]> git.saurik.com Git - apple/dyld.git/blobdiff - unit-tests/test-cases/bundle-memory-load-bad/main.c
dyld-353.2.1.tar.gz
[apple/dyld.git] / unit-tests / test-cases / bundle-memory-load-bad / main.c
index fe100daf1d8d820bf2951e39bf7867575a93efaf..7e8c93c848ad3411cc005ac0706801f56d1c450c 100644 (file)
 #include <sys/mman.h> 
 #include <unistd.h>
 #include <fcntl.h>
+#include <Availability.h>
 
 #include "test.h" // PASS(), FAIL()
 
 int main()
 {
+// NSAddImage is only available on Mac OS X - not iPhone OS
+#if __MAC_OS_X_VERSION_MIN_REQUIRED
        int fd = open("test.bundle", O_RDONLY, 0);
        if ( fd == -1 ) {
                FAIL("open() failed");
@@ -55,10 +58,11 @@ int main()
 
        // we are using a file not of type MH_BUNDLE, so NSCreateObjectFileImageFromMemory should fail
        NSObjectFileImage ofi;
-       if ( NSCreateObjectFileImageFromMemory(loadAddress, stat_buf.st_size, &ofi) != NSObjectFileImageSuccess ) 
-               PASS("bundle-memory-load-bad");
-       else
+       if ( NSCreateObjectFileImageFromMemory(loadAddress, stat_buf.st_size, &ofi) == NSObjectFileImageSuccess ) 
                FAIL("bundle-memory-load-bad");
+       else
+#endif
+               PASS("bundle-memory-load-bad");
        
        return 0;
 }
\ No newline at end of file