]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/env-DYLD_LIBRARY_PATH.dtest/main.c
dyld-519.2.1.tar.gz
[apple/dyld.git] / testing / test-cases / env-DYLD_LIBRARY_PATH.dtest / main.c
1
2 // BUILD: mkdir -p $BUILD_DIR/door1 $BUILD_DIR/door2
3 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/door1/libfoo.dylib -install_name $RUN_DIR/door1/libfoo.dylib -DVALUE=1
4 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/door2/libfoo.dylib -install_name $RUN_DIR/door2/libfoo.dylib -DVALUE=42
5 // BUILD: $CC main.c -o $BUILD_DIR/main.exe $BUILD_DIR/door1/libfoo.dylib
6 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/main.exe
7
8 // RUN: ./main.exe
9 // RUN: DYLD_LIBRARY_PATH=$RUN_DIR/door2/ ./main.exe
10
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 extern int foo();
15
16 int main()
17 {
18 int expected = (getenv("DYLD_LIBRARY_PATH") != NULL) ? 42 : 1;
19
20 printf("[BEGIN] env-DYLD_LIBRARY_PATH, expect %d\n", expected);
21
22 if ( foo() == expected )
23 printf("[PASS] env-DYLD_LIBRARY_PATH\n");
24 else
25 printf("[FAIL] env-DYLD_LIBRARY_PATH\n");
26
27 return 0;
28 }
29