]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_has_inserted_or_interposing_libraries.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / dyld_has_inserted_or_interposing_libraries.dtest / main.c
1
2 // BUILD: $CC main.c -DRUN_DIR=$RUN_DIR -o $BUILD_DIR/insert_target.exe
3 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
4 // BUILD: $CC interposer.c -dynamiclib $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libinterposer.dylib -o $BUILD_DIR/libinterposer.dylib
5 // BUILD: $CC main.c $BUILD_DIR/libinterposer.dylib $BUILD_DIR/libfoo.dylib -DRUN_DIR=$RUN_DIR -o $BUILD_DIR/interpose_target.exe
6 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/insert_target.exe
7
8 // RUN: ./insert_target.exe
9 // RUN: DYLD_INSERT_LIBRARIES=$RUN_DIR/libfoo.dylib ./insert_target.exe true
10 // RUN: ./interpose_target.exe true
11
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <stdbool.h>
15 #include <string.h>
16 #include <mach-o/dyld_priv.h>
17
18 #include "test_support.h"
19
20 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
21 bool actual = dyld_has_inserted_or_interposing_libraries();
22 bool expected = (argc == 2) && (strcmp(argv[1], "true") == 0);
23
24 if (actual != expected) {
25 FAIL("dyld_has_inserted_or_interposing_libraries");
26 }
27
28 PASS("Success");
29 }