OLD | NEW |
1 /* expandargv test program, | 1 /* expandargv test program, |
2 Copyright (C) 2006 Free Software Foundation, Inc. | 2 Copyright (C) 2006 Free Software Foundation, Inc. |
3 Written by Carlos O'Donell <carlos@codesourcery.com> | 3 Written by Carlos O'Donell <carlos@codesourcery.com> |
4 | 4 |
5 This file is part of the libiberty library, which is part of GCC. | 5 This file is part of the libiberty library, which is part of GCC. |
6 | 6 |
7 This file is free software; you can redistribute it and/or modify | 7 This file is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 2 of the License, or | 9 the Free Software Foundation; either version 2 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 0, | 100 0, |
101 | 101 |
102 /* Test 3 - Check for expansion with only \0 */ | 102 /* Test 3 - Check for expansion with only \0 */ |
103 "\b", /* Test 3 data */ | 103 "\b", /* Test 3 data */ |
104 ARGV0, | 104 ARGV0, |
105 "@test-expandargv-3.lst", | 105 "@test-expandargv-3.lst", |
106 0, | 106 0, |
107 ARGV0, | 107 ARGV0, |
108 0, | 108 0, |
109 | 109 |
| 110 /* Test 4 - Check for options beginning with an empty line. */ |
| 111 "\na\nb", /* Test 4 data */ |
| 112 ARGV0, |
| 113 "@test-expandargv-4.lst", |
| 114 0, |
| 115 ARGV0, |
| 116 "a", |
| 117 "b", |
| 118 0, |
| 119 |
| 120 /* Test 5 - Check for options containing an empty argument. */ |
| 121 "a\n''\nb", /* Test 5 data */ |
| 122 ARGV0, |
| 123 "@test-expandargv-5.lst", |
| 124 0, |
| 125 ARGV0, |
| 126 "a", |
| 127 "", |
| 128 "b", |
| 129 0, |
| 130 |
| 131 /* Test 6 - Check for options containing a quoted newline. */ |
| 132 "a\n'a\n\nb'\nb", /* Test 6 data */ |
| 133 ARGV0, |
| 134 "@test-expandargv-6.lst", |
| 135 0, |
| 136 ARGV0, |
| 137 "a", |
| 138 "a\n\nb", |
| 139 "b", |
| 140 0, |
| 141 |
110 0 /* Test done marker, don't remove. */ | 142 0 /* Test done marker, don't remove. */ |
111 }; | 143 }; |
112 | 144 |
113 /* Print a fatal error and exit. LINE is the line number where we | 145 /* Print a fatal error and exit. LINE is the line number where we |
114 detected the error, ERRMSG is the error message to print, and ERR | 146 detected the error, ERRMSG is the error message to print, and ERR |
115 is 0 or an errno value to print. */ | 147 is 0 or an errno value to print. */ |
116 | 148 |
117 static void | 149 static void |
118 fatal_error (int line, const char *errmsg, int err) | 150 fatal_error (int line, const char *errmsg, int err) |
119 { | 151 { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 failed = 0; | 271 failed = 0; |
240 /* Compare size first */ | 272 /* Compare size first */ |
241 if (argc_before != argc_after) | 273 if (argc_before != argc_after) |
242 { | 274 { |
243 printf ("FAIL: test-expandargv-%d. Number of arguments don't match.\n"
, i); | 275 printf ("FAIL: test-expandargv-%d. Number of arguments don't match.\n"
, i); |
244 failed++; | 276 failed++; |
245 } | 277 } |
246 /* Compare each of the argv's ... */ | 278 /* Compare each of the argv's ... */ |
247 else | 279 else |
248 for (k = 0; k < argc_after; k++) | 280 for (k = 0; k < argc_after; k++) |
249 if (strncmp (argv_before[k], argv_after[k], strlen(argv_after[k])) !=
0) | 281 if (strcmp (argv_before[k], argv_after[k]) != 0) |
250 { | 282 { |
251 printf ("FAIL: test-expandargv-%d. Arguments don't match.\n", i); | 283 printf ("FAIL: test-expandargv-%d. Arguments don't match.\n", i); |
252 failed++; | 284 failed++; |
253 } | 285 } |
254 | 286 |
255 if (!failed) | 287 if (!failed) |
256 printf ("PASS: test-expandargv-%d.\n", i); | 288 printf ("PASS: test-expandargv-%d.\n", i); |
257 else | 289 else |
258 fails++; | 290 fails++; |
259 | 291 |
(...skipping 27 matching lines...) Expand all Loading... |
287 else the test fails. | 319 else the test fails. |
288 - Erase test file. */ | 320 - Erase test file. */ |
289 | 321 |
290 fails = run_tests (test_data); | 322 fails = run_tests (test_data); |
291 if (!fails) | 323 if (!fails) |
292 exit (EXIT_SUCCESS); | 324 exit (EXIT_SUCCESS); |
293 else | 325 else |
294 exit (EXIT_FAILURE); | 326 exit (EXIT_FAILURE); |
295 } | 327 } |
296 | 328 |
OLD | NEW |