Lines Matching +full:stdout +full:- +full:path

1 // SPDX-License-Identifier: GPL-2.0-only
29 if (verbose() && env.worker_id == -1) { in stdio_hijack_init()
30 /* nothing to do, output to stdout by default */ in stdio_hijack_init()
34 fflush(stdout); in stdio_hijack_init()
37 stdout = open_memstream(log_buf, log_cnt); in stdio_hijack_init()
38 if (!stdout) { in stdio_hijack_init()
39 stdout = env.stdout; in stdio_hijack_init()
45 env.subtest_state->stdout = stdout; in stdio_hijack_init()
47 env.test_state->stdout = stdout; in stdio_hijack_init()
49 stderr = stdout; in stdio_hijack_init()
56 if (verbose() && env.worker_id == -1) { in stdio_hijack()
57 /* nothing to do, output to stdout by default */ in stdio_hijack()
61 env.stdout = stdout; in stdio_hijack()
71 if (verbose() && env.worker_id == -1) { in stdio_restore_cleanup()
72 /* nothing to do, output to stdout by default */ in stdio_restore_cleanup()
76 fflush(stdout); in stdio_restore_cleanup()
79 fclose(env.subtest_state->stdout); in stdio_restore_cleanup()
80 env.subtest_state->stdout = NULL; in stdio_restore_cleanup()
81 stdout = env.test_state->stdout; in stdio_restore_cleanup()
82 stderr = env.test_state->stdout; in stdio_restore_cleanup()
84 fclose(env.test_state->stdout); in stdio_restore_cleanup()
85 env.test_state->stdout = NULL; in stdio_restore_cleanup()
93 if (verbose() && env.worker_id == -1) { in stdio_restore()
94 /* nothing to do, output to stdout by default */ in stdio_restore()
98 if (stdout == env.stdout) in stdio_restore()
103 stdout = env.stdout; in stdio_restore()
163 for (i = 0; i < sel->blacklist.cnt; i++) { in should_run()
164 if (glob_match(name, sel->blacklist.tests[i].name) && in should_run()
165 !sel->blacklist.tests[i].subtest_cnt) in should_run()
169 for (i = 0; i < sel->whitelist.cnt; i++) { in should_run()
170 if (glob_match(name, sel->whitelist.tests[i].name)) in should_run()
174 if (!sel->whitelist.cnt && !sel->num_set) in should_run()
177 return num < sel->num_set_len && sel->num_set[num]; in should_run()
188 for (i = 0; i < sel->blacklist.cnt; i++) { in should_run_subtest()
189 if (glob_match(test_name, sel->blacklist.tests[i].name)) { in should_run_subtest()
190 if (!sel->blacklist.tests[i].subtest_cnt) in should_run_subtest()
193 for (j = 0; j < sel->blacklist.tests[i].subtest_cnt; j++) { in should_run_subtest()
195 sel->blacklist.tests[i].subtests[j])) in should_run_subtest()
201 for (i = 0; i < sel->whitelist.cnt; i++) { in should_run_subtest()
202 if (glob_match(test_name, sel->whitelist.tests[i].name)) { in should_run_subtest()
203 if (!sel->whitelist.tests[i].subtest_cnt) in should_run_subtest()
206 for (j = 0; j < sel->whitelist.tests[i].subtest_cnt; j++) { in should_run_subtest()
208 sel->whitelist.tests[i].subtests[j])) in should_run_subtest()
214 if (!sel->whitelist.cnt && !subtest_sel->num_set) in should_run_subtest()
217 return subtest_num < subtest_sel->num_set_len && subtest_sel->num_set[subtest_num]; in should_run_subtest()
228 fprintf(env.stdout, "%s", log_buf); in print_test_log()
229 if (log_buf[log_cnt - 1] != '\n') in print_test_log()
230 fprintf(env.stdout, "\n"); in print_test_log()
237 fprintf(env.stdout, "#%-*d %s", TEST_NUM_WIDTH, test_num, test_name); in print_test_name()
240 fprintf(env.stdout, ":%s", result); in print_test_name()
242 fprintf(env.stdout, "\n"); in print_test_name()
253 fprintf(env.stdout, "#%-*s %s/%s", in print_subtest_name()
258 fprintf(env.stdout, ":%s", result); in print_subtest_name()
260 fprintf(env.stdout, "\n"); in print_subtest_name()
268 bool test_failed = test_state->error_cnt > 0; in dump_test_log()
269 bool force_log = test_state->force_log; in dump_test_log()
278 if (env.worker_id != -1) in dump_test_log()
287 if (test_state->log_cnt && print_test) in dump_test_log()
288 print_test_log(test_state->log_buf, test_state->log_cnt); in dump_test_log()
290 for (i = 0; i < test_state->subtest_num; i++) { in dump_test_log()
291 subtest_state = &test_state->subtest_states[i]; in dump_test_log()
292 subtest_failed = subtest_state->error_cnt; in dump_test_log()
293 subtest_filtered = subtest_state->filtered; in dump_test_log()
299 if (subtest_state->log_cnt && print_subtest) { in dump_test_log()
300 print_test_log(subtest_state->log_buf, in dump_test_log()
301 subtest_state->log_cnt); in dump_test_log()
304 print_subtest_name(test->test_num, i + 1, in dump_test_log()
305 test->test_name, subtest_state->name, in dump_test_log()
306 test_result(subtest_state->error_cnt, in dump_test_log()
307 subtest_state->skipped)); in dump_test_log()
310 print_test_name(test->test_num, test->test_name, in dump_test_log()
311 test_result(test_failed, test_state->skip_cnt)); in dump_test_log()
316 /* A bunch of tests set custom affinity per-thread and/or per-process. Reset
317 * it after each test/sub-test.
345 if (env.saved_netns_fd == -1) { in save_netns()
353 if (setns(env.saved_netns_fd, CLONE_NEWNET) == -1) { in restore_netns()
366 if (subtest_state->error_cnt) { in test__end_subtest()
367 test_state->error_cnt++; in test__end_subtest()
369 if (!subtest_state->skipped) in test__end_subtest()
370 test_state->sub_succ_cnt++; in test__end_subtest()
372 test_state->skip_cnt++; in test__end_subtest()
376 print_subtest_name(test->test_num, test_state->subtest_num, in test__end_subtest()
377 test->test_name, subtest_state->name, in test__end_subtest()
378 test_result(subtest_state->error_cnt, in test__end_subtest()
379 subtest_state->skipped)); in test__end_subtest()
395 state->subtest_num++; in test__start_subtest()
396 state->subtest_states = in test__start_subtest()
397 realloc(state->subtest_states, in test__start_subtest()
398 state->subtest_num * sub_state_size); in test__start_subtest()
399 if (!state->subtest_states) { in test__start_subtest()
404 subtest_state = &state->subtest_states[state->subtest_num - 1]; in test__start_subtest()
410 "Subtest #%d didn't provide sub-test name!\n", in test__start_subtest()
411 state->subtest_num); in test__start_subtest()
415 subtest_state->name = strdup(subtest_name); in test__start_subtest()
416 if (!subtest_state->name) { in test__start_subtest()
419 state->subtest_num); in test__start_subtest()
425 state->subtest_num, in test__start_subtest()
426 test->test_name, in test__start_subtest()
428 subtest_state->filtered = true; in test__start_subtest()
433 stdio_hijack_init(&subtest_state->log_buf, &subtest_state->log_cnt); in test__start_subtest()
440 env.test_state->force_log = true; in test__force_log()
446 env.subtest_state->skipped = true; in test__skip()
448 env.test_state->skip_cnt++; in test__skip()
454 env.subtest_state->error_cnt++; in test__fail()
456 env.test_state->error_cnt++; in test__fail()
459 int test__join_cgroup(const char *path) in test__join_cgroup() argument
463 if (!env.test->need_cgroup_cleanup) { in test__join_cgroup()
467 env.test->test_num, env.test->test_name); in test__join_cgroup()
468 return -1; in test__join_cgroup()
471 env.test->need_cgroup_cleanup = true; in test__join_cgroup()
474 fd = create_and_get_cgroup(path); in test__join_cgroup()
478 env.test->test_num, env.test->test_name, path, errno); in test__join_cgroup()
482 if (join_cgroup(path)) { in test__join_cgroup()
485 env.test->test_num, env.test->test_name, path, errno); in test__join_cgroup()
486 return -1; in test__join_cgroup()
498 fprintf(stdout, "%s:FAIL:map '%s' not found\n", test, name); in bpf_find_map()
500 return -1; in bpf_find_map()
512 if (sysctl_fd != -1) { in is_jit_enabled()
545 return -1; in compare_map_keys()
569 err = -1; in compare_stack_ips()
578 err = -1; in compare_stack_ips()
592 fp = popen("readelf -n ./urandom_read | grep 'Build ID'", "r"); in extract_build_id()
594 return -1; in extract_build_id()
596 if (getline(&line, &len, fp) == -1) in extract_build_id()
608 return -1; in extract_build_id()
632 fprintf(env.stderr, "Failed to trigger kernel-side RCU sync!\n"); in unload_bpf_testmod()
636 fprintf(stdout, "bpf_testmod.ko is already unloaded.\n"); in unload_bpf_testmod()
639 fprintf(env.stderr, "Failed to unload bpf_testmod.ko from kernel: %d\n", -errno); in unload_bpf_testmod()
643 fprintf(stdout, "Successfully unloaded bpf_testmod.ko.\n"); in unload_bpf_testmod()
654 fprintf(stdout, "Loading bpf_testmod.ko...\n"); in load_bpf_testmod()
658 fprintf(env.stderr, "Can't find bpf_testmod.ko kernel module: %d\n", -errno); in load_bpf_testmod()
659 return -ENOENT; in load_bpf_testmod()
662 fprintf(env.stderr, "Failed to load bpf_testmod.ko into the kernel: %d\n", -errno); in load_bpf_testmod()
664 return -EINVAL; in load_bpf_testmod()
669 fprintf(stdout, "Successfully loaded bpf_testmod.ko.\n"); in load_bpf_testmod()
709 ARG_DEBUG = -1,
717 { "name-blacklist", ARG_TEST_NAME_BLACKLIST, "NAMES", 0,
719 { "verifier-stats", ARG_VERIFIER_STATS, NULL, 0,
722 "Verbose output (use -vv or -vvv for progressively verbose output)" },
724 "Get number of selected top-level tests " },
743 vfprintf(stdout, format, args); in libbpf_print_fn()
754 for (i = 0; i < set->cnt; i++) { in free_test_filter_set()
755 free((void *)set->tests[i].name); in free_test_filter_set()
756 for (j = 0; j < set->tests[i].subtest_cnt; j++) in free_test_filter_set()
757 free((void *)set->tests[i].subtests[j]); in free_test_filter_set()
759 free((void *)set->tests[i].subtests); in free_test_filter_set()
762 free((void *)set->tests); in free_test_filter_set()
767 free_test_filter_set(&test_selector->blacklist); in free_test_selector()
768 free_test_filter_set(&test_selector->whitelist); in free_test_selector()
769 free(test_selector->num_set); in free_test_selector()
776 struct test_env *env = state->input; in parse_arg()
785 &env->subtest_selector.num_set, in parse_arg()
786 &env->subtest_selector.num_set_len)) { in parse_arg()
789 return -EINVAL; in parse_arg()
792 if (parse_num_list(arg, &env->test_selector.num_set, in parse_arg()
793 &env->test_selector.num_set_len)) { in parse_arg()
795 return -EINVAL; in parse_arg()
802 &env->test_selector.whitelist, in parse_arg()
804 return -ENOMEM; in parse_arg()
810 &env->test_selector.blacklist, in parse_arg()
812 return -ENOMEM; in parse_arg()
816 env->verifier_stats = true; in parse_arg()
819 env->verbosity = VERBOSE_NORMAL; in parse_arg()
822 env->verbosity = VERBOSE_VERY; in parse_arg()
825 env->verbosity = VERBOSE_SUPER; in parse_arg()
829 "Unrecognized verbosity setting ('%s'), only -v and -vv are supported\n", in parse_arg()
831 return -EINVAL; in parse_arg()
836 if (setenv("SELFTESTS_VERBOSE", "1", 1) == -1) { in parse_arg()
840 return -EINVAL; in parse_arg()
846 env->get_test_cnt = true; in parse_arg()
849 env->list_test_names = true; in parse_arg()
853 env->workers = atoi(arg); in parse_arg()
854 if (!env->workers) { in parse_arg()
856 return -EINVAL; in parse_arg()
859 env->workers = get_nprocs(); in parse_arg()
863 env->debug = true; in parse_arg()
878 * into corresponding sub-directory to load correct BPF objects.
880 * This is done by looking at executable name. If it contains "-flavor"
886 * some/path/to/test_progs[-flavor], where -flavor part is optional. in cd_flavor_subdir()
887 * First cut out "test_progs[-flavor]" part, then extract "flavor" in cd_flavor_subdir()
897 flavor = strrchr(flavor, '-'); in cd_flavor_subdir()
902 fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor); in cd_flavor_subdir()
912 err = -errno; in trigger_module_test_read()
928 return -ENOMEM; in trigger_module_test_write()
931 buf[write_sz-1] = '\0'; in trigger_module_test_write()
934 err = -errno; in trigger_module_test_write()
951 if (!ASSERT_NEQ(fd, -1, "open sysctl")) in write_sysctl()
952 return -1; in write_sysctl()
958 return -1; in write_sysctl()
972 env.test_state->error_cnt++; in crash_handler()
975 if (env.stdout) in crash_handler()
977 if (env.worker_id != -1) in crash_handler()
998 switch (msg->type) { in str_msg()
1000 sprintf(buf, "MSG_DO_TEST %d", msg->do_test.num); in str_msg()
1004 msg->test_done.num, in str_msg()
1005 msg->test_done.have_log); in str_msg()
1009 msg->subtest_done.num, in str_msg()
1010 msg->subtest_done.have_log); in str_msg()
1014 strlen(msg->test_log.log_buf), in str_msg()
1015 msg->test_log.is_last); in str_msg()
1059 stdio_hijack(&state->log_buf, &state->log_cnt); in run_one_test()
1061 if (test->run_test) in run_one_test()
1062 test->run_test(); in run_one_test()
1063 else if (test->run_serial_test) in run_one_test()
1064 test->run_serial_test(); in run_one_test()
1066 /* ensure last sub-test is finalized properly */ in run_one_test()
1070 state->tested = true; in run_one_test()
1072 if (verbose() && env.worker_id == -1) in run_one_test()
1073 print_test_name(test_num + 1, test->test_name, in run_one_test()
1074 test_result(state->error_cnt, state->skip_cnt)); in run_one_test()
1078 if (test->need_cgroup_cleanup) in run_one_test()
1096 if (msg->type != type) { in read_prog_test_msg()
1097 printf("%s: unexpected message type %d. expected %d\n", __func__, msg->type, type); in read_prog_test_msg()
1136 int subtest_num = state->subtest_num; in dispatch_thread_send_subtests()
1138 state->subtest_states = malloc(subtest_num * sizeof(*subtest_state)); in dispatch_thread_send_subtests()
1141 subtest_state = &state->subtest_states[i]; in dispatch_thread_send_subtests()
1148 subtest_state->name = strdup(msg.subtest_done.name); in dispatch_thread_send_subtests()
1149 subtest_state->error_cnt = msg.subtest_done.error_cnt; in dispatch_thread_send_subtests()
1150 subtest_state->skipped = msg.subtest_done.skipped; in dispatch_thread_send_subtests()
1151 subtest_state->filtered = msg.subtest_done.filtered; in dispatch_thread_send_subtests()
1156 &subtest_state->log_buf, in dispatch_thread_send_subtests()
1157 &subtest_state->log_cnt)) in dispatch_thread_send_subtests()
1169 sock_fd = data->sock_fd; in dispatch_thread()
1172 int test_to_run = -1; in dispatch_thread()
1192 if (!test->should_run || test->run_serial_test) in dispatch_thread()
1206 env.worker_current_test[data->worker_id] = test_to_run; in dispatch_thread()
1219 state->tested = true; in dispatch_thread()
1220 state->error_cnt = msg.test_done.error_cnt; in dispatch_thread()
1221 state->skip_cnt = msg.test_done.skip_cnt; in dispatch_thread()
1222 state->sub_succ_cnt = msg.test_done.sub_succ_cnt; in dispatch_thread()
1223 state->subtest_num = msg.test_done.subtest_num; in dispatch_thread()
1228 &state->log_buf, in dispatch_thread()
1229 &state->log_cnt)) in dispatch_thread()
1234 if (!state->subtest_num) in dispatch_thread()
1247 fprintf(stderr, "[%d]: Protocol/IO error: %s.\n", data->worker_id, strerror(errno)); in dispatch_thread()
1257 data->worker_id, strerror(errno)); in dispatch_thread()
1271 if (!state->tested) in calculate_summary_and_print_errors()
1274 sub_succ_cnt += state->sub_succ_cnt; in calculate_summary_and_print_errors()
1275 skip_cnt += state->skip_cnt; in calculate_summary_and_print_errors()
1277 if (state->error_cnt) in calculate_summary_and_print_errors()
1296 if (!state->tested || !state->error_cnt) in calculate_summary_and_print_errors()
1306 env->succ_cnt = succ_cnt; in calculate_summary_and_print_errors()
1307 env->sub_succ_cnt = sub_succ_cnt; in calculate_summary_and_print_errors()
1308 env->fail_cnt = fail_cnt; in calculate_summary_and_print_errors()
1309 env->skip_cnt = skip_cnt; in calculate_summary_and_print_errors()
1369 if (!test->should_run || !test->run_serial_test) in server_main()
1377 fflush(stdout); in server_main()
1410 slen -= len; in worker_main_send_log()
1420 if (state->log_buf) { in free_subtest_state()
1421 free(state->log_buf); in free_subtest_state()
1422 state->log_buf = NULL; in free_subtest_state()
1423 state->log_cnt = 0; in free_subtest_state()
1425 free(state->name); in free_subtest_state()
1426 state->name = NULL; in free_subtest_state()
1438 for (i = 0; i < state->subtest_num; i++) { in worker_main_send_subtests()
1439 subtest_state = &state->subtest_states[i]; in worker_main_send_subtests()
1443 strncpy(msg.subtest_done.name, subtest_state->name, MAX_SUBTEST_NAME); in worker_main_send_subtests()
1445 msg.subtest_done.error_cnt = subtest_state->error_cnt; in worker_main_send_subtests()
1446 msg.subtest_done.skipped = subtest_state->skipped; in worker_main_send_subtests()
1447 msg.subtest_done.filtered = subtest_state->filtered; in worker_main_send_subtests()
1450 if (verbose() || state->force_log || subtest_state->error_cnt) { in worker_main_send_subtests()
1451 if (subtest_state->log_cnt) in worker_main_send_subtests()
1463 worker_main_send_log(sock, subtest_state->log_buf, subtest_state->log_cnt); in worker_main_send_subtests()
1466 free(subtest_state->name); in worker_main_send_subtests()
1470 for (; i < state->subtest_num; i++) in worker_main_send_subtests()
1471 free_subtest_state(&state->subtest_states[i]); in worker_main_send_subtests()
1472 free(state->subtest_states); in worker_main_send_subtests()
1503 test->test_name); in worker_main()
1510 msg.test_done.error_cnt = state->error_cnt; in worker_main()
1511 msg.test_done.skip_cnt = state->skip_cnt; in worker_main()
1512 msg.test_done.sub_succ_cnt = state->sub_succ_cnt; in worker_main()
1513 msg.test_done.subtest_num = state->subtest_num; in worker_main()
1516 if (verbose() || state->force_log || state->error_cnt) { in worker_main()
1517 if (state->log_cnt) in worker_main()
1527 worker_main_send_log(sock, state->log_buf, state->log_cnt); in worker_main()
1529 if (state->log_buf) { in worker_main()
1530 free(state->log_buf); in worker_main()
1531 state->log_buf = NULL; in worker_main()
1532 state->log_cnt = 0; in worker_main()
1535 if (state->subtest_num) in worker_main()
1543 test->test_name); in worker_main()
1549 return -1; in worker_main()
1563 for (j = 0; j < test_state->subtest_num; j++) in free_test_states()
1564 free_subtest_state(&test_state->subtest_states[j]); in free_test_states()
1566 free(test_state->subtest_states); in free_test_states()
1567 free(test_state->log_buf); in free_test_states()
1568 test_state->subtest_states = NULL; in free_test_states()
1569 test_state->log_buf = NULL; in free_test_states()
1607 return -1; in main()
1610 env.stdout = stdout; in main()
1623 test->test_num = i + 1; in main()
1624 test->should_run = should_run(&env.test_selector, in main()
1625 test->test_num, test->test_name); in main()
1627 if ((test->run_test == NULL && test->run_serial_test == NULL) || in main()
1628 (test->run_test != NULL && test->run_serial_test != NULL)) { in main()
1630 test->test_num, test->test_name, test->test_name, test->test_name); in main()
1640 env.worker_id = -1; /* main process */ in main()
1645 fprintf(stdout, "Launching %d workers.\n", env.workers); in main()
1652 return -1; in main()
1657 return -1; in main()
1669 if (env.worker_id == -1) { in main()
1683 if (!test->should_run) in main()
1692 fprintf(env.stdout, "%s\n", test->test_name); in main()