From: Todd C. Miller Date: Sat, 8 Feb 2014 13:24:01 +0000 (-0700) Subject: Add some initprogname() calls to the test programs. X-Git-Tag: SUDO_1_8_10^2~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d748ebe48b89983117eb61d956362578a4e69714;p=sudo Add some initprogname() calls to the test programs. --- diff --git a/common/regress/atofoo/atofoo_test.c b/common/regress/atofoo/atofoo_test.c index 9e4753349..8c3f6d382 100644 --- a/common/regress/atofoo/atofoo_test.c +++ b/common/regress/atofoo/atofoo_test.c @@ -168,6 +168,8 @@ main(int argc, char *argv[]) { int errors = 0; + initprogname(argc > 0 ? argv[0] : "atofoo"); + errors += test_atobool(); errors += test_atoid(); errors += test_atomode(); diff --git a/common/regress/sudo_conf/conf_test.c b/common/regress/sudo_conf/conf_test.c index 658e030ab..69c09f48d 100644 --- a/common/regress/sudo_conf/conf_test.c +++ b/common/regress/sudo_conf/conf_test.c @@ -43,6 +43,7 @@ #include "missing.h" #include "sudo_conf.h" +#include "sudo_util.h" static void sudo_conf_dump(void); @@ -56,8 +57,9 @@ __dso_public int main(int argc, char *argv[]); int main(int argc, char *argv[]) { + initprogname(argc > 0 ? argv[0] : "conf_test"); if (argc != 2) { - fprintf(stderr, "usage: conf_test conf_file\n"); + fprintf(stderr, "usage: %s conf_file\n", getprogname()); exit(1); } sudo_conf_read(argv[1]); diff --git a/common/regress/sudo_parseln/parseln_test.c b/common/regress/sudo_parseln/parseln_test.c index 73b960dc1..369325c16 100644 --- a/common/regress/sudo_parseln/parseln_test.c +++ b/common/regress/sudo_parseln/parseln_test.c @@ -43,6 +43,7 @@ #include "missing.h" #include "fileops.h" +#include "sudo_util.h" __dso_public int main(int argc, char *argv[]); @@ -59,6 +60,8 @@ main(int argc, char *argv[]) size_t linesize = 0; char *line = NULL; + initprogname(argc > 0 ? argv[0] : "parseln_test"); + while (sudo_parseln(&line, &linesize, &lineno, stdin) != -1) printf("%6u\t%s\n", lineno, line); free(line); diff --git a/common/regress/tailq/hltq_test.c b/common/regress/tailq/hltq_test.c index 49b724db6..42437e68b 100644 --- a/common/regress/tailq/hltq_test.c +++ b/common/regress/tailq/hltq_test.c @@ -44,6 +44,7 @@ #include "missing.h" #include "fatal.h" #include "queue.h" +#include "sudo_util.h" __dso_public int main(int argc, char *argv[]); @@ -70,6 +71,8 @@ main(int argc, char *argv[]) struct test_data_list tq; int errors = 0; + initprogname(argc > 0 ? argv[0] : "hltq_test"); + /* * Initialize three data elements and concatenate them in order. */ diff --git a/plugins/sudoers/regress/parser/check_fill.c b/plugins/sudoers/regress/parser/check_fill.c index ce7c3ca4d..afe99f311 100644 --- a/plugins/sudoers/regress/parser/check_fill.c +++ b/plugins/sudoers/regress/parser/check_fill.c @@ -47,6 +47,7 @@ #include "parse.h" #include "toke.h" #include "sudo_plugin.h" +#include "sudo_util.h" #include __dso_public int main(int argc, char *argv[]); @@ -170,6 +171,8 @@ main(int argc, char *argv[]) { int ntests, errors = 0; + initprogname(argc > 0 ? argv[0] : "check_fill"); + errors += do_tests(check_fill, txt_data, sizeof(txt_data) / sizeof(txt_data[0])); errors += do_tests(check_fill_cmnd, cmd_data, sizeof(cmd_data) / sizeof(cmd_data[0])); errors += do_tests(check_fill_args, args_data, sizeof(args_data) / sizeof(args_data[0])); @@ -177,7 +180,7 @@ main(int argc, char *argv[]) ntests = sizeof(txt_data) / sizeof(txt_data[0]) + sizeof(cmd_data) / sizeof(cmd_data[0]) + sizeof(args_data) / sizeof(args_data[0]); - printf("check_fill: %d tests run, %d errors, %d%% success rate\n", + printf("%s: %d tests run, %d errors, %d%% success rate\n", getprogname(), ntests, errors, (ntests - errors) * 100 / ntests); exit(errors);