Less verbose output unless the -v option is used.
Also display a test summary at the end.
This commit is contained in:
@@ -44,6 +44,7 @@ DECL_PLUGIN(audit_plugin, python_audit);
|
|||||||
DECL_PLUGIN(sudoers_group_plugin, group_plugin);
|
DECL_PLUGIN(sudoers_group_plugin, group_plugin);
|
||||||
|
|
||||||
static struct passwd example_pwd;
|
static struct passwd example_pwd;
|
||||||
|
static bool verbose;
|
||||||
|
|
||||||
static int _init_symbols(void);
|
static int _init_symbols(void);
|
||||||
static int _unlink_symbols(void);
|
static int _unlink_symbols(void);
|
||||||
@@ -1511,13 +1512,26 @@ _unlink_symbols(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int errors = 0;
|
int ch, errors = 0, ntests = 0;
|
||||||
|
|
||||||
if (argc != 2) {
|
while ((ch = getopt(argc, argv, "v")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'v':
|
||||||
|
verbose = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "usage: %s [-v]\n", getprogname());
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
if (argc != 1) {
|
||||||
printf("Please specify the python_plugin.so as argument!\n");
|
printf("Please specify the python_plugin.so as argument!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
python_plugin_so_path = argv[1];
|
python_plugin_so_path = argv[0];
|
||||||
|
|
||||||
RUN_TEST(check_example_io_plugin_version_display(true));
|
RUN_TEST(check_example_io_plugin_version_display(true));
|
||||||
RUN_TEST(check_example_io_plugin_version_display(false));
|
RUN_TEST(check_example_io_plugin_version_display(false));
|
||||||
@@ -1595,5 +1609,10 @@ main(int argc, char *argv[])
|
|||||||
RUN_TEST(check_example_debugging("plugin@err"));
|
RUN_TEST(check_example_debugging("plugin@err"));
|
||||||
RUN_TEST(check_plugin_unload());
|
RUN_TEST(check_plugin_unload());
|
||||||
|
|
||||||
|
if (ntests != 0) {
|
||||||
|
printf("%s: %d tests run, %d errors, %d%% success rate\n",
|
||||||
|
getprogname(), ntests, errors, (ntests - errors) * 100 / ntests);
|
||||||
|
}
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,10 @@ char ** create_str_array(size_t count, ...);
|
|||||||
#define RUN_TEST(testcase) \
|
#define RUN_TEST(testcase) \
|
||||||
do { \
|
do { \
|
||||||
int success = 1; \
|
int success = 1; \
|
||||||
printf("Running test " #testcase " ... \n"); \
|
ntests++; \
|
||||||
|
if (verbose) { \
|
||||||
|
printf("Running test " #testcase " ... \n"); \
|
||||||
|
} \
|
||||||
if (!init()) { \
|
if (!init()) { \
|
||||||
printf("FAILED: initialization of testcase %s at %s:%d\n", #testcase, __FILE__, __LINE__); \
|
printf("FAILED: initialization of testcase %s at %s:%d\n", #testcase, __FILE__, __LINE__); \
|
||||||
success = 0; \
|
success = 0; \
|
||||||
|
Reference in New Issue
Block a user