From: brarcher Date: Wed, 18 Dec 2013 19:46:52 +0000 (+0000) Subject: checkmk: tcase_add_loop_test support in checkmk X-Git-Tag: 0.10.0~318 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e48bc8ae1e3e8125ef58bef513dee55cf03d59b0;p=check checkmk: tcase_add_loop_test support in checkmk git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@898 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/AUTHORS b/AUTHORS index eb928af..66c1658 100644 --- a/AUTHORS +++ b/AUTHORS @@ -43,6 +43,7 @@ Contributors: bross (patches for msys/mingw32 support) Pino Toscano (GNU/Hurd support for subsecond timeouts) lod (compiler warning) + Bill Kolokithas (more checkmk directives) Anybody who has contributed code to Check or Check's build system is considered an author. Send patches to this file to diff --git a/checkmk/checkmk.in b/checkmk/checkmk.in index 2df778c..b6d29d6 100644 --- a/checkmk/checkmk.in +++ b/checkmk/checkmk.in @@ -24,36 +24,64 @@ BEGIN { outfname="/dev/stdout"; # Tokens - pp_ws = "[ \t\f\v\r\n]+"; - pp_ws_op = "[ \t\f\v\r\n]*"; - pp_prefix = pp_ws_op "#" pp_ws_op; - pp_tag = "([Ss][Uu][Ii][Tt][Ee]|[Tt][Cc][Aa][Ss][Ee])"; - pp_test_tag = "[Tt][Ee][Ss][Tt]"; - pp_main_pre_tag = "[Mm][Aa][Ii][Nn]-[Pp][Rr][Ee]"; + pp_ws = "[ \t\f\v\r\n]+"; + pp_ws_op = "[ \t\f\v\r\n]*"; + pp_prefix = pp_ws_op "#" pp_ws_op; + pp_sep = "[ \t\f\v\r\n]+"; + pp_name = ".+"; + pp_hex_quad = "[A-F0-9a-f][A-F0-9a-f][A-F0-9a-f][A-F0-9a-f]" + pp_ucn = "\\\\(u" pp_hex_quad "|U" pp_hex_quad pp_hex_quad ")"; + pp_test_name = "([A-Za-z_]|" pp_ucn ")([A-Za-z0-9_]|" pp_ucn ")*"; + pp_tag = "([Ss][Uu][Ii][Tt][Ee]|[Tt][Cc][Aa][Ss][Ee])"; + pp_test_tag = "[Tt][Ee][Ss][Tt]"; + pp_main_pre_tag = "[Mm][Aa][Ii][Nn]-[Pp][Rr][Ee]"; pp_main_post_tag = "[Mm][Aa][Ii][Nn]-[Pp][Oo][Ss][Tt]"; - pp_sep = "[ \t\f\v\r\n]+"; - pp_name = ".+"; - pp_hex_quad = "[A-F0-9a-f][A-F0-9a-f][A-F0-9a-f][A-F0-9a-f]" - pp_ucn = "\\\\(u" pp_hex_quad "|U" pp_hex_quad pp_hex_quad ")"; - pp_test_name = "([A-Za-z_]|" pp_ucn ")([A-Za-z0-9_]|" pp_ucn ")*"; + + # Tests with arguments + pp_test_exit_tag = "[Tt][Ee][Ss][Tt]-[Ee][Xx][Ii][Tt][[:blank:]]*[(]" \ + "[[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[)]"; + pp_test_signal_tag = "[Tt][Ee][Ss][Tt]-[Ss][Ii][Gg][Nn][Aa][Ll]" \ + "[[:blank:]]*[(][[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[)]"; + pp_test_loop_tag = "[Tt][Ee][Ss][Tt]-[Ll][Oo][Oo][Pp][[:blank:]]*[(]" \ + "[[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[,][[:blank:]]*" \ + "[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[)]"; + pp_test_loop_exit_tag = "[Tt][Ee][Ss][Tt]-[Ll][Oo][Oo][Pp]-[Ee][Xx][Ii][Tt]" \ + "[[:blank:]]*[(][[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*" \ + "[,][[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[,]" \ + "[[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[)]"; + pp_test_loop_signal_tag = "[Tt][Ee][Ss][Tt]-[Ll][Oo][Oo][Pp]-[Ss][Ii][Gg]" \ + "[Nn][Aa][Ll][[:blank:]]*[(][[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+" \ + "[[:blank:]]*[,][[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*" \ + "[,][[:blank:]]*[+-]?[[:blank:]]*[[:digit:]]+[[:blank:]]*[)]"; pp_suite_or_tcase_line = "^" pp_prefix pp_tag pp_ws pp_name "$"; pp_test_line_prefix = "^" pp_prefix pp_test_tag pp_ws; + pp_test_exit_line_prefix = "^" pp_prefix pp_test_exit_tag pp_ws; + pp_test_signal_line_prefix = "^" pp_prefix pp_test_signal_tag pp_ws; + pp_test_loop_line_prefix = "^" pp_prefix pp_test_loop_tag pp_ws; + pp_test_loop_exit_line_prefix = "^" pp_prefix pp_test_loop_exit_tag pp_ws; + pp_test_loop_signal_line_prefix = "^" pp_prefix pp_test_loop_signal_tag pp_ws; pp_test_line = pp_test_line_prefix pp_name pp_ws_op "$"; + pp_test_exit_line = pp_test_exit_line_prefix pp_name pp_ws_op "$"; + pp_test_signal_line = pp_test_signal_line_prefix pp_name pp_ws_op "$"; + pp_test_loop_line = pp_test_loop_line_prefix pp_name pp_ws_op "$"; + pp_test_loop_exit_line = pp_test_loop_exit_line_prefix pp_name pp_ws_op "$"; + pp_test_loop_signal_line = pp_test_loop_signal_line_prefix pp_name pp_ws_op "$"; pp_main_pre_line = "^" pp_prefix pp_main_pre_tag pp_ws_op "$"; pp_main_post_line = "^" pp_prefix pp_main_post_tag pp_ws_op "$"; # Global vars - num_tests = 0; + in_test = needs_line_decl = 0; cur_suite = cur_tcase = "Core"; cur_test = ""; - in_test = 0; - needs_line_decl = 0; - exit_okay = 1; - - num_cur_tcases = 0; - num_cur_tests = 0; - start = 1; + exit_okay = start = 1; + num_cur_tcases = num_cur_tests = 0; + test_type = num_tests = 0; + arg1 = 0; + arg2 = 1; + arg3 = 2; + test_name = 0; + test_type_flag = 1; } # Run on the first line of the input file. @@ -100,7 +128,7 @@ $0 ~ pp_suite_or_tcase_line { cur_suite = name; num_cur_tcases = 0; } - else if ((name, 0) in tcase_test_map) { + else if ((name, 0, 0) in tcase_test_map) { error_with_line("Test Case \"" name "\" already exists."); } cur_tcase = name; @@ -113,14 +141,9 @@ $0 ~ pp_suite_or_tcase_line { } $0 ~ pp_test_line { - if (in_main()) - in_main_error(); - if (in_test) { - finish_test(); - print ""; - } - ++num_tests; + # Pre checks + test_pre(); # Get the test name match($0, pp_test_line_prefix) @@ -129,29 +152,132 @@ $0 ~ pp_test_line { # Remove trailing ws. sub(pp_ws_op "$", "", cur_test); - # Confirm that the test name is a valid C identifier. - if (!match(cur_test, "^" pp_test_name "$")) { - error_with_line("Malformed test name \"" cur_test \ - "\" (must be a C identifier)."); - } + # Check for duplicate tests / cases and valid names + duplicate_check(); - # Verify that it has not already been used. - if (cur_test in test_registry) { - error_with_line("Test \"" cur_test "\" already exists."); - } + # Boilerplate printing code + test_post(); - # Verify that any implied test case is not a repeat. - if (num_cur_tests == 0 && (cur_tcase, 0) in tcase_test_map) { - error_with_line("Test Case \"" name "\" already exists."); - } + # Set type before calling register + test_type = 0; + register_test(); - # Print preamble - print "START_TEST(" cur_test ")"; - print "{"; - if (!clean_mode) - print "#line " FNR+1; - needs_line_decl = 0; + print_line = 0; + in_test = 1; +} + +$0 ~ pp_test_loop_line { + + test_pre(); + + match($0, pp_test_loop_line_prefix) + cur_test = substr($0, RLENGTH+1); + sub(pp_ws_op "$", "", cur_test); + + duplicate_check(); + + # Split the line into an array to extract the arguments + split($0, arr, /[[:blank:]]*[(),][[:blank:]]*/); + + # Eliminate possible whitespace between sign and numbers + gsub(/[[:space:]]*/, "", arr[2]); + gsub(/[[:space:]]*/, "", arr[3]); + + test_post(); + + test_type = 1; + register_test(); + + print_line = 0; + in_test = 1; +} + +$0 ~ pp_test_exit_line { + + test_pre(); + + match($0, pp_test_exit_line_prefix) + cur_test = substr($0, RLENGTH+1); + sub(pp_ws_op "$", "", cur_test); + + duplicate_check(); + + split($0, arr, /[[:blank:]]*[(),][[:blank:]]*/); + gsub(/[[:space:]]*/, "", arr[2]); + + test_post(); + + test_type = 2; + register_test(); + + print_line = 0; + in_test = 1; +} + +$0 ~ pp_test_signal_line { + + test_pre(); + + match($0, pp_test_signal_line_prefix) + cur_test = substr($0, RLENGTH+1); + sub(pp_ws_op "$", "", cur_test); + + duplicate_check(); + + split($0, arr, /[[:blank:]]*[(),][[:blank:]]*/); + gsub(/[[:space:]]*/, "", arr[2]); + test_post(); + + test_type = 3; + register_test(); + + print_line = 0; + in_test = 1; +} + +$0 ~ pp_test_loop_exit_line { + + test_pre(); + + match($0, pp_test_loop_exit_line_prefix) + cur_test = substr($0, RLENGTH+1); + sub(pp_ws_op "$", "", cur_test); + + duplicate_check(); + + split($0, arr, /[[:blank:]]*[(),][[:blank:]]*/); + gsub(/[[:space:]]*/, "", arr[2]); + gsub(/[[:space:]]*/, "", arr[3]); + gsub(/[[:space:]]*/, "", arr[4]); + + test_post(); + + test_type = 4; + register_test(); + + print_line = 0; + in_test = 1; +} + +$0 ~ pp_test_loop_signal_line { + + test_pre(); + + match($0, pp_test_loop_signal_line_prefix) + cur_test = substr($0, RLENGTH+1); + sub(pp_ws_op "$", "", cur_test); + + duplicate_check(); + + split($0, arr, /[[:blank:]]*[(),][[:blank:]]*/); + gsub(/[[:space:]]*/, "", arr[2]); + gsub(/[[:space:]]*/, "", arr[3]); + gsub(/[[:space:]]*/, "", arr[4]); + + test_post(); + + test_type = 5; register_test(); print_line = 0; @@ -198,7 +324,6 @@ END { print ""; print " return nf == 0 ? 0 : 1;"; } - print "}"; } else { @@ -208,6 +333,47 @@ END { ### Functions ### +function test_pre() +{ + if (in_main()) + in_main_error(); + + if (in_test) { + finish_test(); + print ""; + } + ++num_tests; +} + +function duplicate_check() +{ + # Confirm that the test name is a valid C identifier. + if (!match(cur_test, "^" pp_test_name "$")) { + error_with_line("Malformed test name \"" cur_test \ + "\" (must be a C identifier)."); + } + + # Verify that it has not already been used. + if (cur_test in test_registry) { + error_with_line("Test \"" cur_test "\" already exists."); + } + + # Verify that any implied test case is not a repeat. + if (num_cur_tests == 0 && (cur_tcase, 0, 0) in tcase_test_map) { + error_with_line("Test Case \"" name "\" already exists."); + } +} + +function test_post() +{ + print "START_TEST(" cur_test ")"; + print "{"; + if (!clean_mode) + print "#line " FNR+1; + + needs_line_decl = 0; +} + function main_post() { if (main_post_done) @@ -300,8 +466,34 @@ function print_runner_bindings() tcvar = tcase_var_name(i, j); print " suite_add_tcase(" svar ", " tcvar ");"; for (k=0; k != tcase_num_tests[tc]; ++k) { - t = tcase_test_map[tc, k]; - print " tcase_add_test(" tcvar ", " t ");"; + t = tcase_test_map[tc, k, test_name]; + test_type = tcase_test_map[tc, k, test_type_flag]; + if (test_type == 0) { + print " tcase_add_test(" tcvar ", " t ");"; + } + else if (test_type == 1) { + print " tcase_add_loop_test(" tcvar ", " t ", " \ + test_parameters[t, arg1] ", " test_parameters[t, arg2] \ + ");"; + } + else if (test_type == 2) { + print " tcase_add_exit_test(" tcvar ", " t ", " \ + test_parameters[t, arg1] ");"; + } + else if (test_type == 3) { + print " tcase_add_test_raise_signal(" tcvar ", " t ", " \ + test_parameters[t, arg1] ");"; + } + else if (test_type == 4) { + print " tcase_add_loop_exit_test(" tcvar ", " t ", " \ + test_parameters[t, arg1] ", " test_parameters[t, arg2] \ + ", " test_parameters[t, arg3] ");"; + } + else if (test_type == 5) { + print " tcase_add_loop_test_raise_signal(" tcvar ", " t \ + ", " test_parameters[t, arg1] ", " test_parameters[t, arg2] \ + ", " test_parameters[t, arg3] ");"; + } } } } @@ -323,9 +515,15 @@ function register_test() suite_tcase_map[cur_suite, num_cur_tcases++] = cur_tcase; suite_num_tcases[cur_suite] = num_cur_tcases; } - tcase_test_map[cur_tcase, num_cur_tests++] = cur_test; + tcase_test_map[cur_tcase, num_cur_tests, test_name] = cur_test; + tcase_test_map[cur_tcase, num_cur_tests++, test_type_flag] = test_type; tcase_num_tests[cur_tcase] = num_cur_tests; test_registry[cur_test] = 1; + + # Store arguments to array + test_parameters[cur_test, arg1] = arr[2]; + test_parameters[cur_test, arg2] = arr[3]; + test_parameters[cur_test, arg3] = arr[4]; } function finish_test() diff --git a/checkmk/test/argument_ws/in b/checkmk/test/argument_ws/in new file mode 100644 index 0000000..9dc1572 --- /dev/null +++ b/checkmk/test/argument_ws/in @@ -0,0 +1,84 @@ +#test-exit(0) test1 + ck_assert(0 == 0); + #test-exit (1) test2 + ck_assert(1 == 0); + #test-exit ( 0) test3 + ck_assert(1 == 0); + #test-exit ( +0 ) test4 + ck_assert(1 == 0); + #test-exit ( -1 ) test5 + ck_assert(1 == 0); + #test-exit ( - 1 ) test6 + ck_assert(1 == 0); + #test-exit (- 0 ) test7 + ck_assert(1 == 0); + #test-exit ( + 1 ) test8 + ck_assert(1 == 0); + +#test-signal(0) test9 + ck_assert(0 == 0); + #test-signal (1) test10 + ck_assert(1 == 0); + #test-signal ( 0) test11 + ck_assert(1 == 0); + #test-signal ( +0 ) test12 + ck_assert(1 == 2); + #test-signal ( -1 ) test13 + ck_assert(1 == 0); + #test-signal ( - 1 ) test14 + ck_assert(1 == 0); + #test-signal (- 0 ) test15 + ck_assert(1 == 0); + #test-signal ( + 1 ) test16 + ck_assert(1 == 0); + +#test-loop(0,2) test17 + ck_assert(0 == 0); + #test-loop (1 ,0) test18 + ck_assert(1 == 0); + #test-loop ( 0 , 1) test19 + ck_assert(1 == 1); + #test-loop ( +0 , -2) test20 + ck_assert(1 == 0); + #test-loop ( -1 ,+ 3) test21 + ck_assert(1 == 0); + #test-loop ( - 1, + 2 ) test22 + ck_assert(1 == 0); + #test-loop (- 0 , - 2) test23 + ck_assert(1 == 0); + #test-loop ( + 1 , - 3 ) test24 + ck_assert(1 == 1); + +#test-loop-exit(1,0,2) test25 + ck_assert(0 == 1); + #test-loop-exit ( 2,1 ,0) test26 + ck_assert(1 == 0); + #test-loop-exit ( 2 ,0 , 1) test27 + ck_assert(1 == 0); + #test-loop-exit ( -1 , +0 , -2) test28 + ck_assert(1 == 0); + #test-loop-exit ( - 3 , -1 ,+ 3) test29 + ck_assert(1 == 1); + #test-loop-exit ( + 0, - 1, + 2 ) test30 + ck_assert(1 == 0); + #test-loop-exit (- 4 ,- 0 , - 2) test31 + ck_assert(1 == 0); + #test-loop-exit ( +2 , + 1 , - 3 ) test32 + ck_assert(1 == 0); + +#test-loop-signal(1,0,2) test33 + ck_assert(0 == 0); + #test-loop-signal ( 2,1 ,0) test34 + ck_assert(1 == 0); + #test-loop-signal ( 2 ,0 , 1) test35 + ck_assert(1 == 1); + #test-loop-signal ( -1 , +0 , -2) test36 + ck_assert(1 == 0); + #test-loop-signal ( - 3 , -1 ,+ 3) test37 + ck_assert(1 == 0); + #test-loop-signal ( + 0, - 1, + 2 ) test38 + ck_assert(1 == 0); + #test-loop-signal (- 4 ,- 0 , - 2) test39 + ck_assert(1 == 0); + #test-loop-signal ( +2 , + 1 , - 3 ) test40 + ck_assert(1 == 1); \ No newline at end of file diff --git a/checkmk/test/argument_ws/x_output b/checkmk/test/argument_ws/x_output new file mode 100644 index 0000000..59d5556 --- /dev/null +++ b/checkmk/test/argument_ws/x_output @@ -0,0 +1,347 @@ +/* + * DO NOT EDIT THIS FILE. Generated by checkmk. + * Edit the original source file "in" instead. + */ + +#include + +#line 1 "in" +START_TEST(test1) +{ +#line 2 + ck_assert(0 == 0); +} +END_TEST + +START_TEST(test2) +{ +#line 4 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test3) +{ +#line 6 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test4) +{ +#line 8 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test5) +{ +#line 10 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test6) +{ +#line 12 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test7) +{ +#line 14 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test8) +{ +#line 16 + ck_assert(1 == 0); + +} +END_TEST + +START_TEST(test9) +{ +#line 19 + ck_assert(0 == 0); +} +END_TEST + +START_TEST(test10) +{ +#line 21 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test11) +{ +#line 23 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test12) +{ +#line 25 + ck_assert(1 == 2); +} +END_TEST + +START_TEST(test13) +{ +#line 27 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test14) +{ +#line 29 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test15) +{ +#line 31 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test16) +{ +#line 33 + ck_assert(1 == 0); + +} +END_TEST + +START_TEST(test17) +{ +#line 36 + ck_assert(0 == 0); +} +END_TEST + +START_TEST(test18) +{ +#line 38 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test19) +{ +#line 40 + ck_assert(1 == 1); +} +END_TEST + +START_TEST(test20) +{ +#line 42 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test21) +{ +#line 44 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test22) +{ +#line 46 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test23) +{ +#line 48 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test24) +{ +#line 50 + ck_assert(1 == 1); + +} +END_TEST + +START_TEST(test25) +{ +#line 53 + ck_assert(0 == 1); +} +END_TEST + +START_TEST(test26) +{ +#line 55 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test27) +{ +#line 57 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test28) +{ +#line 59 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test29) +{ +#line 61 + ck_assert(1 == 1); +} +END_TEST + +START_TEST(test30) +{ +#line 63 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test31) +{ +#line 65 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test32) +{ +#line 67 + ck_assert(1 == 0); + +} +END_TEST + +START_TEST(test33) +{ +#line 70 + ck_assert(0 == 0); +} +END_TEST + +START_TEST(test34) +{ +#line 72 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test35) +{ +#line 74 + ck_assert(1 == 1); +} +END_TEST + +START_TEST(test36) +{ +#line 76 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test37) +{ +#line 78 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test38) +{ +#line 80 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test39) +{ +#line 82 + ck_assert(1 == 0); +} +END_TEST + +START_TEST(test40) +{ +#line 84 + ck_assert(1 == 1); +} +END_TEST + +int main(void) +{ + Suite *s1 = suite_create("Core"); + TCase *tc1_1 = tcase_create("Core"); + SRunner *sr = srunner_create(s1); + int nf; + + suite_add_tcase(s1, tc1_1); + tcase_add_exit_test(tc1_1, test1, 0); + tcase_add_exit_test(tc1_1, test2, 1); + tcase_add_exit_test(tc1_1, test3, 0); + tcase_add_exit_test(tc1_1, test4, +0); + tcase_add_exit_test(tc1_1, test5, -1); + tcase_add_exit_test(tc1_1, test6, -1); + tcase_add_exit_test(tc1_1, test7, -0); + tcase_add_exit_test(tc1_1, test8, +1); + tcase_add_test_raise_signal(tc1_1, test9, 0); + tcase_add_test_raise_signal(tc1_1, test10, 1); + tcase_add_test_raise_signal(tc1_1, test11, 0); + tcase_add_test_raise_signal(tc1_1, test12, +0); + tcase_add_test_raise_signal(tc1_1, test13, -1); + tcase_add_test_raise_signal(tc1_1, test14, -1); + tcase_add_test_raise_signal(tc1_1, test15, -0); + tcase_add_test_raise_signal(tc1_1, test16, +1); + tcase_add_loop_test(tc1_1, test17, 0, 2); + tcase_add_loop_test(tc1_1, test18, 1, 0); + tcase_add_loop_test(tc1_1, test19, 0, 1); + tcase_add_loop_test(tc1_1, test20, +0, -2); + tcase_add_loop_test(tc1_1, test21, -1, +3); + tcase_add_loop_test(tc1_1, test22, -1, +2); + tcase_add_loop_test(tc1_1, test23, -0, -2); + tcase_add_loop_test(tc1_1, test24, +1, -3); + tcase_add_loop_exit_test(tc1_1, test25, 1, 0, 2); + tcase_add_loop_exit_test(tc1_1, test26, 2, 1, 0); + tcase_add_loop_exit_test(tc1_1, test27, 2, 0, 1); + tcase_add_loop_exit_test(tc1_1, test28, -1, +0, -2); + tcase_add_loop_exit_test(tc1_1, test29, -3, -1, +3); + tcase_add_loop_exit_test(tc1_1, test30, +0, -1, +2); + tcase_add_loop_exit_test(tc1_1, test31, -4, -0, -2); + tcase_add_loop_exit_test(tc1_1, test32, +2, +1, -3); + tcase_add_loop_test_raise_signal(tc1_1, test33, 1, 0, 2); + tcase_add_loop_test_raise_signal(tc1_1, test34, 2, 1, 0); + tcase_add_loop_test_raise_signal(tc1_1, test35, 2, 0, 1); + tcase_add_loop_test_raise_signal(tc1_1, test36, -1, +0, -2); + tcase_add_loop_test_raise_signal(tc1_1, test37, -3, -1, +3); + tcase_add_loop_test_raise_signal(tc1_1, test38, +0, -1, +2); + tcase_add_loop_test_raise_signal(tc1_1, test39, -4, -0, -2); + tcase_add_loop_test_raise_signal(tc1_1, test40, +2, +1, -3); + + srunner_run_all(sr, CK_ENV); + nf = srunner_ntests_failed(sr); + srunner_free(sr); + + return nf == 0 ? 0 : 1; +} diff --git a/checkmk/test/check_checkmk b/checkmk/test/check_checkmk index 8ebcb31..f591a18 100755 --- a/checkmk/test/check_checkmk +++ b/checkmk/test/check_checkmk @@ -13,7 +13,7 @@ TEST_DIRS="$TEST_DIRS test_chars num_start_test_name" TEST_DIRS="$TEST_DIRS no_args clean_mode declarations test_after_main_pre" TEST_DIRS="$TEST_DIRS main_pre_multiple main_post main_pre_after_post" TEST_DIRS="$TEST_DIRS test_after_main_post main_post_multiple ucn" -TEST_DIRS="$TEST_DIRS invalid_ucn" +TEST_DIRS="$TEST_DIRS invalid_ucn argument_ws repeated_argument_tests" check_dir() { status=0 diff --git a/checkmk/test/repeated_argument_tests/in b/checkmk/test/repeated_argument_tests/in new file mode 100644 index 0000000..07947d4 --- /dev/null +++ b/checkmk/test/repeated_argument_tests/in @@ -0,0 +1,10 @@ +/* Fail when tests with identical name are detected */ + +#test-loop(1,4) test1 + ck_assert(1 == 1); +#test-signal(-1) test2 + ck_assert(1 == 1); +#suite secondary +#tcase second +#test-loop-exit(1, 1, 5) test2 + ck_assert(1 == 1); diff --git a/checkmk/test/repeated_argument_tests/x_err b/checkmk/test/repeated_argument_tests/x_err new file mode 100644 index 0000000..8f642cb --- /dev/null +++ b/checkmk/test/repeated_argument_tests/x_err @@ -0,0 +1 @@ +checkmk: in line 9: Test "test2" already exists. diff --git a/checkmk/test/repeated_argument_tests/x_output b/checkmk/test/repeated_argument_tests/x_output new file mode 100644 index 0000000..671308c --- /dev/null +++ b/checkmk/test/repeated_argument_tests/x_output @@ -0,0 +1,23 @@ +/* + * DO NOT EDIT THIS FILE. Generated by checkmk. + * Edit the original source file "in" instead. + */ + +#include + +#line 1 "in" +/* Fail when tests with identical name are detected */ + +START_TEST(test1) +{ +#line 4 + ck_assert(1 == 1); +} +END_TEST + +START_TEST(test2) +{ +#line 6 + ck_assert(1 == 1); +} +END_TEST