int wmain(int argc, wchar_t *argv[]) { if (argc < 3) { printf("usage: %ls <pid> (n_args args ...)+\n", argv[0]); return 0; } event_log = RegisterEventSourceW(NULL, PROVIDER_NAME); wait_for_parent(argv[1]); int arg_index = 2; while (arg_index < argc - 1) { unsigned long cmd_argc = wcstoul(argv[arg_index++], NULL, 10); if (cmd_argc == 0 || cmd_argc > argc - arg_index) { log_event(ERR_ARGS, "unexpected '%s' @ %d", argv[arg_index - 1], arg_index - 1); break; } else { wchar_t **cmd_argv = argv + arg_index; arg_index += cmd_argc; run_command((int)cmd_argc, cmd_argv, arg_index >= argc - 1); } } if (event_log != NULL) { DeregisterEventSource(event_log); } return 0; }
static int victim_child(union pipe read_pipe, union pipe write_pipe) { FAIL_IF(wait_for_parent(read_pipe)); /* Setup our EBB handler, before the EBB event is created */ ebb_enable_pmc_counting(1); setup_ebb_handler(standard_ebb_callee); ebb_global_enable(); FAIL_IF(notify_parent(write_pipe)); while (ebb_state.stats.ebb_count < 20) { FAIL_IF(core_busy_loop()); } ebb_global_disable(); ebb_freeze_pmcs(); count_pmc(1, sample_period); dump_ebb_state(); FAIL_IF(ebb_state.stats.ebb_count == 0); return 0; }
static void do_sleep(void) { wait_for_parent(); sleep(1); sleep(1); exit(4); }
static void do_fork(void) { int fork_pid, wait_pid; int status, i; wait_for_parent(); /* * Fork a kid. Keep track of the kid's pid, have the kid do_mkdir, * and wait for it. Compare the fork_pid with the wait_pid to be * sure they are the same. */ for (i = 0; i < 50; i++) { fork_pid = FORK_OR_VFORK(); if (fork_pid < 0) { tst_resm(TFAIL, "Fork failed"); tst_exit(); } if (fork_pid == 0) { #ifdef UCLINUX if (self_exec(argv0, "n", 5) < 0) { tst_resm(TFAIL, "do_fork self_exec failed"); tst_exit(); } #else do_mkdir(); #endif } errno = 0; while (((wait_pid = waitpid(fork_pid, &status, 0)) != -1) || (errno == EINTR)) { if (wait_pid == -1) continue; if (fork_pid != wait_pid) { tst_resm(TFAIL, "Didnt get a pid returned " "from waitpid that matches the one " "returned by fork"); tst_resm(TFAIL, "fork pid = %d, wait pid = " "%d", fork_pid, wait_pid); fail = 1; } } } exit(4); }
static int eat_cpu_child(union pipe read_pipe, union pipe write_pipe) { volatile int i = 0; /* * We are just here to eat cpu and die. So make sure we can be killed, * and also don't do any custom SIGTERM handling. */ signal(SIGTERM, SIG_DFL); notify_parent(write_pipe); wait_for_parent(read_pipe); /* Soak up cpu forever */ while (1) i++; return 0; }
static void do_compute(void) { int i; wait_for_parent(); for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; for (i = 0; i < 100000; i++) ; exit(4); }
static void do_exit(void) { wait_for_parent(); exit(3); }
void do_exit() { wait_for_parent(); exit(3); }
void do_exit() { wait_for_parent(); kill(getpid(), SIGSTOP); exit(3); }