comparison packages/language/c/libc/current/tests/stdlib/atexit.c @ 0:3111d98ba7b3 ecos-v1_1-release

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