Lines Matching full:env

42 	return env.verbosity > VERBOSE_NONE;  in verbose()
48 if (verbose() && env.worker_id == -1) { in stdio_hijack_init()
58 stdout = env.stdout_saved; in stdio_hijack_init()
63 if (env.subtest_state) in stdio_hijack_init()
64 env.subtest_state->stdout_saved = stdout; in stdio_hijack_init()
66 env.test_state->stdout_saved = stdout; in stdio_hijack_init()
75 if (verbose() && env.worker_id == -1) { in stdio_hijack()
80 env.stdout_saved = stdout; in stdio_hijack()
81 env.stderr_saved = stderr; in stdio_hijack()
90 if (verbose() && env.worker_id == -1) { in stdio_restore_cleanup()
97 if (env.subtest_state) { in stdio_restore_cleanup()
98 fclose(env.subtest_state->stdout_saved); in stdio_restore_cleanup()
99 env.subtest_state->stdout_saved = NULL; in stdio_restore_cleanup()
100 stdout = env.test_state->stdout_saved; in stdio_restore_cleanup()
101 stderr = env.test_state->stdout_saved; in stdio_restore_cleanup()
103 fclose(env.test_state->stdout_saved); in stdio_restore_cleanup()
104 env.test_state->stdout_saved = NULL; in stdio_restore_cleanup()
112 if (verbose() && env.worker_id == -1) { in stdio_restore()
117 if (stdout == env.stdout_saved) in stdio_restore()
122 stdout = env.stdout_saved; in stdio_restore()
123 stderr = env.stderr_saved; in stdio_restore()
153 struct test_env env = {}; variable
265 fprintf(env.stdout_saved, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); in print_test_result()
267 fprintf(env.stdout_saved, "FAIL"); in print_test_result()
269 fprintf(env.stdout_saved, "OK"); in print_test_result()
271 fprintf(env.stdout_saved, "SKIP"); in print_test_result()
273 fprintf(env.stdout_saved, "OK (SKIP: %d/%d)", skipped_cnt, subtests_cnt); in print_test_result()
275 fprintf(env.stdout_saved, "\n"); in print_test_result()
281 fprintf(env.stdout_saved, "%s", log_buf); in print_test_log()
283 fprintf(env.stdout_saved, "\n"); in print_test_log()
294 fprintf(env.stdout_saved, "#%-*s %s/%s", in print_subtest_name()
299 fprintf(env.stdout_saved, ":%s", result); in print_subtest_name()
301 fprintf(env.stdout_saved, "\n"); in print_subtest_name()
332 if (env.worker_id != -1) in dump_test_log()
402 for (i = 0; i < env.nr_cpus; i++) in reset_affinity()
421 env.saved_netns_fd = open("/proc/self/ns/net", O_RDONLY); in save_netns()
422 if (env.saved_netns_fd == -1) { in save_netns()
430 if (setns(env.saved_netns_fd, CLONE_NEWNET) == -1) { in restore_netns()
439 struct prog_test_def *test = env.test; in test__end_subtest()
440 struct test_state *test_state = env.test_state; in test__end_subtest()
441 struct subtest_state *subtest_state = env.subtest_state; in test__end_subtest()
452 if (verbose() && !env.workers) in test__end_subtest()
459 env.subtest_state = NULL; in test__end_subtest()
464 struct prog_test_def *test = env.test; in test__start_subtest()
465 struct test_state *state = env.test_state; in test__start_subtest()
469 if (env.subtest_state) in test__start_subtest()
486 fprintf(env.stderr_saved, in test__start_subtest()
494 fprintf(env.stderr_saved, in test__start_subtest()
500 if (!should_run_subtest(&env.test_selector, in test__start_subtest()
501 &env.subtest_selector, in test__start_subtest()
509 subtest_state->should_tmon = match_subtest(&env.tmon_selector.whitelist, in test__start_subtest()
513 env.subtest_state = subtest_state; in test__start_subtest()
521 env.test_state->force_log = true; in test__force_log()
526 if (env.subtest_state) in test__skip()
527 env.subtest_state->skipped = true; in test__skip()
529 env.test_state->skip_cnt++; in test__skip()
534 if (env.subtest_state) in test__fail()
535 env.subtest_state->error_cnt++; in test__fail()
537 env.test_state->error_cnt++; in test__fail()
544 if (!env.test->need_cgroup_cleanup) { in test__join_cgroup()
548 env.test->test_num, env.test->test_name); in test__join_cgroup()
552 env.test->need_cgroup_cleanup = true; in test__join_cgroup()
559 env.test->test_num, env.test->test_name, path, errno); in test__join_cgroup()
566 env.test->test_num, env.test->test_name, path, errno); in test__join_cgroup()
691 if (env.test->should_tmon || in netns_new()
692 (env.subtest_state && env.subtest_state->should_tmon)) { in netns_new()
693 test_name = env.test->test_name; in netns_new()
694 subtest_name = env.subtest_state ? env.subtest_state->name : NULL; in netns_new()
873 if (env.verbosity < VERBOSE_VERY && level == LIBBPF_DEBUG) in libbpf_print_fn()
909 struct test_env *env = state->input; in parse_arg() local
919 &env->subtest_selector.num_set, in parse_arg()
920 &env->subtest_selector.num_set_len)) { in parse_arg()
926 if (parse_num_list(arg, &env->test_selector.num_set, in parse_arg()
927 &env->test_selector.num_set_len)) { in parse_arg()
937 &env->test_selector.whitelist, in parse_arg()
941 &env->test_selector.whitelist, in parse_arg()
950 &env->test_selector.blacklist, in parse_arg()
954 &env->test_selector.blacklist, in parse_arg()
960 env->verifier_stats = true; in parse_arg()
963 env->verbosity = VERBOSE_NORMAL; in parse_arg()
966 env->verbosity = VERBOSE_VERY; in parse_arg()
969 env->verbosity = VERBOSE_SUPER; in parse_arg()
978 env_verbosity = env->verbosity; in parse_arg()
991 env->get_test_cnt = true; in parse_arg()
994 env->list_test_names = true; in parse_arg()
998 env->workers = atoi(arg); in parse_arg()
999 if (!env->workers) { in parse_arg()
1004 env->workers = get_nprocs(); in parse_arg()
1008 env->debug = true; in parse_arg()
1011 env->json = fopen(arg, "w"); in parse_arg()
1012 if (env->json == NULL) { in parse_arg()
1026 &env->tmon_selector.whitelist, in parse_arg()
1030 &env->tmon_selector.whitelist, in parse_arg()
1172 if (env.stdout_saved) in crash_handler()
1174 if (env.test) { in crash_handler()
1175 env.test_state->error_cnt++; in crash_handler()
1176 dump_test_log(env.test, env.test_state, true, false, NULL); in crash_handler()
1178 if (env.worker_id != -1) in crash_handler()
1179 fprintf(stderr, "[%d]: ", env.worker_id); in crash_handler()
1188 for (i = 0; i < env.workers; i++) in sigint_handler()
1189 if (env.worker_socks[i] > 0) in sigint_handler()
1190 close(env.worker_socks[i]); in sigint_handler()
1233 if (env.debug) in send_message()
1246 if (env.debug) in recv_message()
1257 env.test = test; in run_one_test()
1258 env.test_state = state; in run_one_test()
1268 if (env.subtest_state) in run_one_test()
1273 if (verbose() && env.worker_id == -1) in run_one_test()
1407 env.worker_current_test[data->worker_id] = test_to_run; in dispatch_thread()
1447 if (env.debug) in dispatch_thread()
1456 if (env.debug) in dispatch_thread()
1464 static void calculate_summary_and_print_errors(struct test_env *env) in calculate_summary_and_print_errors() argument
1485 if (env->json) { in calculate_summary_and_print_errors()
1486 w = jsonw_new(env->json); in calculate_summary_and_print_errors()
1488 fprintf(env->stderr_saved, "Failed to create new JSON stream."); in calculate_summary_and_print_errors()
1527 if (env->json) in calculate_summary_and_print_errors()
1528 fclose(env->json); in calculate_summary_and_print_errors()
1533 env->succ_cnt = succ_cnt; in calculate_summary_and_print_errors()
1534 env->sub_succ_cnt = sub_succ_cnt; in calculate_summary_and_print_errors()
1535 env->fail_cnt = fail_cnt; in calculate_summary_and_print_errors()
1536 env->skip_cnt = skip_cnt; in calculate_summary_and_print_errors()
1551 dispatcher_threads = calloc(sizeof(pthread_t), env.workers); in server_main()
1552 data = calloc(sizeof(struct dispatch_data), env.workers); in server_main()
1554 env.worker_current_test = calloc(sizeof(int), env.workers); in server_main()
1555 for (i = 0; i < env.workers; i++) { in server_main()
1559 data[i].sock_fd = env.worker_socks[i]; in server_main()
1568 for (i = 0; i < env.workers; i++) { in server_main()
1575 if (env.debug) in server_main()
1577 i, env.worker_current_test[i] + 1); in server_main()
1587 free(env.worker_current_test); in server_main()
1606 calculate_summary_and_print_errors(&env); in server_main()
1609 for (i = 0; i < env.workers; i++) { in server_main()
1612 pid = waitpid(env.worker_pids[i], &wstatus, 0); in server_main()
1613 if (pid != env.worker_pids[i]) in server_main()
1716 if (env.debug) in worker_main()
1718 env.worker_id); in worker_main()
1726 if (env.debug) in worker_main()
1728 env.worker_id, in worker_main()
1766 if (env.debug) in worker_main()
1768 env.worker_id, in worker_main()
1774 if (env.debug) in worker_main()
1775 fprintf(stderr, "[%d]: unknown message.\n", env.worker_id); in worker_main()
1815 err = argp_parse(&argp, argc, argv, 0, NULL, &env); in main()
1829 env.jit_enabled = is_jit_enabled(); in main()
1830 env.nr_cpus = libbpf_num_possible_cpus(); in main()
1831 if (env.nr_cpus < 0) { in main()
1833 env.nr_cpus); in main()
1837 env.stdout_saved = stdout; in main()
1838 env.stderr_saved = stderr; in main()
1840 env.has_testmod = true; in main()
1841 if (!env.list_test_names) { in main()
1846 fprintf(env.stderr_saved, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n"); in main()
1847 env.has_testmod = false; in main()
1856 test->should_run = should_run(&env.test_selector, in main()
1866 test->should_tmon = should_tmon(&env.tmon_selector, test->test_name); in main()
1870 if (env.get_test_cnt || env.list_test_names) in main()
1871 env.workers = 0; in main()
1874 env.worker_id = -1; /* main process */ in main()
1875 if (env.workers) { in main()
1876 env.worker_pids = calloc(sizeof(pid_t), env.workers); in main()
1877 env.worker_socks = calloc(sizeof(int), env.workers); in main()
1878 if (env.debug) in main()
1879 fprintf(stdout, "Launching %d workers.\n", env.workers); in main()
1880 for (i = 0; i < env.workers; i++) { in main()
1894 env.worker_pids[i] = pid; in main()
1895 env.worker_socks[i] = sv[0]; in main()
1898 env.worker_id = i; in main()
1903 if (env.worker_id == -1) { in main()
1920 if (env.get_test_cnt) { in main()
1921 env.succ_cnt++; in main()
1925 if (env.list_test_names) { in main()
1926 fprintf(env.stdout_saved, "%s\n", test->test_name); in main()
1927 env.succ_cnt++; in main()
1934 if (env.get_test_cnt) { in main()
1935 printf("%d\n", env.succ_cnt); in main()
1939 if (env.list_test_names) in main()
1942 calculate_summary_and_print_errors(&env); in main()
1944 close(env.saved_netns_fd); in main()
1946 if (!env.list_test_names && env.has_testmod) in main()
1949 free_test_selector(&env.test_selector); in main()
1950 free_test_selector(&env.subtest_selector); in main()
1951 free_test_selector(&env.tmon_selector); in main()
1954 if (env.succ_cnt + env.fail_cnt + env.skip_cnt == 0) in main()
1957 return env.fail_cnt ? EXIT_FAILURE : EXIT_SUCCESS; in main()