#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#include <mach-o/dyld_priv.h>
#include "test_support.h"
typedef void (*NotifyProc)(void);
static bool termDidRun = false;
static void termNotifyFunc()
{
termDidRun = true;
}
int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
void* handle = dlopen(RUN_DIR "/libterm.dylib", RTLD_LAZY);
if ( handle == NULL ) {
FAIL("libterm.dylib could not be loaded, %s", dlerror());
}
NotifyProc* pointerAddress = (NotifyProc*)dlsym(handle, "gNotifer");
if ( pointerAddress == NULL ) {
FAIL("gNotifer not found in libterm.dylib");
}
*pointerAddress = &termNotifyFunc;
dlclose(handle);
if ( termDidRun )
PASS("Success");
else
FAIL("terminator not run");
}