]>
git.saurik.com Git - apple/dyld.git/blob - unit-tests/test-cases/crt-libSystem/main.c
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #include <stdio.h> // fprintf(), NULL
24 #include <stdlib.h> // exit(), EXIT_SUCCESS
27 #include <crt_externs.h>
28 #include <mach-o/ldsyms.h>
29 #include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
39 static const struct ProgramVars
* sVars
;
41 // global variables defeined in crt1.o
44 extern char** environ
;
45 extern char* __progname
;
49 main(int argc
, const char* argv
[])
53 if ( _NSGetArgv() != &NXArgv
) {
54 FAIL("crt-libSystem _NSGetArgv() != &NXArgv (%p!=%p) for %s", _NSGetArgv(), &NXArgv
, argv
[0]);
58 if ( _NSGetArgc() != &NXArgc
) {
59 FAIL("crt-libSystem _NSGetArgc() != &NXArgc (%p!=%p) for %s", _NSGetArgc(), &NXArgc
, argv
[0]);
63 if ( _NSGetEnviron() != &environ
) {
64 FAIL("crt-libSystem _NSGetEnviron() != &environv (%p!=%p) for %s", _NSGetEnviron(), &environ
, argv
[0]);
68 if ( _NSGetProgname() != &__progname
) {
69 FAIL("crt-libSystem _NSGetProgname() != &__progname (%p!=%p) for %s", _NSGetProgname(), &__progname
, argv
[0]);
73 if ( _NSGetMachExecuteHeader() != &_mh_execute_header
) {
74 FAIL("crt-libSystem _NSGetMachExecuteHeader() != &_mh_execute_headerv (%p!=%p) for %s", _NSGetMachExecuteHeader(), &_mh_execute_header
, argv
[0]);
78 if ( sVars
->NXArgvPtr
!= &NXArgv
) {
79 FAIL("crt-libSystem sVars->NXArgvPtr != &NXArg (%p!=%p) for %s", sVars
->NXArgvPtr
, &NXArgv
, argv
[0]);
83 if ( sVars
->NXArgcPtr
!= &NXArgc
) {
84 FAIL("crt-libSystem sVars->NXArgcPtr != &NXArgc (%p!=%p) for %s", sVars
->NXArgcPtr
, &NXArgc
, argv
[0]);
88 if ( sVars
->environPtr
!= &environ
) {
89 FAIL("crt-libSystem sVars->environPtr != &environ (%p!=%p) for %s", sVars
->environPtr
, &environ
, argv
[0]);
93 if ( sVars
->__prognamePtr
!= &__progname
) {
94 FAIL("crt-libSystem sVars->__prognamePtr != &__progname (%p!=%p) for %s", sVars
->__prognamePtr
, &__progname
, argv
[0]);
98 if ( sVars
->mh
!= &_mh_execute_header
) {
99 FAIL("crt-libSystem sVars->mh != &_mh_execute_header (%p!=%p) for %s", sVars
->mh
, &_mh_execute_header
, argv
[0]);
104 PASS("crt-libSystem");
111 void __attribute__((constructor
))
112 myInit(int argc
, const char* argv
[], const char* envp
[], const char* apple
[], const struct ProgramVars
* vars
)