#include <stdio.h>
#include <dlfcn.h>
#include <mach-o/dyld.h>
#include "test_support.h"
int main(int arg, const char* argv[])
{
#if FOR_IOSMAC
void* handle = dlopen("/System/Library/Frameworks/UIKit.framework/UIKit", RTLD_LAZY);
if ( handle == NULL ) {
FAIL("dlopen-iOS-on-Mac, UIKit failed to dlopen(): %s", dlerror());
return 0;
}
#else
void* handle = dlopen("/System/Library/Frameworks/AppKit.framework/AppKit", RTLD_LAZY);
if ( handle == NULL ) {
FAIL("dlopen-macOS, AppKit failed to dlopen(): %s", dlerror());
return 0;
}
handle = dlopen(RUN_DIR "/libtestnotincache.dylib", RTLD_LAZY);
if ( handle != NULL ) {
FAIL("dlopen-macOS, libtestnotincache.dylib should not be loaded");
return 0;
}
handle = dlopen(RUN_DIR "/libtestincache.dylib", RTLD_LAZY);
if ( handle != NULL ) {
FAIL("dlopen-macOS, libtestincache.dylib should not be loaded");
return 0;
}
#endif
#if FOR_IOSMAC
PASS("dlopen-iOS-on-Mac");
#else
PASS("dlopen-macOS");
#endif
return 0;
}