|
0
|
1 //================================================================= |
|
|
2 // |
|
|
3 // strcoll2.c |
|
|
4 // |
|
|
5 // Testcase for C library strcoll() |
|
|
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 |
|
2
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //================================================================= |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
2
|
32 // Author(s): ctarpy, jlarmour |
|
|
33 // Contributors: jlarmour |
|
0
|
34 // Date: 1998/6/3 |
|
|
35 // Description: Contains testcode for C library strcoll() function |
|
|
36 // |
|
|
37 // |
|
|
38 //####DESCRIPTIONEND#### |
|
|
39 |
|
|
40 // Declarations for test system: |
|
|
41 // |
|
|
42 // TESTCASE_TYPE=CYG_TEST_MODULE |
|
|
43 // COMPOUND_TESTCASE |
|
|
44 |
|
|
45 |
|
|
46 // INCLUDES |
|
|
47 |
|
|
48 #include <string.h> |
|
|
49 #include <cyg/infra/testcase.h> |
|
|
50 #include <sys/cstartup.h> // C library initialisation |
|
|
51 |
|
|
52 // CONSTANTS |
|
|
53 |
|
|
54 #define NUM_ROBUSTNESS_RUNS 300 |
|
|
55 |
|
|
56 // FUNCTIONS |
|
|
57 |
|
|
58 |
|
|
59 externC void |
|
|
60 cyg_package_start( void ) |
|
|
61 { |
|
|
62 #ifdef CYGPKG_LIBC |
|
|
63 cyg_iso_c_start(); |
|
|
64 #else |
|
|
65 (void)main(0, NULL); |
|
|
66 #endif |
|
|
67 } // cyg_package_start() |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 // Functions to avoid having to use libc strings |
|
|
72 |
|
|
73 static char *my_strcpy(char *s1, const char *s2) |
|
|
74 { |
|
|
75 while (*s2 != '\0') { |
|
|
76 *(s1++) = *(s2++); |
|
|
77 } |
|
|
78 *s1 = '\0'; |
|
|
79 |
|
|
80 return s1; |
|
|
81 } // my_strcpy() |
|
|
82 |
|
|
83 |
|
|
84 int main( int argc, char *argv[] ) |
|
|
85 { |
|
|
86 char x[300]; |
|
|
87 char y[300]; |
|
|
88 char z[300]; |
|
|
89 int ctr; |
|
|
90 int fail; |
|
|
91 |
|
|
92 CYG_TEST_INIT(); |
|
|
93 |
|
|
94 CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " |
|
|
95 "strcoll() function"); |
|
|
96 CYG_TEST_INFO("This testcase tests robustness, and may take some time"); |
|
|
97 |
|
|
98 fail = 0; |
|
|
99 for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) |
|
|
100 { |
|
|
101 my_strcpy(x, "Spare a talent for an old ex-leper"); |
|
|
102 my_strcpy(y, "Spare a talent for an old ex-leper"); |
|
|
103 my_strcpy(z, "I was hopping along, when suddenly he"); |
|
|
104 |
|
|
105 if (strcoll(x, y) != 0) |
|
|
106 { |
|
|
107 fail = 1; |
|
|
108 break; |
|
|
109 } |
|
|
110 if (strcoll(x, z) == 0) |
|
|
111 { |
|
|
112 fail = 1; |
|
|
113 break; |
|
|
114 } // if |
|
|
115 } // for |
|
|
116 |
|
|
117 CYG_TEST_PASS_FAIL( (fail==0), "Robustness test"); |
|
|
118 |
|
|
119 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " |
|
|
120 "strcoll() function"); |
|
|
121 } // main() |
|
|
122 |
|
|
123 |
|
|
124 // EOF strcoll2.c |