#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <mach-o/dyld_priv.h>
#include "test_support.h"
bool gFoundLibrary = false;
const char* gLibraryName = NULL;
bool wasImageLoaded(const char* libraryName) {
gFoundLibrary = false;
gLibraryName = libraryName;
_dyld_register_for_image_loads([](const mach_header* mh, const char* path, bool unloadable) {
if ( strstr(path, gLibraryName) != NULL ) {
gFoundLibrary = true;
}
});
if (!gFoundLibrary)
FAIL("Expected insert to pass for '%s'", libraryName);
return gFoundLibrary;
}
int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
if (!wasImageLoaded("libfoo.dylib") || !wasImageLoaded("libbar.dylib")) {
return 0;
}
PASS("Success");
}