Mercurial > flash_v2
annotate packages/language/c/libc/current/tests/stdlib/atexit.c @ 64:c38311975d4f ecos-sw-2000-01-28
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
| author | jlarmour |
|---|---|
| date | Fri, 28 Jan 2000 04:59:39 +0000 |
| parents | 443894e2e912 |
| children | bf00f99aec69 |
| rev | line source |
|---|---|
| 0 | 1 //================================================================= |
| 2 // | |
| 3 // atexit.c | |
| 4 // | |
| 5 // Testcase for C library atexit() | |
| 6 // | |
| 7 //================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
14 // http://sourceware.cygnus.com/ecos |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
16 // Software distributed under the License is distributed on an |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 0 | 30 //####COPYRIGHTEND#### |
| 31 //================================================================= | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 2 | 34 // Author(s): jlarmour |
| 35 // Contributors: jlarmour | |
| 36 // Date: 1999-03-03 | |
| 0 | 37 // Description: Contains testcode for C library atexit() function |
| 38 // | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 | |
| 42 // Declarations for test system: | |
| 43 // | |
| 44 // TESTCASE_TYPE=CYG_TEST_MODULE | |
| 45 | |
| 46 | |
| 47 // CONFIGURATION | |
| 48 | |
| 49 #include <pkgconf/libc.h> // Configuration header | |
| 50 | |
| 51 // INCLUDES | |
| 52 | |
| 53 #include <stdlib.h> // Main header for stdlib functions | |
| 54 #include <cyg/infra/testcase.h> // Testcase API | |
| 55 #include <sys/cstartup.h> // C library initialisation | |
| 56 | |
| 57 | |
| 58 // STATICS | |
| 59 | |
| 60 static int stage; | |
| 61 static int failed; | |
| 62 | |
| 63 // FUNCTIONS | |
| 64 | |
| 65 externC void | |
| 66 cyg_package_start( void ) | |
| 67 { | |
| 68 cyg_iso_c_start(); | |
| 69 } // cyg_package_start() | |
| 70 | |
| 71 | |
| 72 static void | |
| 73 myfun1( void ) | |
| 74 { | |
| 75 if (!failed) | |
| 76 { | |
| 77 CYG_TEST_PASS_FAIL( stage==0, "first function called correctly" ); | |
| 78 stage=1; | |
| 79 } // if | |
| 80 } // myfun1() | |
| 81 | |
| 82 static void | |
| 83 myfun2( void ) | |
| 84 { | |
| 85 if (!failed) | |
| 86 { | |
| 87 CYG_TEST_PASS_FAIL( stage==1, "Second function called correctly" ); | |
| 88 stage=2; | |
| 89 } // if | |
| 90 } // myfun2() | |
| 91 | |
| 92 static void | |
| 93 myfun3( void ) | |
| 94 { | |
| 95 if (!failed) | |
| 96 { | |
| 97 CYG_TEST_PASS_FAIL( stage==2, "Second function called correctly" ); | |
| 98 stage=3; | |
| 99 } // if | |
| 100 | |
| 101 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " | |
| 102 "library atexit() function"); | |
| 103 | |
| 104 } // myfun3() | |
| 105 | |
| 106 int | |
| 107 main( int argc, char *argv[] ) | |
| 108 { | |
| 109 CYG_TEST_INIT(); | |
| 110 | |
| 111 CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " | |
| 112 "library atexit() function"); | |
| 113 | |
| 2 | 114 #if defined(CYGFUN_LIBC_ATEXIT) |
| 0 | 115 |
| 116 // we only have one test in us! We can only exit once :-) | |
| 117 | |
| 118 CYG_TEST_PASS_FAIL( atexit(&myfun3)==0, | |
| 119 "Simple registration of first atexit() function" ); | |
| 120 | |
| 121 CYG_TEST_PASS_FAIL( atexit(&myfun2)==0, | |
| 122 "Simple registration of second atexit() function" ); | |
| 123 | |
| 124 CYG_TEST_PASS_FAIL( atexit(&myfun1)==0, | |
| 125 "Simple registration of third atexit() function" ); | |
| 126 | |
| 127 return 0; | |
| 128 #else | |
| 2 | 129 CYG_TEST_NA("Testing is not applicable to this configuration"); |
| 0 | 130 |
| 131 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " | |
| 132 "library atexit() function"); | |
| 133 | |
| 2 | 134 #endif // if defined(CYGFUN_LIBC_ATEXIT) |
| 0 | 135 |
| 136 } // main() | |
| 137 | |
| 138 // EOF atexit.c |
