Skip to content
Browse files

Fix test so that it works on Mac OS X 10.7 Lion.

  • Loading branch information...
1 parent fbd0517 commit 820b779918f927cd144729f8fd8e520e6b73bfbf @lapcat lapcat committed
Showing with 8 additions and 2 deletions.
  1. +8 −2 mach_override/test_mach_override.cp
View
10 mach_override/test_mach_override.cp
@@ -2,6 +2,7 @@
#include <assert.h>
#include <string.h>
#include <errno.h>
+#include <CoreServices/CoreServices.h>
#include "mach_override.h"
#define assertStrEqual( EXPECTED, ACTUAL ) if( strcmp( (EXPECTED), (ACTUAL) ) != 0 ) { printf( "EXPECTED: %s\nACTUAL: %s\n", (EXPECTED), (ACTUAL)); assert( strcmp( (EXPECTED), (ACTUAL) ) == 0 ); }
@@ -40,17 +41,22 @@ void testLocalFunctionOverrideByPointer() {
#pragma mark Test System Override by Pointer
char* (*strerrorPtr)(int) = strerror;
+const char* strerrReturnValue = "Unknown error: 0";
void testSystemFunctionOverrideByPointer() {
+ SInt32 sysv;
+ if (Gestalt( gestaltSystemVersion, &sysv ) == noErr && sysv >= 0x1070)
+ strerrReturnValue = "Undefined error: 0";
+
// Test original.
- assertStrEqual( "Unknown error: 0", strerrorPtr( 0 ) );
+ assertStrEqual( strerrReturnValue, strerrorPtr( 0 ) );
// Override system function by pointer.
kern_return_t err;
MACH_OVERRIDE( char*, strerror, (int errnum), err ) {
// Test calling through the reentry island back into the original
// implementation.
- assertStrEqual( "Unknown error: 0", strerror_reenter( 0 ) );
+ assertStrEqual( strerrReturnValue, strerror_reenter( 0 ) );
return (char *)"strerrorOverride";
} END_MACH_OVERRIDE(strerror);

0 comments on commit 820b779

Please sign in to comment.
Something went wrong with that request. Please try again.