comparison packages/language/c/libc/startup/current/tests/atexit.c @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
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 Red Hat eCos Public License
12 // Version 1.1 (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://www.redhat.com/
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 Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //=================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): jlarmour
35 // Contributors:
36 // Date: 2000-04-30
37 // Description: Contains testcode for C library atexit() function
38 //
39 //
40 //####DESCRIPTIONEND####
41
42 // CONFIGURATION
43
44 #include <pkgconf/libc_startup.h> // Configuration header
45
46 // INCLUDES
47
48 #include <stdlib.h> // Main header for stdlib functions
49 #include <cyg/infra/testcase.h> // Testcase API
50
51
52 // STATICS
53
54 static int stage;
55 static int failed;
56
57 // FUNCTIONS
58
59 #if defined(CYGFUN_LIBC_ATEXIT)
60
61 static void
62 myfun1( void )
63 {
64 if (!failed)
65 {
66 CYG_TEST_PASS_FAIL( stage==0, "first function called correctly" );
67 stage=1;
68 } // if
69 } // myfun1()
70
71 static void
72 myfun2( void )
73 {
74 if (!failed)
75 {
76 CYG_TEST_PASS_FAIL( stage==1, "Second function called correctly" );
77 stage=2;
78 } // if
79 } // myfun2()
80
81 static void
82 myfun3( void )
83 {
84 if (!failed)
85 {
86 CYG_TEST_PASS_FAIL( stage==2, "Second function called correctly" );
87 stage=3;
88 } // if
89
90 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C "
91 "library atexit() function");
92
93 } // myfun3()
94
95 #endif // if defined(CYGFUN_LIBC_ATEXIT)
96
97 int
98 main( int argc, char *argv[] )
99 {
100 CYG_TEST_INIT();
101
102 CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C "
103 "library atexit() function");
104
105 #if defined(CYGFUN_LIBC_ATEXIT)
106
107 // we only have one test in us! We can only exit once :-)
108
109 CYG_TEST_PASS_FAIL( atexit(&myfun3)==0,
110 "Simple registration of first atexit() function" );
111
112 CYG_TEST_PASS_FAIL( atexit(&myfun2)==0,
113 "Simple registration of second atexit() function" );
114
115 CYG_TEST_PASS_FAIL( atexit(&myfun1)==0,
116 "Simple registration of third atexit() function" );
117
118 return 0;
119 #else
120 CYG_TEST_NA("Testing is not applicable to this configuration");
121
122 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C "
123 "library atexit() function");
124
125 #endif // if defined(CYGFUN_LIBC_ATEXIT)
126
127 } // main()
128
129 // EOF atexit.c