X-Git-Url: https://git.saurik.com/apple/objc4.git/blobdiff_plain/7c0e6487d7b67b6bf6c632300ee4b74e8950b051..7af964d1562d70f51a8e9aca24215ac3d83d0624:/test/load-reentrant.m diff --git a/test/load-reentrant.m b/test/load-reentrant.m new file mode 100644 index 0000000..d1740e4 --- /dev/null +++ b/test/load-reentrant.m @@ -0,0 +1,28 @@ +#include "test.h" +#include + +int state1 = 0; +int *state2_p; + +@interface One @end +@implementation One ++(void)load +{ + state1 = 111; + + // Re-entrant +load doesn't get to complete until we do + void *dlh = dlopen("libload-reentrant2.dylib", RTLD_LAZY); + testassert(dlh); + state2_p = (int *)dlsym(dlh, "state2"); + testassert(state2_p); + testassert(*state2_p == 0); + + state1 = 1; +} +@end + +int main() +{ + testassert(state1 == 1 && state2_p && *state2_p == 2); + succeed(__FILE__); +}