OCMock sigabrt on execution

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

OCMock sigabrt on execution

Postby stan4th » 26 Sep 2012, 17:21

I've created a project for iPad from scratch including unit test project, added OCMock lib and headers and set all the paths in the project.
I've added the code for a mock test from the sample on the website (I've commented out all but the first line of the test to establish which line it fails on;
Code: Select all
#import "ELOITests.h"
#import <OCMock/OCMock.h>

@implementation ELOITests

- (void)setUp
    [super setUp];
    // Set-up code here.

- (void)tearDown
    // Tear-down code here.
    [super tearDown];

- (void)testExample
//    STFail(@"Unit tests are not implemented yet in ELOITests");

- (void)testOCMockPass {
    id mock = [OCMockObject mockForClass:NSString.class];
//    [[[mock stub] andReturn:@"mocktest"] lowercaseString];
//    NSString *returnValue = [mock lowercaseString];
//    STAssertEqualObjects(@"mocktest", returnValue, @"Should have returned the expected string.");


but when it executes it halts in the assembly code for OCMock with a sigabrt.

ELOITests`+[OCMockObject initialize] at OCMockObject.m:26:
0x6a7e5f9: pushl %ebp
0x6a7e5fa: movl %esp, %ebp
0x6a7e5fc: pushl %esi
0x6a7e5fd: subl $20, %esp
0x6a7e600: calll 0x6a7e605 ; +[OCMockObject initialize] + 12 at OCMockObject.m:28
0x6a7e605: popl %esi
0x6a7e606: movl 28275(%esi), %eax
0x6a7e60c: movl 27755(%esi), %ecx
0x6a7e612: movl %ecx, 4(%esp)
0x6a7e616: movl %eax, (%esp)
0x6a7e619: calll 0x6a81544 ; symbol stub for: objc_msgSend
0x6a7e61e: movl 27863(%esi), %ecx
0x6a7e624: movl 27859(%esi), %edx
0x6a7e62a: movl %edx, 8(%esp)
0x6a7e62e: movl %ecx, 4(%esp)
0x6a7e632: movl %eax, (%esp)
0x6a7e635: calll 0x6a81544 ; symbol stub for: objc_msgSend
0x6a7e63a: testl %eax, %eax
0x6a7e63c: jne 0x6a7e66c ; +[OCMockObject initialize] + 115 at OCMockObject.m:30
0x6a7e63e: movl 28279(%esi), %eax
0x6a7e644: movl 27867(%esi), %ecx
0x6a7e64a: leal 29847(%esi), %edx
0x6a7e650: movl %edx, 12(%esp)
0x6a7e654: movl 23055(%esi), %edx
0x6a7e65a: movl (%edx), %edx
0x6a7e65c: movl %edx, 8(%esp)
0x6a7e660: movl %ecx, 4(%esp)
0x6a7e664: movl %eax, (%esp)
0x6a7e667: calll 0x6a81544 ; symbol stub for: objc_msgSend
0x6a7e66c: addl $20, %esp
0x6a7e66f: popl %esi
0x6a7e670: popl %ebp
0x6a7e671: ret

Re: OCMock sigabrt on execution

Postby stan4th » 26 Sep 2012, 17:24


It fails on the 4th to last line

Code: Select all
0x6a7e66c:  addl   $20, %esp
with the error msg Thread 1: signal SIGABRT


Return to OCMock