]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/flat-namespace.dtest/main.c
dyld-733.8.tar.gz
[apple/dyld.git] / testing / test-cases / flat-namespace.dtest / main.c
1 // BUILD_ONLY: MacOSX
2
3 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib
4 // BUILD: $CC main.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/flat-namespace.exe -flat_namespace
5
6 // RUN: ./flat-namespace.exe
7
8
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 int main()
15 {
16 printf("[BEGIN] flat-namespace\n");
17
18 // check that the malloc in libfoo.dylib was used by looking at the content the allocated buffer
19 // <rdar://problem/31921090> strncmp is tricky for flat namespace because it is re-exporte and renamed
20 char* p1 = malloc(10);
21 if ( strncmp(p1, "##########", 10) != 0 ) {
22 printf("[FAIL] malloc() from main executable not interposed\n");
23 return 0;
24 }
25
26 printf("[PASS] flat-namespace\n");
27 return 0;
28 }