]> git.saurik.com Git - apple/dyld.git/blobdiff - unit-tests/test-cases/crt-apple/main.c
dyld-360.14.tar.gz
[apple/dyld.git] / unit-tests / test-cases / crt-apple / main.c
index 05959bb763717b40d6178352ef90f6ea22a58fcb..8a56fd87a9d27046301920e2ae031ae53d7308f7 100644 (file)
@@ -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@
  * 
 
 
 ///
+/// 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;
 }