Add some initprogname() calls to the test programs.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 8 Feb 2014 13:24:01 +0000 (06:24 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 8 Feb 2014 13:24:01 +0000 (06:24 -0700)
common/regress/atofoo/atofoo_test.c
common/regress/sudo_conf/conf_test.c
common/regress/sudo_parseln/parseln_test.c
common/regress/tailq/hltq_test.c
plugins/sudoers/regress/parser/check_fill.c

index 9e47533492b5a157a4f0bd2caf9152d176bae2b2..8c3f6d382d6a342d9545a8a66a391556ad62683b 100644 (file)
@@ -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();
index 658e030ab3610acf307dd6e36e0009965749ba49..69c09f48d24a57701dd07e519c4ce685d6b81262 100644 (file)
@@ -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]);
index 73b960dc194c29cec8e6f135df85b5b29c14f485..369325c1655f9e784bfa77ee5eaf14f759c26f49 100644 (file)
@@ -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);
index 49b724db6dec03e5a37415b8579e2bbc1f73baee..42437e68bf943e1ae4b4f7a55faa5c2c522c31f3 100644 (file)
@@ -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.
      */
index ce7c3ca4d1dd86da90ae182238e4448c7ef77608..afe99f311a9e7b60ac49b22e24b491979288179e 100644 (file)
@@ -47,6 +47,7 @@
 #include "parse.h"
 #include "toke.h"
 #include "sudo_plugin.h"
+#include "sudo_util.h"
 #include <gram.h>
 
 __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);