X-Git-Url: https://git.saurik.com/apple/dyld.git/blobdiff_plain/bac542e65c0030c0d819c7ff1dcfc25892a61844..df9d6cf7fb01f4e3d4128fe7a687984fe0b45584:/unit-tests/test-cases/crt-apple/main.c diff --git a/unit-tests/test-cases/crt-apple/main.c b/unit-tests/test-cases/crt-apple/main.c index 05959bb..8a56fd8 100644 --- a/unit-tests/test-cases/crt-apple/main.c +++ b/unit-tests/test-cases/crt-apple/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Apple Inc. All rights reserved. + * Copyright (c) 2007-2010 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -28,16 +28,52 @@ /// +/// verify parameters passed to initializer are same as passed to main() /// verify that apple[0] parameter is correct by comparing to argv[1] /// +static int initializer_argc = 0; +static const char** initializer_argv = NULL; +static const char** initializer_env = NULL; +static const char** initializer_apple = NULL; + + +__attribute__((constructor)) +void init(int argc, const char* argv[], const char* env[], const char* apple[]) +{ + initializer_argc = argc; + initializer_argv = argv; + initializer_env = env; + initializer_apple = apple; +} + int main(int argc, const char* argv[], const char* env[], const char* apple[]) { + if ( argc != initializer_argc ) { + FAIL("crt-apple argc changed"); + exit(EXIT_SUCCESS); + } + + if ( argv != initializer_argv ) { + FAIL("crt-apple argv changed"); + exit(EXIT_SUCCESS); + } + + if ( env != initializer_env ) { + FAIL("crt-apple envp changed"); + exit(EXIT_SUCCESS); + } + + if ( apple != initializer_apple ) { + FAIL("crt-apple apple changed"); + exit(EXIT_SUCCESS); + } + if ( strcmp(apple[0], argv[1]) == 0 ) - PASS("crt-apple %s", argv[0]); + PASS("crt-apple %s", apple[0]); else - FAIL("crt-apple %s", argv[0]); + FAIL("crt-apple %s", apple[0]); return EXIT_SUCCESS; }