| 1 |
#! /usr/bin/awk -f |
| 2 |
# Generated from checkmk.in;FILEPATH by configure. |
| 3 |
|
| 4 |
# checkmk - translate more concise versions of test suite specifications |
| 5 |
# into C programs suitable for use with the Check unit test |
| 6 |
# framework. |
| 7 |
|
| 8 |
# -- LICENSE -- |
| 9 |
# |
| 10 |
# Written by Micah Cowan <[email protected]> |
| 11 |
# Copyright (c) 2006, 2010 Micah Cowan |
| 12 |
# |
| 13 |
# Redistribution of this program in any form, with or without |
| 14 |
# modifications, is permitted, provided that the above copyright is |
| 15 |
# retained in distributions of this program in source form. |
| 16 |
# |
| 17 |
# (This is a free, non-copyleft license compatible with pretty much any |
| 18 |
# other free or proprietary license, including the GPL. It's essentially |
| 19 |
# a scaled-down version of the "modified" BSD license.) |
| 20 |
|
| 21 |
BEGIN { |
| 22 |
progname="checkmk"; |
| 23 |
is_stdin=0; |
| 24 |
outfname="/dev/stdout"; |
| 25 |
|
| 26 |
# Tokens |
| 27 |
pp_ws = "[ \\t\\f\\v\\r\\n]+"; |
| 28 |
pp_ws_op = "[ \\t\\f\\v\\r\\n]*"; |
| 29 |
pp_digit = "[0-9]+" |
| 30 |
pp_prefix = pp_ws_op "#" pp_ws_op; |
| 31 |
pp_sep = "[ \\t\\f\\v\\r\\n]+"; |
| 32 |
pp_name = ".+"; |
| 33 |
pp_hex_quad = "[A-F0-9a-f][A-F0-9a-f][A-F0-9a-f][A-F0-9a-f]" |
| 34 |
pp_ucn = "\\\\(u" pp_hex_quad "|U" pp_hex_quad pp_hex_quad ")"; |
| 35 |
pp_test_name = "([A-Za-z_]|" pp_ucn ")([A-Za-z0-9_]|" pp_ucn ")*"; |
| 36 |
pp_tag = "([Ss][Uu][Ii][Tt][Ee]|[Tt][Cc][Aa][Ss][Ee])"; |
| 37 |
pp_test_tag = "[Tt][Ee][Ss][Tt]"; |
| 38 |
pp_main_pre_tag = "[Mm][Aa][Ii][Nn]-[Pp][Rr][Ee]"; |
| 39 |
pp_main_post_tag = "[Mm][Aa][Ii][Nn]-[Pp][Oo][Ss][Tt]"; |
| 40 |
|
| 41 |
# Tests with arguments |
| 42 |
pp_test_exit_tag = "[Tt][Ee][Ss][Tt]-[Ee][Xx][Ii][Tt]" pp_ws_op "[(]" \ |
| 43 |
pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op "[)]"; |
| 44 |
|
| 45 |
pp_test_signal_tag = "[Tt][Ee][Ss][Tt]-[Ss][Ii][Gg][Nn][Aa][Ll]" pp_ws_op \ |
| 46 |
"[(]" pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op "[)]"; |
| 47 |
|
| 48 |
pp_test_loop_tag = "[Tt][Ee][Ss][Tt]-[Ll][Oo][Oo][Pp]" pp_ws_op "[(]" \ |
| 49 |
pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op "[,]" pp_ws_op \ |
| 50 |
"[+-]?" pp_ws_op pp_digit pp_ws_op "[)]"; |
| 51 |
|
| 52 |
pp_test_loop_exit_tag = "[Tt][Ee][Ss][Tt]-[Ll][Oo][Oo][Pp]-[Ee][Xx][Ii][Tt]" \ |
| 53 |
pp_ws_op "[(]" pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op \ |
| 54 |
"[,]" pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op "[,]" \ |
| 55 |
pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op "[)]"; |
| 56 |
|
| 57 |
pp_test_loop_signal_tag = "[Tt][Ee][Ss][Tt]-[Ll][Oo][Oo][Pp]-[Ss][Ii][Gg]" \ |
| 58 |
"[Nn][Aa][Ll]" pp_ws_op "[(]" pp_ws_op "[+-]?" pp_ws_op pp_digit \ |
| 59 |
pp_ws_op "[,]" pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op \ |
| 60 |
"[,]" pp_ws_op "[+-]?" pp_ws_op pp_digit pp_ws_op "[)]"; |
| 61 |
|
| 62 |
pp_suite_or_tcase_line = "^" pp_prefix pp_tag pp_ws pp_name "$"; |
| 63 |
pp_test_line_prefix = "^" pp_prefix pp_test_tag pp_ws; |
| 64 |
pp_test_exit_line_prefix = "^" pp_prefix pp_test_exit_tag pp_ws; |
| 65 |
pp_test_signal_line_prefix = "^" pp_prefix pp_test_signal_tag pp_ws; |
| 66 |
pp_test_loop_line_prefix = "^" pp_prefix pp_test_loop_tag pp_ws; |
| 67 |
pp_test_loop_exit_line_prefix = "^" pp_prefix pp_test_loop_exit_tag pp_ws; |
| 68 |
pp_test_loop_signal_line_prefix = "^" pp_prefix pp_test_loop_signal_tag pp_ws; |
| 69 |
pp_test_line = pp_test_line_prefix pp_name pp_ws_op "$"; |
| 70 |
pp_test_exit_line = pp_test_exit_line_prefix pp_name pp_ws_op "$"; |
| 71 |
pp_test_signal_line = pp_test_signal_line_prefix pp_name pp_ws_op "$"; |
| 72 |
pp_test_loop_line = pp_test_loop_line_prefix pp_name pp_ws_op "$"; |
| 73 |
pp_test_loop_exit_line = pp_test_loop_exit_line_prefix pp_name pp_ws_op "$"; |
| 74 |
pp_test_loop_signal_line = pp_test_loop_signal_line_prefix pp_name pp_ws_op "$"; |
| 75 |
pp_main_pre_line = "^" pp_prefix pp_main_pre_tag pp_ws_op "$"; |
| 76 |
pp_main_post_line = "^" pp_prefix pp_main_post_tag pp_ws_op "$"; |
| 77 |
|
| 78 |
# Global vars |
| 79 |
in_test = needs_line_decl = 0; |
| 80 |
cur_suite = cur_tcase = "Core"; |
| 81 |
cur_test = ""; |
| 82 |
exit_okay = start = 1; |
| 83 |
num_cur_tcases = num_cur_tests = 0; |
| 84 |
test_type = num_tests = 0; |
| 85 |
arg1 = 0; |
| 86 |
arg2 = 1; |
| 87 |
arg3 = 2; |
| 88 |
test_name = 0; |
| 89 |
test_type_flag = 1; |
| 90 |
} |
| 91 |
|
| 92 |
# Run on the first line of the input file. |
| 93 |
start { |
| 94 |
print_boilerplate(); |
| 95 |
start = 0; |
| 96 |
} |
| 97 |
|
| 98 |
# (Executed every line:) |
| 99 |
{ |
| 100 |
print_line = 1; |
| 101 |
} |
| 102 |
|
| 103 |
$0 ~ pp_suite_or_tcase_line { |
| 104 |
if (in_main()) |
| 105 |
in_main_error(); |
| 106 |
|
| 107 |
# Skip to the start of the tag ("suite" or "tcase"). |
| 108 |
match($0, pp_prefix); |
| 109 |
rol = substr($0, RLENGTH+1); |
| 110 |
|
| 111 |
# Save away the tag. |
| 112 |
match(rol, "^" pp_tag); |
| 113 |
tag = substr(rol, 1, RLENGTH); |
| 114 |
|
| 115 |
# Advance past the ws following tag. |
| 116 |
rol = substr(rol, RLENGTH+1); |
| 117 |
match(rol, pp_ws); |
| 118 |
rol = substr(rol, RLENGTH+1); |
| 119 |
|
| 120 |
# The suite or tcase name is the rest of the line, minus any |
| 121 |
# trailing ws. |
| 122 |
if (match(rol, pp_ws "$")) { |
| 123 |
name = substr(rol, 1, RSTART-1); |
| 124 |
} else { |
| 125 |
name = rol; |
| 126 |
} |
| 127 |
|
| 128 |
if (tolower(tag) == "suite") { |
| 129 |
# Does this suite already exist? |
| 130 |
if ((name, 0) in suite_tcase_map) { |
| 131 |
error_with_line("Suite \"" name "\" already exists."); |
| 132 |
} |
| 133 |
cur_suite = name; |
| 134 |
num_cur_tcases = 0; |
| 135 |
} |
| 136 |
else if ((name, 0, 0) in tcase_test_map) { |
| 137 |
error_with_line("Test Case \"" name "\" already exists."); |
| 138 |
} |
| 139 |
cur_tcase = name; |
| 140 |
num_cur_tests = 0; |
| 141 |
|
| 142 |
finish_test(); |
| 143 |
print_line = 0; |
| 144 |
if (!clean_mode) |
| 145 |
needs_line_decl = 1; |
| 146 |
} |
| 147 |
|
| 148 |
$0 ~ pp_test_line { |
| 149 |
|
| 150 |
# Pre checks |
| 151 |
test_pre(); |
| 152 |
|
| 153 |
# Get the test name |
| 154 |
match($0, pp_test_line_prefix) |
| 155 |
cur_test = substr($0, RLENGTH+1); |
| 156 |
|
| 157 |
# Remove trailing ws. |
| 158 |
sub(pp_ws_op "$", "", cur_test); |
| 159 |
|
| 160 |
# Check for duplicate tests / cases and valid names |
| 161 |
duplicate_check(); |
| 162 |
|
| 163 |
# Boilerplate printing code |
| 164 |
test_post(); |
| 165 |
|
| 166 |
# Set type before calling register |
| 167 |
test_type = 0; |
| 168 |
register_test(); |
| 169 |
|
| 170 |
print_line = 0; |
| 171 |
in_test = 1; |
| 172 |
} |
| 173 |
|
| 174 |
$0 ~ pp_test_loop_line { |
| 175 |
|
| 176 |
test_pre(); |
| 177 |
|
| 178 |
match($0, pp_test_loop_line_prefix) |
| 179 |
cur_test = substr($0, RLENGTH+1); |
| 180 |
sub(pp_ws_op "$", "", cur_test); |
| 181 |
|
| 182 |
duplicate_check(); |
| 183 |
|
| 184 |
# Split the line into an array to extract the arguments |
| 185 |
split($0, arr, pp_ws_op "[(),]" pp_ws_op); |
| 186 |
|
| 187 |
# Eliminate possible whitespace between sign and numbers |
| 188 |
gsub(pp_ws_op, "", arr[2]); |
| 189 |
gsub(pp_ws_op, "", arr[3]); |
| 190 |
|
| 191 |
test_post(); |
| 192 |
|
| 193 |
test_type = 1; |
| 194 |
register_test(); |
| 195 |
|
| 196 |
print_line = 0; |
| 197 |
in_test = 1; |
| 198 |
} |
| 199 |
|
| 200 |
$0 ~ pp_test_exit_line { |
| 201 |
|
| 202 |
test_pre(); |
| 203 |
|
| 204 |
match($0, pp_test_exit_line_prefix) |
| 205 |
cur_test = substr($0, RLENGTH+1); |
| 206 |
sub(pp_ws_op "$", "", cur_test); |
| 207 |
|
| 208 |
duplicate_check(); |
| 209 |
|
| 210 |
split($0, arr, pp_ws_op "[(),]" pp_ws_op); |
| 211 |
gsub(pp_ws_op, "", arr[2]); |
| 212 |
|
| 213 |
test_post(); |
| 214 |
|
| 215 |
test_type = 2; |
| 216 |
register_test(); |
| 217 |
|
| 218 |
print_line = 0; |
| 219 |
in_test = 1; |
| 220 |
} |
| 221 |
|
| 222 |
$0 ~ pp_test_signal_line { |
| 223 |
|
| 224 |
test_pre(); |
| 225 |
|
| 226 |
match($0, pp_test_signal_line_prefix) |
| 227 |
cur_test = substr($0, RLENGTH+1); |
| 228 |
sub(pp_ws_op "$", "", cur_test); |
| 229 |
|
| 230 |
duplicate_check(); |
| 231 |
|
| 232 |
split($0, arr, pp_ws_op "[(),]" pp_ws_op); |
| 233 |
gsub(pp_ws_op, "", arr[2]); |
| 234 |
|
| 235 |
test_post(); |
| 236 |
|
| 237 |
test_type = 3; |
| 238 |
register_test(); |
| 239 |
|
| 240 |
print_line = 0; |
| 241 |
in_test = 1; |
| 242 |
} |
| 243 |
|
| 244 |
$0 ~ pp_test_loop_exit_line { |
| 245 |
|
| 246 |
test_pre(); |
| 247 |
|
| 248 |
match($0, pp_test_loop_exit_line_prefix) |
| 249 |
cur_test = substr($0, RLENGTH+1); |
| 250 |
sub(pp_ws_op "$", "", cur_test); |
| 251 |
|
| 252 |
duplicate_check(); |
| 253 |
|
| 254 |
split($0, arr, pp_ws_op "[(),]" pp_ws_op); |
| 255 |
gsub(pp_ws_op, "", arr[2]); |
| 256 |
gsub(pp_ws_op, "", arr[3]); |
| 257 |
gsub(pp_ws_op, "", arr[4]); |
| 258 |
|
| 259 |
test_post(); |
| 260 |
|
| 261 |
test_type = 4; |
| 262 |
register_test(); |
| 263 |
|
| 264 |
print_line = 0; |
| 265 |
in_test = 1; |
| 266 |
} |
| 267 |
|
| 268 |
$0 ~ pp_test_loop_signal_line { |
| 269 |
|
| 270 |
test_pre(); |
| 271 |
|
| 272 |
match($0, pp_test_loop_signal_line_prefix) |
| 273 |
cur_test = substr($0, RLENGTH+1); |
| 274 |
sub(pp_ws_op "$", "", cur_test); |
| 275 |
|
| 276 |
duplicate_check(); |
| 277 |
|
| 278 |
split($0, arr, pp_ws_op "[(),]" pp_ws_op); |
| 279 |
gsub(pp_ws_op, "", arr[2]); |
| 280 |
gsub(pp_ws_op, "", arr[3]); |
| 281 |
gsub(pp_ws_op, "", arr[4]); |
| 282 |
|
| 283 |
test_post(); |
| 284 |
|
| 285 |
test_type = 5; |
| 286 |
register_test(); |
| 287 |
|
| 288 |
print_line = 0; |
| 289 |
in_test = 1; |
| 290 |
} |
| 291 |
|
| 292 |
$0 ~ pp_main_pre_line { |
| 293 |
main_pre(); |
| 294 |
|
| 295 |
print ""; |
| 296 |
print " /* User-specified pre-run code */"; |
| 297 |
|
| 298 |
if (!clean_mode) |
| 299 |
needs_line_decl = 1; |
| 300 |
print_line = 0; |
| 301 |
} |
| 302 |
|
| 303 |
$0 ~ pp_main_post_line { |
| 304 |
main_post(); |
| 305 |
|
| 306 |
print ""; |
| 307 |
print " /* User-specified post-run code */"; |
| 308 |
|
| 309 |
if (!clean_mode) |
| 310 |
needs_line_decl = 1; |
| 311 |
print_line = 0; |
| 312 |
} |
| 313 |
|
| 314 |
print_line { |
| 315 |
if (/[^ \t\f\v\r\n]/ && needs_line_decl && !clean_mode) { |
| 316 |
print "#line " FNR; |
| 317 |
needs_line_decl = 0; |
| 318 |
} |
| 319 |
print; |
| 320 |
} |
| 321 |
|
| 322 |
END { |
| 323 |
if (!exit_okay) { |
| 324 |
# We're exiting due to an error. Don't do anything else. |
| 325 |
} |
| 326 |
else if (num_tests) { |
| 327 |
if (!main_post_done) { |
| 328 |
main_post(); |
| 329 |
print ""; |
| 330 |
print " return nf == 0 ? 0 : 1;"; |
| 331 |
} |
| 332 |
print "}"; |
| 333 |
} |
| 334 |
else { |
| 335 |
error("Expected at least one #test line."); |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
### Functions ### |
| 340 |
|
| 341 |
function test_pre() |
| 342 |
{ |
| 343 |
if (in_main()) |
| 344 |
in_main_error(); |
| 345 |
|
| 346 |
if (in_test) { |
| 347 |
finish_test(); |
| 348 |
print ""; |
| 349 |
} |
| 350 |
++num_tests; |
| 351 |
} |
| 352 |
|
| 353 |
function duplicate_check() |
| 354 |
{ |
| 355 |
# Confirm that the test name is a valid C identifier. |
| 356 |
if (!match(cur_test, "^" pp_test_name "$")) { |
| 357 |
error_with_line("Malformed test name \"" cur_test \ |
| 358 |
"\" (must be a C identifier)."); |
| 359 |
} |
| 360 |
|
| 361 |
# Verify that it has not already been used. |
| 362 |
if (cur_test in test_registry) { |
| 363 |
error_with_line("Test \"" cur_test "\" already exists."); |
| 364 |
} |
| 365 |
|
| 366 |
# Verify that any implied test case is not a repeat. |
| 367 |
if (num_cur_tests == 0 && (cur_tcase, 0, 0) in tcase_test_map) { |
| 368 |
error_with_line("Test Case \"" name "\" already exists."); |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
function test_post() |
| 373 |
{ |
| 374 |
print "START_TEST(" cur_test ")"; |
| 375 |
print "{"; |
| 376 |
if (!clean_mode) |
| 377 |
print "#line " FNR+1; |
| 378 |
|
| 379 |
needs_line_decl = 0; |
| 380 |
} |
| 381 |
|
| 382 |
function main_post() |
| 383 |
{ |
| 384 |
if (main_post_done) |
| 385 |
error_with_line("main-post specified multiple times."); |
| 386 |
if (!main_pre_done) |
| 387 |
main_pre(); |
| 388 |
main_post_done = 1; |
| 389 |
|
| 390 |
print ""; |
| 391 |
|
| 392 |
print_runner_bindings(); |
| 393 |
|
| 394 |
print ""; |
| 395 |
print " srunner_run_all(sr, CK_ENV);"; |
| 396 |
print " nf = srunner_ntests_failed(sr);"; |
| 397 |
print " srunner_free(sr);"; |
| 398 |
} |
| 399 |
|
| 400 |
function in_main() |
| 401 |
{ |
| 402 |
return main_pre_done || main_post_done; |
| 403 |
} |
| 404 |
|
| 405 |
function in_main_error() |
| 406 |
{ |
| 407 |
error_with_line("Cannot specify tests after main-pre or main-post."); |
| 408 |
} |
| 409 |
|
| 410 |
function main_pre() |
| 411 |
{ |
| 412 |
if (main_post_done) |
| 413 |
error_with_line("main-pre specified after main-post."); |
| 414 |
if (main_pre_done) |
| 415 |
error_with_line("main-pre specified multiple times."); |
| 416 |
main_pre_done = 1; |
| 417 |
finish_test(); |
| 418 |
print ""; |
| 419 |
print "int main(void)"; |
| 420 |
print "{"; |
| 421 |
|
| 422 |
print_main_declarations(); |
| 423 |
} |
| 424 |
|
| 425 |
function suite_var_name(num) |
| 426 |
{ |
| 427 |
return "s" num+1; |
| 428 |
} |
| 429 |
|
| 430 |
function tcase_var_name(snum, tcnum) |
| 431 |
{ |
| 432 |
return "tc" snum+1 "_" tcnum+1; |
| 433 |
} |
| 434 |
|
| 435 |
function print_main_declarations() |
| 436 |
{ |
| 437 |
for (i=0; i != num_suites; ++i) { |
| 438 |
s = suite_names[i]; |
| 439 |
svar = suite_var_name(i); |
| 440 |
print " Suite *" svar " = suite_create(" string_encode(s) ");"; |
| 441 |
for (j=0; j != suite_num_tcases[s]; ++j) { |
| 442 |
tc = suite_tcase_map[s, j]; |
| 443 |
tcvar = tcase_var_name(i, j); |
| 444 |
print " TCase *" tcvar " = tcase_create(" \ |
| 445 |
string_encode(tc) ");"; |
| 446 |
} |
| 447 |
} |
| 448 |
print " SRunner *sr = srunner_create(s1);"; |
| 449 |
print " int nf;"; |
| 450 |
} |
| 451 |
|
| 452 |
function string_encode(raw) |
| 453 |
{ |
| 454 |
# The next line might look funny, but remember that the first |
| 455 |
# argument will go through both string interpolation /and/ regex |
| 456 |
# interpolation, so the backslashes must be double-escaped. The |
| 457 |
# substitution string is supposed to result in an actual |
| 458 |
# double-backslash. |
| 459 |
gsub("\\\\", "", raw); |
| 460 |
gsub("\"", "\\\"", raw); |
| 461 |
return "\"" raw "\""; |
| 462 |
} |
| 463 |
|
| 464 |
function print_runner_bindings() |
| 465 |
{ |
| 466 |
for (i=0; i != num_suites; ++i) { |
| 467 |
s = suite_names[i]; |
| 468 |
svar = suite_var_name(i); |
| 469 |
for (j=0; j != suite_num_tcases[s]; ++j) { |
| 470 |
tc = suite_tcase_map[s, j]; |
| 471 |
tcvar = tcase_var_name(i, j); |
| 472 |
print " suite_add_tcase(" svar ", " tcvar ");"; |
| 473 |
for (k=0; k != tcase_num_tests[tc]; ++k) { |
| 474 |
t = tcase_test_map[tc, k, test_name]; |
| 475 |
test_type = tcase_test_map[tc, k, test_type_flag]; |
| 476 |
if (test_type == 0) { |
| 477 |
print " tcase_add_test(" tcvar ", " t ");"; |
| 478 |
} |
| 479 |
else if (test_type == 1) { |
| 480 |
print " tcase_add_loop_test(" tcvar ", " t ", " \ |
| 481 |
test_parameters[t, arg1] ", " test_parameters[t, arg2] \ |
| 482 |
");"; |
| 483 |
} |
| 484 |
else if (test_type == 2) { |
| 485 |
print " tcase_add_exit_test(" tcvar ", " t ", " \ |
| 486 |
test_parameters[t, arg1] ");"; |
| 487 |
} |
| 488 |
else if (test_type == 3) { |
| 489 |
print " tcase_add_test_raise_signal(" tcvar ", " t ", " \ |
| 490 |
test_parameters[t, arg1] ");"; |
| 491 |
} |
| 492 |
else if (test_type == 4) { |
| 493 |
print " tcase_add_loop_exit_test(" tcvar ", " t ", " \ |
| 494 |
test_parameters[t, arg1] ", " test_parameters[t, arg2] \ |
| 495 |
", " test_parameters[t, arg3] ");"; |
| 496 |
} |
| 497 |
else if (test_type == 5) { |
| 498 |
print " tcase_add_loop_test_raise_signal(" tcvar ", " t \ |
| 499 |
", " test_parameters[t, arg1] ", " test_parameters[t, arg2] \ |
| 500 |
", " test_parameters[t, arg3] ");"; |
| 501 |
} |
| 502 |
} |
| 503 |
} |
| 504 |
} |
| 505 |
if (num_suites > 1) { |
| 506 |
print ""; |
| 507 |
for (i=1; i != num_suites; ++i) { |
| 508 |
svar = suite_var_name(i); |
| 509 |
print " srunner_add_suite(sr, " svar ");"; |
| 510 |
} |
| 511 |
} |
| 512 |
} |
| 513 |
|
| 514 |
function register_test() |
| 515 |
{ |
| 516 |
if (num_cur_tcases == 0) { |
| 517 |
suite_names[num_suites++] = cur_suite; |
| 518 |
} |
| 519 |
if (num_cur_tests == 0) { |
| 520 |
suite_tcase_map[cur_suite, num_cur_tcases++] = cur_tcase; |
| 521 |
suite_num_tcases[cur_suite] = num_cur_tcases; |
| 522 |
} |
| 523 |
tcase_test_map[cur_tcase, num_cur_tests, test_name] = cur_test; |
| 524 |
tcase_test_map[cur_tcase, num_cur_tests++, test_type_flag] = test_type; |
| 525 |
tcase_num_tests[cur_tcase] = num_cur_tests; |
| 526 |
test_registry[cur_test] = 1; |
| 527 |
|
| 528 |
# Store arguments to array |
| 529 |
test_parameters[cur_test, arg1] = arr[2]; |
| 530 |
test_parameters[cur_test, arg2] = arr[3]; |
| 531 |
test_parameters[cur_test, arg3] = arr[4]; |
| 532 |
} |
| 533 |
|
| 534 |
function finish_test() |
| 535 |
{ |
| 536 |
if (in_test) { |
| 537 |
in_test = 0; |
| 538 |
print "}"; |
| 539 |
print "END_TEST"; |
| 540 |
} |
| 541 |
} |
| 542 |
|
| 543 |
function print_boilerplate() |
| 544 |
{ |
| 545 |
print "/*"; |
| 546 |
print " * DO NOT EDIT THIS FILE. Generated by " progname "."; |
| 547 |
if (!FILENAME || FILENAME == "-") { |
| 548 |
clean_mode=1; |
| 549 |
is_stdin=1; |
| 550 |
} |
| 551 |
if (is_stdin) |
| 552 |
srcfile = "(standard input)"; |
| 553 |
else |
| 554 |
srcfile = "\"" FILENAME "\""; |
| 555 |
print " * Edit the original source file " srcfile " instead."; |
| 556 |
print " */"; |
| 557 |
print ""; |
| 558 |
print "#include <check.h>"; |
| 559 |
print ""; |
| 560 |
if (!clean_mode) |
| 561 |
print "#line 1 " string_encode(FILENAME) |
| 562 |
} |
| 563 |
|
| 564 |
function error_with_line(err) |
| 565 |
{ |
| 566 |
error((is_stdin ? "(standard input)" : FILENAME) " line " FNR ": " err); |
| 567 |
} |
| 568 |
|
| 569 |
function error(err) |
| 570 |
{ |
| 571 |
print progname ": " err > "/dev/stderr"; |
| 572 |
exit_okay = 0; |
| 573 |
exit 1; |
| 574 |
} |