#include <stdbool.h> // fprintf(), NULL
#include <stdio.h> // fprintf(), NULL
#include <stdlib.h> // exit(), EXIT_SUCCESS
#include <stdbool.h>
#include <string.h>
#include <mach-o/dyld.h>
#include <mach-o/dyld_priv.h>
#include <dlfcn.h>
#include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
int main(int argc, const char* argv[])
{
if ( ! dlopen_preflight("libfoo.dylib") ) {
FAIL("dlopen_preflight-cycle libfoo.dylib should not be loadable");
return EXIT_SUCCESS;
}
void* handle = dlopen("libbar.dylib", RTLD_NOLOAD);
if ( handle != NULL ) {
FAIL("dlopen_preflight-cycle libbar.dylib was left loaded by dlopen_preflight()");
return EXIT_SUCCESS;
}
handle = dlopen("libbaz.dylib", RTLD_NOLOAD);
if ( handle != NULL ) {
FAIL("dlopen_preflight-cycle libbaz.dylib was left loaded by dlopen_preflight()");
return EXIT_SUCCESS;
}
handle = dlopen("libfoo.dylib", RTLD_NOLOAD);
if ( handle != NULL ) {
FAIL("dlopen_preflight-cycle libfoo.dylib was left loaded by dlopen_preflight()");
return EXIT_SUCCESS;
}
PASS("dlopen_preflight-cycle");
return EXIT_SUCCESS;
}