Lines Matching +full:test +full:- +full:config
4 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2018-2025 Gavin D. Howard and contributors.
37 SAFE_INSTALL: str = path.join(src_dir, "scripts/safe-install.sh");
40 EXEC_INSTALL_MODE: str = "-Dm755";
44 MANPAGE_INSTALL_MODE: str = "-Dm644";
49 DESTDIR: str = str(config["destdir"]);
51 EXECPREFIX: str = str(config["execprefix"]);
52 EXECSUFFIX: str = str(config["execsuffix"]);
60 fn exe_name(name: str) -> str
72 fn default_exe_name(name: str) -> str
82 fn lib_name(name: str) -> str
106 fn prompt(name: str) -> str
108 opt: sym = sym(config[name +~ "/default_prompt"]);
117 str(uint(bool(config[name +~ "/default_tty_mode"])));
129 FORCE: bool = bool(config["force"]);
131 BUILD_MODE: sym = sym(config["build_mode"]);
137 EXTRA_MATH_ENABLED: str = str(uint(bool(config["extra_math"])));
139 HISTORY: sym = sym(config["history"]);
151 str(uint(sym(config["locales"]) != @none));
168 OPTIMIZE: str = str(config["optimization"]);
172 "--error-exitcode=100",
173 "--leak-check=full",
174 "--show-leak-kinds=all",
175 "--errors-for-leak-kinds=all",
176 "--track-fds=yes",
177 "--track-origins=yes",
186 // Get the command-line option for defining a preprocessor variable.
189 // Get the command-line string for the optimization option for the compiler.
204 if bool(config["coverage"])
206 @[ "-fprofile-arcs", "-ftest-coverage", "-g", "-O0", DEFOPT +~ "NDEBUG" ];
231 DEFOPT +~ "EXECPREFIX=" +~ str(config["execprefix"]),
232 DEFOPT +~ "BC_NUM_KARATSUBA_LEN=" +~ str(num(config["karatsuba_len"])),
239 DEFOPT +~ "BC_ENABLE_MEMCHECK=" +~ str(uint(bool(config["memcheck"]))),
240 DEFOPT +~ "BC_ENABLE_AFL=" +~ str(uint(bool(config["afl"]))),
241 DEFOPT +~ "BC_ENABLE_OSSFUZZ=" +~ str(uint(bool(config["ossfuzz"]))),
243 str(uint(bool(config["bc/default_banner"]))),
245 str(uint(bool(config["bc/default_sigint_reset"]))),
247 str(uint(bool(config["bc/default_tty_mode"]))),
250 str(uint(bool(config["bc/default_expr_exit"]))),
252 str(uint(bool(config["bc/default_digit_clamp"]))),
254 str(uint(bool(config["dc/default_sigint_reset"]))),
256 str(uint(bool(config["dc/default_tty_mode"]))),
259 str(uint(bool(config["dc/default_expr_exit"]))),
261 str(uint(bool(config["dc/default_digit_clamp"]))),
308 "// Copyright (c) 2018-2025 Gavin D. Howard and contributors.\n" +~
309 "// Licensed under the 2-clause BSD license.\n" +~
361 ) -> void
534 fn c2o(c_file: str) -> str
567 ) -> str
583 str(config["strgen_name"]), str(config["strgen_label"]),
584 str(config["strgen_define"]),
585 bool(config["strgen_remove_tabs"]));
598 fn exe(name: str, o_files: []str) -> void
612 fn ln(name: str, exec: str) -> void
625 $ ln -fs @("./" +~ path.basename(file_dep)) @(tgt);
635 fn lib(name: str, o_files: []str) -> void
645 $ ar -r -cu @(tgt) %(file_deps);
653 ) -> void
657 error("Test \"" +~ name +~ "\" crashed");
662 error("Test \"" +~ name +~ "\" returned no error");
667 error("Test \"" +~ name +~ "\" had memory errors on non-fatal error\n");
672 error("Test \"" +~ name +~ "\" produced no error message");
679 ) -> void
683 error("Test \"" +~ name +~ "\" failed with exitcode: " +~
692 ) -> void
700 error("Test \"" +~ name +~ "\" failed\n" +~ str(res.stderr));
709 ) -> void
730 test sym(path.join(testdir, t)): bin
732 halt: str = str(config["halt"]);
748 if !bool(config["generated_tests"])
750 io.eprint("Skipping test " +~ tgt_name +~ "\n");
797 ) -> void
817 test sym(path.join(scriptdir, t)): bin
819 halt: str = str(config["halt"]);
840 // This particular test needs to be generated straight. Also, on
854 // manual (manuals/development.md#script-tests) for more
857 sed -n -f @(path.join(root_testdir, "script.sed"))
870 res1 := $ %(config_list["args"]) -g
896 ) -> void
898 test sym(path.join(testdir, name)): bin
923 ) -> void
945 ) -> void
977 // First test is the regular read test.
978 test sym(path.join(testdir, "read")): bin
986 read_call: str = str(config["read_call"]);
1005 // Next test is reading multiple times.
1006 test sym(path.join(testdir, "read_multiple")): bin
1014 read_call: str = str(config["read_call"]);
1024 -e $read_call -e $read_call -e $read_call
1025 << @(str(config["read_multiple"]));
1030 // Next test is the read errors test.
1031 test sym(path.join(testdir, "read_errors")): bin
1041 read_call: str = str(config["read_call"]);
1059 // Next test is the empty read test.
1060 test sym(path.join(testdir, "read_empty")): bin
1062 read_call: str = str(config["read_call"]);
1070 // Next test is the read EOF test.
1071 test sym(path.join(testdir, "read_EOF")): bin
1073 read_call: str = str(config["read_call"]);
1083 fn run_error_lines_test(name: str) -> void
1107 ) -> void
1111 // First test is command-line expression error.
1112 test sym(path.join(testdir, "command-line_expr_error")): bin
1114 halt: str = str(config["halt"]);
1116 res := $ %(config_list["args"]) %(config_list["options"]) -e "1+1" -f-
1117 -e "2+2" << $halt;
1122 // First test is command-line file expression error.
1123 test sym(path.join(testdir, "command-line_file_expr_error")): bin
1126 halt: str = str(config["halt"]);
1128 res := $ %(config_list["args"]) %(config_list["options"]) -e "1+1" -f-
1129 -f @(path.join(testdir, "decimal.txt")) << $halt;
1136 test sym(path.join(testdir, "posix_warning")): bin
1138 res := $ %(config_list["args"]) %(config_list["options"]) -w
1143 error("Test \"" +~ tgt_name +~ "\" returned an error (" +~
1151 error("Test \"" +~ tgt_name +~ "\" did not print a warning");
1155 test sym(path.join(testdir, "posix_errors.txt")): bin
1161 test sym(path.join(testdir, "errors.txt")): bin
1170 // Skip the problematic test, if requested.
1172 !bool(config["problematic_tests"])
1177 test sym(f): bin
1183 halt: str = str(config["halt"]);
1185 res1 := $ %(config_list["args"]) %(config_list["error_options"]) -c
1190 res2 := $ %(config_list["args"]) %(config_list["error_options"]) -C
1195 res3 := $ %(config_list["args"]) %(config_list["error_options"]) -c
1200 res4 := $ %(config_list["args"]) %(config_list["error_options"]) -C
1211 ) -> void
1228 ) -> void
1234 // Halt test.
1235 test sym(path.join(testdir, "halt")): bin
1237 halt: str = str(config["halt"]) +~ "\n";
1246 // bc has two halt or quit commands, so test the second as well.
1247 test sym(path.join(testdir, "quit")): bin
1255 test sym(path.join(testdir, "quit_after_expr")): bin
1257 res := $ %(config_list["args"]) -e "1+1" << @("quit\n");
1263 error("Test \"" +~ tgt_name +~
1268 test sym(path.join(testdir, "env_args1")): bin
1270 env.set env.str("BC_ENV_ARGS", " '-l' '' -q")
1278 test sym(path.join(testdir, "env_args2")): bin
1280 env.set env.str("BC_ENV_ARGS", " '-l' '' -q")
1282 res := $ %(config_list["args"]) -e 4 << @("halt\n");
1295 test sym(path.join(testdir, "keyword_redefinition1")): bin
1297 res := $ %(config_list["args"]) --redefine=print -e
1298 "define print(x) { x }" -e "print(5)" << @("halt\n");
1303 test sym(path.join(testdir, "keyword_redefinition2")): bin
1305 res := $ %(config_list["args"]) -r abs -r else -e
1306 "abs = 5; else = 0" -e "abs;else" << @("halt\n");
1313 test sym(path.join(testdir, "keyword_redefinition_lib2")): bin
1315 res := $ %(config_list["args"]) -lr abs -e "perm(5, 1)" -e 0
1321 test sym(path.join(testdir, "leading_zero_script")): bin
1326 res := $ %(config_list["args"]) -lz
1328 << @(str(config["halt"]));
1335 test sym(path.join(testdir, "keyword_redefinition3")): bin
1337 res := $ %(config_list["args"]) -r abs -r else -e
1338 "abs = 5; else = 0" -e "abs;else" << @("halt\n");
1343 test sym(path.join(testdir, "keyword_redefinition_error")): bin
1345 res := $ %(config_list["args"]) -r break -e "define break(x) { x }";
1350 test sym(path.join(testdir,
1353 res := $ %(config_list["args"]) -e "define read(x) { x }";
1358 test sym(path.join(testdir, "multiline_comment_in_expr_file")): bin
1368 res := $ %(config_list["args"]) -f $src_test_file << @("halt\n");
1373 test sym(path.join(testdir,
1381 res := $ %(config_list["args"]) -f $src_test_file << @("halt\n");
1386 test sym(path.join(testdir, "multiline_string_in_expr_file")): bin
1396 res := $ %(config_list["args"]) -f $src_test_file << @("halt\n");
1404 test sym(tst): bin
1411 res := $ %(config_list["args"]) -f $src_test_file << @("halt\n");
1418 test sym(tst2): bin
1425 res := $ %(config_list["args"]) -f $src_test_file << @("halt\n");
1430 test sym(path.join(testdir, "interactive_halt")): bin
1432 res := $ %(config_list["args"]) -i << @("halt\n");
1439 test sym(path.join(testdir, "env_args1")): bin
1441 env.set env.str("DC_ENV_ARGS", "'-x'"), env.str("DC_EXPR_EXIT", "1")
1449 test sym(path.join(testdir, "env_args2")): bin
1451 env.set env.str("DC_ENV_ARGS", "'-x'"), env.str("DC_EXPR_EXIT", "1")
1453 res := $ %(config_list["args"]) -e 4pR;
1459 test sym(path.join(testdir, "extended_register_command1")): bin
1471 res := $ %(config_list["args"]) -e gxpR << @("q\n");
1476 test sym(path.join(testdir, "extended_register_command2")): bin
1488 res := $ %(config_list["args"]) -x -e gxpR << @("q\n");
1508 test sym(path.join(testdir, "line_length1")): bin
1510 env.set env.str(str(config["var"]), "80")
1523 test sym(path.join(testdir, "line_length2")): bin
1525 env.set env.str(str(config["var"]), "2147483647")
1538 test sym(path.join(testdir, "expr_and_file_args_test")): bin
1555 res := $ %(config_list["args"]) -e $input -f $input_file
1556 --expression $input --file $input_file
1557 -e @(str(config["halt"]));
1562 test sym(path.join(testdir, "files_test")): bin
1564 env.set env.str(str(config["var"]), "2147483647")
1581 res := $ %(config_list["args"]) -- $input_file $input_file
1582 $input_file $input_file << @(str(config["halt"]));
1588 test sym(path.join(testdir, "line_length3")): bin
1590 env.set env.str(str(config["var"]), "62")
1596 res := $ %(config_list["args"]) -L << @(other_tests[3]);
1603 test sym(path.join(testdir, "line_length_func")): bin
1605 env.set env.str(str(config["var"]), "62")
1619 res := $ %(config_list["args"]) -L << @(other_tests[2]);
1625 test sym(path.join(testdir, "arg")): bin
1627 halt: str = str(config["halt"]);
1629 res1 := $ %(config_list["args"]) -h << $halt;
1632 res2 := $ %(config_list["args"]) -P << $halt;
1635 res3 := $ %(config_list["args"]) -R << $halt;
1638 res4 := $ %(config_list["args"]) -v << $halt;
1641 res5 := $ %(config_list["args"]) -V << $halt;
1645 test sym(path.join(testdir, "leading_zero_arg")): bin
1652 expected: str = "0.1\n-0.1\n1.1\n-1.1\n0.1\n-0.1\n";
1662 "0.1\n-0.1\n1.1\n-1.1\n.1\n-.1\n";
1669 res := $ %(config_list["args"]) -z << $data;
1674 test sym(path.join(testdir, "invalid_file_arg")): bin
1676 res := $ %(config_list["args"]) -f
1682 test sym(path.join(testdir, "invalid_option_arg")): bin
1686 res := $ %(config_list["args"]) @("-" +~ other_tests[0])
1687 -e @(str(config["halt"]));
1692 test sym(path.join(testdir, "invalid_long_option_arg")): bin
1696 res := $ %(config_list["args"]) @("--" +~ other_tests[1])
1697 -e @(str(config["halt"]));
1702 test sym(path.join(testdir, "unrecognized_option_arg")): bin
1704 res := $ %(config_list["args"]) -u -e @(str(config["halt"]));
1709 test sym(path.join(testdir, "unrecognized_long_option_arg")): bin
1711 res := $ %(config_list["args"]) --uniform -e @(str(config["halt"]));
1716 test sym(path.join(testdir, "no_required_arg_for_option")): bin
1718 res := $ %(config_list["args"]) -f;
1723 test sym(path.join(testdir, "no_required_arg_for_long_option")): bin
1725 res := $ %(config_list["args"]) --file;
1730 test sym(path.join(testdir, "given_arg_for_long_option_with_no_arg")): bin
1732 res := $ %(config_list["args"]) --version=5;
1737 test sym(path.join(testdir, "colon_option")): bin
1739 res := $ %(config_list["args"]) -:;
1744 test sym(path.join(testdir, "colon_long_option")): bin
1746 res := $ %(config_list["args"]) --:;
1751 test sym(path.join(testdir, "builtin_variable_arg_test")): bin
1756 extra: bool = bool(config["extra_math"]);
1802 @[ "-S14", "-I15", "-O16", "-E17.25" ];
1806 @[ "-S14", "-I15", "-O16" ];
1815 @[ "--scale=14", "--ibase=15", "--obase=16", "--seed=17.25" ];
1819 @[ "--scale=14", "--ibase=15", "--obase=16" ];
1833 test sym(path.join(testdir, "builtin_var_arg_with_lib")): bin
1839 res := $ %(config_list["args"]) -S100 -l << @("scale\n");
1844 test sym(path.join(testdir, "builtin_variable_long_arg_with_lib")): bin
1850 res := $ %(config_list["args"]) --scale=100 --mathlib <<
1856 test sym(path.join(testdir, "builtin_var_arg_with_lib_env_arg")): bin
1858 env.set env.str("BC_ENV_ARGS", "-l")
1864 res := $ %(config_list["args"]) -S100 << @("scale\n");
1870 test sym(path.join(testdir,
1873 env.set env.str("BC_ENV_ARGS", "-l")
1879 res := $ %(config_list["args"]) --scale=100 << @("scale\n");
1885 test sym(path.join(testdir, "builtin_var_env_arg_with_lib_arg")): bin
1887 env.set env.str("BC_ENV_ARGS", "-S100")
1893 res := $ %(config_list["args"]) -l << @("scale\n");
1899 test sym(path.join(testdir,
1902 env.set env.str("BC_ENV_ARGS", "--scale=100")
1908 res := $ %(config_list["args"]) -l << @("scale\n");
1914 test sym(path.join(testdir, "limits")): bin
1922 error("Test \"" +~ tgt_name +~ "\" did not produce output");
1927 test sym(path.join(testdir, "bad_arg_for_builtin_var_option")): bin
1934 res1 := $ %(config_list["args"]) --scale=18923c.rlg << $scale;
1938 if bool(config["extra_math"])
1942 res2 := $ %(config_list["args"]) --seed=18923c.rlg << $seed;
1948 test sym(path.join(testdir, "directory_as_file")): bin
1957 test sym(path.join(testdir, "binary_file")): bin
1964 test sym(path.join(testdir, "binary_stdin")): bin
1976 ) -> void
1985 io.eprint("To test it, get it from the Linux kernel at " +~
1994 test sym(path.join(timeconst, str(i)))
2000 res1 := $ bc -q $file << $idx;
2009 res2 := $ %(config_list["args"]) -q $file << $idx;
2023 ) -> void
2029 len_res := $ @(path.join(src_test_scriptdir, "history.py")) $calc -a;
2041 test sym(calc +~ "/history/" +~ str(i)): bin
2051 $ @(path.join(src_testdir, "history.py")) -t $calc $idx @(file_dep);
2057 * Generates all of the test targets for an executable.
2061 fn exe_tests(name: str) -> void
2069 gen_options: []str = if name == "bc" { @[ "-lq" ]; };
2070 options: []str = if name == "bc" { @[ "-lqc" ]; } else { @[ "-xc" ]; };
2080 @[ "x", "extended-register", "line_length()", other_num ];
2094 @[ "-lqC" ];
2098 @[ "-xC" ];
2101 error_options: []str = if name == "bc" { @[ "-ls" ]; } else { @[ "-x" ]; };
2104 if bool(config["valgrind"])
2127 extra: bool = bool(config["extra_math"]);
2136 if name == "bc" && bool(config["generated_tests"]) &&
2142 if host.os != "Windows" && sym(config["history"]) == @builtin
2154 fn get_bindir() -> str
2156 temp: str = str(config["bindir"]);
2161 path.join(str(config["prefix"]), "bin");
2176 fn get_libdir() -> str
2178 temp: str = str(config["libdir"]);
2183 path.join(str(config["prefix"]), "lib");
2198 fn get_includedir() -> str
2200 temp: str = str(config["includedir"]);
2205 path.join(str(config["prefix"]), "include");
2220 fn get_pc_path() -> str
2223 if str(config["pc_path"]) == ""
2225 res := $ pkg-config --variable=pc_path pkg-config;
2231 str(config["pc_path"]);
2242 fn get_datarootdir() -> str
2244 temp: str = str(config["datarootdir"]);
2249 path.join(str(config["prefix"]), "share");
2264 fn get_datadir() -> str
2266 temp: str = str(config["datadir"]);
2286 fn get_mandir() -> str
2288 temp: str = str(config["mandir"]);
2308 fn get_man1dir() -> str
2310 temp: str = str(config["man1dir"]);
2330 fn get_man3dir() -> str
2332 temp: str = str(config["man3dir"]);