int main(void) { log_set_max_level(LOG_DEBUG); log_parse_environment(); log_open(); test_path_decode_unit(); test_path_get_unit(); test_path_get_user_unit(); test_path_get_session(); test_path_get_owner_uid(); test_path_get_slice(); test_path_get_user_slice(); TEST_REQ_RUNNING_SYSTEMD(test_get_paths()); test_proc(); TEST_REQ_RUNNING_SYSTEMD(test_escape()); test_controller_is_valid(); test_slice_to_path(); test_shift_path(); TEST_REQ_RUNNING_SYSTEMD(test_mask_supported()); TEST_REQ_RUNNING_SYSTEMD(test_is_cgroup_fs()); TEST_REQ_RUNNING_SYSTEMD(test_fd_is_cgroup_fs()); test_is_wanted_print(true); test_is_wanted_print(false); /* run twice to test caching */ test_is_wanted(); return 0; }
int SizeofDatum(enum Datum type) { int type_size; test_proc(); switch ( type ) { case Integer: type_size = PROC->I_size; break; case ShortInteger: type_size = PROC->IS_size; break; case Single: type_size = PROC->FSP_size; break; case Double: type_size = PROC->FP_size; break; case Byte: type_size = 1; break; case Half: type_size = 2; break; default: exit(-1);break; } return type_size; }
int run_test_process(ContextAttachCallBack * done, void * data) { #if defined(WIN32) char fnm[FILE_PATH_SIZE]; char cmd[FILE_PATH_SIZE]; int res = 0; STARTUPINFO si; PROCESS_INFORMATION prs; ContextAttachArgs * args; memset(&si, 0, sizeof(si)); memset(&prs, 0, sizeof(prs)); memset(fnm, 0, sizeof(fnm)); if (GetModuleFileName(NULL, fnm, sizeof(fnm)) == 0) { set_win32_errno(GetLastError()); return -1; } si.cb = sizeof(si); strcpy(cmd, "agent.exe -t"); if (CreateProcess(fnm, cmd, NULL, NULL, FALSE, CREATE_SUSPENDED | CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &prs) == 0) { set_win32_errno(GetLastError()); return -1; } args = (ContextAttachArgs *)loc_alloc(sizeof(ContextAttachArgs)); args->done = done; args->data = data; args->thread = prs.hThread; args->process = prs.hProcess; res = context_attach(prs.dwProcessId, done_context_attach, args, 0); if (res != 0) loc_free(args); return res; #elif defined(_WRS_KERNEL) int tid = taskCreate("tTcf", 100, 0, 0x4000, (FUNCPTR)test_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (tid == 0) return -1; taskStop(tid); taskActivate(tid); assert(taskIsStopped(tid)); return context_attach(tid, done, data, 0); #else /* Create child process to debug */ int pid = fork(); if (pid < 0) return -1; if (pid == 0) { int fd; if (context_attach_self() < 0) exit(1); fd = sysconf(_SC_OPEN_MAX); while (fd-- > 2) close(fd); if (tkill(getpid(), SIGSTOP) < 0) exit(1); test_proc(); exit(0); } return context_attach(pid, done, data, CONTEXT_ATTACH_SELF); #endif }
int main(void) { test_path_decode_unit(); test_path_get_unit(); test_path_get_user_unit(); test_path_get_session(); test_path_get_owner_uid(); TEST_REQ_RUNNING_SYSTEMD(test_get_paths()); test_proc(); TEST_REQ_RUNNING_SYSTEMD(test_escape()); test_controller_is_valid(); test_slice_to_path(); test_shift_path(); return 0; }
int main (void) { const gsl_multilarge_nlinear_trs **nlinear_trs[6]; const gsl_multilarge_nlinear_scale **nlinear_scales[3]; const gsl_multilarge_nlinear_trs **trs; const gsl_multilarge_nlinear_scale **scale; int fdtype; size_t i = 0; gsl_ieee_env_setup(); /* initialize arrays */ nlinear_trs[0] = &gsl_multilarge_nlinear_trs_lm; nlinear_trs[1] = &gsl_multilarge_nlinear_trs_lmaccel; nlinear_trs[2] = &gsl_multilarge_nlinear_trs_dogleg; nlinear_trs[3] = &gsl_multilarge_nlinear_trs_ddogleg; nlinear_trs[4] = &gsl_multilarge_nlinear_trs_cgst; nlinear_trs[5] = NULL; nlinear_scales[0] = &gsl_multilarge_nlinear_scale_levenberg; nlinear_scales[1] = &gsl_multilarge_nlinear_scale_more; nlinear_scales[2] = NULL; /* run testsuite over all parameter combinations */ for (trs = nlinear_trs[i]; trs != NULL; trs = nlinear_trs[++i]) { size_t j = 0; fprintf(stderr, "trs = %s\n", (*trs)->name); for (scale = nlinear_scales[j]; scale != NULL; scale = nlinear_scales[++j]) { for (fdtype = GSL_MULTILARGE_NLINEAR_FWDIFF; fdtype <= GSL_MULTILARGE_NLINEAR_CTRDIFF; ++fdtype) { test_proc(*trs, *scale, fdtype); } } } exit (gsl_test_summary ()); }
int __cdecl main(int argc, char *argv[]) { TEST_PARAMS params; if (argc != 4) { fprintf(stderr, "Usage: " APP_NAME " <number of ports> <packet size> <number of packets>\n"); exit(1); } memset(¶ms, 0, sizeof(params)); params.num_ports = atoi(argv[1]); params.pkt_len = atoi(argv[2]); params.pkt_count = atoi(argv[3]); params.detach = 1; params.queue = 1; params.dup_attach = 0; return test_proc(¶ms); }
int main(int argc, char **argv) { if (argc > 1) { if (!strcmp(argv[1], "v")) { Verbose = 1; } else if (!strcmp(argv[1], "test-stdout")) { test_stdout(); return EXIT_SUCCESS; } if (!strcmp(argv[1], "test-atexit")) { test_atexit(); return EXIT_SUCCESS; } } test_mem(); test_str(); test_sprintf(); test_math(); test_proc(); test_stdio(); test_file(); test_exit(); return EXIT_FAILURE; }
int tcf(void) { #else int main(int argc, char ** argv) { int c; int ind; int daemon = 0; const char * log_name = NULL; const char * log_level = NULL; #endif int interactive = 0; int print_server_properties = 0; const char * url = DEFAULT_SERVER_URL; Protocol * proto; TCFBroadcastGroup * bcg; ini_mdep(); ini_trace(); ini_events_queue(); ini_asyncreq(); #if defined(_WRS_KERNEL) progname = "tcf"; open_log_file("-"); log_mode = 0; #else progname = argv[0]; /* Parse arguments */ for (ind = 1; ind < argc; ind++) { const char * s = argv[ind]; if (*s != '-') { break; } s++; while ((c = *s++) != '\0') { switch (c) { case 'i': interactive = 1; break; case 't': #if ENABLE_RCBP_TEST test_proc(); #endif exit(0); break; case 'd': daemon = 1; break; case 'c': generate_ssl_certificate(); exit(0); break; case 'S': print_server_properties = 1; break; case 'h': show_help(); exit(0); case 'I': case 'l': case 'L': case 's': #if ENABLE_Plugins case 'P': #endif if (*s == '\0') { if (++ind >= argc) { fprintf(stderr, "%s: error: no argument given to option '%c'\n", progname, c); exit(1); } s = argv[ind]; } switch (c) { case 'I': idle_timeout = strtol(s, 0, 0); break; case 'l': log_level = s; parse_trace_mode(log_level, &log_mode); break; case 'L': log_name = s; break; case 's': url = s; break; #if ENABLE_Plugins case 'P': plugins_path = s; break; #endif } s = ""; break; default: fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c); show_help(); exit(1); } } } if (daemon && log_name != NULL && strcmp (log_name, LOG_NAME_STDERR) != 0) { fprintf(stderr, "%s: error: can only log to stderr when in daemon " "mode.\n", progname); exit (1); } if (daemon) become_daemon(); open_log_file(log_name); #endif bcg = broadcast_group_alloc(); proto = protocol_alloc(); /* The static services must be initialised before the plugins */ #if ENABLE_Cmdline if (interactive) ini_cmdline_handler(interactive, proto); #else if (interactive) fprintf(stderr, "Warning: This version does not support interactive mode.\n"); #endif ini_services(proto, bcg); #if !defined(_WRS_KERNEL) /* Reparse log level in case initialization cause additional * levels to be registered */ if (log_level != NULL && parse_trace_mode(log_level, &log_mode) != 0) { fprintf(stderr, "Cannot parse log level: %s\n", log_level); exit(1); } #endif if (ini_server(url, proto, bcg) < 0) { fprintf(stderr, "Cannot create TCF server: %s\n", errno_to_str(errno)); exit(1); } discovery_start(); if (print_server_properties) { ChannelServer * s; char * server_properties; assert(!list_is_empty(&channel_server_root)); s = servlink2channelserverp(channel_server_root.next); server_properties = channel_peer_to_json(s->ps); printf("Server-Properties: %s\n", server_properties); fflush(stdout); trace(LOG_ALWAYS, "Server-Properties: %s", server_properties); loc_free(server_properties); } #if ENABLE_SignalHandlers signal(SIGABRT, signal_handler); signal(SIGILL, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); #if defined(_WIN32) SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); AddVectoredExceptionHandler(1, VectoredExceptionHandler); #endif #endif /* ENABLE_SignalHandlers */ if (idle_timeout != 0) { add_channel_close_listener(channel_closed); check_idle_timeout(NULL); } /* Process events - must run on the initial thread since ptrace() * returns ECHILD otherwise, thinking we are not the owner. */ run_event_loop(); #if ENABLE_Plugins plugins_destroy(); #endif /* ENABLE_Plugins */ return 0; }
/* {...Insert an instruction*/ void make_inst(int PIPE, int OP, ...) { struct instruction *inst = new instruction; va_list ap; int i; int ivar; int argtype; int ignore_alloc; if (!inst) { perror("Malloc failed"); exit(0); } test_proc(); ignore_alloc = 0; if ((PIPE == STORPIPE && OP == SAVE_REG_EA) || (PIPE == LOADPIPE && OP == LOAD_REG_EA) || (PIPE == FSTRPIPE && OP == FSAVE_REG_EA) || (PIPE == FLODPIPE && OP == FLOAD_REG_EA)) { ignore_alloc = 1; } *inst = PROC->iset->instructions[PIPE][OP]; // Detect undefined instruction mnemonics if (inst->mnemonic == NULL && PROC->id < UNKNOWN) { fprintf(stderr, "Error: Undefined mnemonic. pipe=%d, op=%d.\n", PIPE, OP); abort(); } #if 0 /* DEBUGGING */ printf("make_inst,args: "); for (int k = 0; k < inst->narg; k++) printf("%d ", inst->args[k]); printf("\n"); #endif va_start(ap, OP); //printf("Info: make_inst: pipe=%d,op=%d,narg=%d\n", PIPE, OP, inst->narg); for (i = 0; i < inst->narg; i++) { /* MIC hack {... */ if (PROC->id == KNC || PROC->id == KNC_SINGLE) { /* Skip one argument if its value is already pre-set by create_*_instructions(). * At the moment this applies to scalar floating-point ops on MIC only: Vector * mask (args[1]) is already set. * This hack saves us modifying more than 150 make_inst() calls and adding * have_mic() switches. */ if ((PIPE == FMACPIPE || PIPE == FADDPIPE || PIPE == FMULPIPE || PIPE == FMOVPIPE) && (i == 1)) // NB: mask is args[1] { fprintf(stderr, "Info: %s: Skipped mask arg for scalar flop on MIC VPU: pipe=%d,op=%d\n", __FUNCTION__, PIPE, OP); ++i; } /* Some FSTOREs use mask which is the last arg, but which is not explicitly passed to make_inst(). Therefore we must break this loop in time for those stores. */ if (PIPE == FSTRPIPE && (OP == FSAVE_EA || OP == FSSAVE_EA) && i == (inst->narg - 1)) { fprintf(stderr, "Info: %s: Break before MIC mask (narg[%d]): pipe=%d,op=%d\n", __FUNCTION__, i, PIPE, OP); break; } } /* ...} MIC hack */ argtype = inst->argtypes[i]; switch (argtype) { case Fregs: ivar = va_arg(ap, int); if (ivar < 0 || ivar > PROC->fregs->regfile) { printf("Error: Invalid floating register %d arg %d\n", ivar, i); printf("instr: pipe=%d,code=%d\n", inst->pipe, inst->code); exit(0); } if (!(PROC->fregs->allocated[ivar]) && !ignore_alloc) { printf("Error: unallocated freg %d used operand %d\n", ivar, i); exit(0); } inst->args[i] = ivar; break; case Iregs: ivar = va_arg(ap, int); if (ivar < 0 || ivar > PROC->iregs->regfile) { printf("Error: Invalid register %d\n", ivar); printf("instr: pipe=%d,code=%d\n", inst->pipe, inst->code); exit(0); } if (!(PROC->iregs->allocated[ivar]) && !ignore_alloc) { printf("Error: unallocated reg %d used\n", ivar); printf("instr: pipe=%d,code=%d\n", inst->pipe, inst->code); exit(0); } inst->args[i] = ivar; break; case SIMM: /* Get one number argument */ ivar = va_arg(ap, int); if (abs(get_offset(ivar)) > 16000 ) { puts("Error: Immediate arg"); exit(0); } inst->args[i] = ivar; break; case UIMM: ivar = va_arg(ap, int); inst->args[i] = ivar; break; case Cycles: /* Get one number argument */ ivar = va_arg(ap, int); inst->args[i] = ivar; break; case Label: /* Get one number argument */ if (inst->pipe == DIRECTIVE) { if (inst->code == Target || inst->code == CmovTarget) { ivar = va_arg(ap, int); if (ivar >= nxtlab || ivar < 0) { puts("Error: Unknown Label"); exit(0); } inst->args[i] = ivar; } else if (inst->code == COMMENT) { if (sizeof(int) != sizeof(char *)) { fprintf(stderr, "Warning: Assembly comments hack might fail!\n"); } inst->args[0] = va_arg(ap, int); // pretty dirty HACK: interpret (char *) as (int) here and cast back to (char *) in directive_print_knc(). Should work fine if sizeof(int)==sizeof(void *). } else { inst->mnemonic = va_arg(ap, char *); } }
static int test_init(void) { test_proc(); return 0; }
int tcf(void) { #else int main(int argc, char ** argv) { int c; int ind; int daemon = 0; const char * log_name = NULL; const char * log_level = NULL; #endif int interactive = 0; int print_server_properties = 0; const char * url = DEFAULT_SERVER_URL; Protocol * proto; TCFBroadcastGroup * bcg; PRE_INIT_HOOK; ini_mdep(); ini_trace(); ini_events_queue(); ini_asyncreq(); PRE_THREADING_HOOK; #if defined(_WRS_KERNEL) progname = "tcf"; open_log_file("-"); log_mode = 0; #else progname = argv[0]; /* Parse arguments */ for (ind = 1; ind < argc; ind++) { char * s = argv[ind]; if (*s++ != '-') break; while (s && (c = *s++) != '\0') { switch (c) { case 'i': interactive = 1; break; case 't': #if ENABLE_RCBP_TEST test_proc(); #endif exit(0); break; case 'd': #if defined(_WIN32) || defined(__CYGWIN__) /* For Windows the only way to detach a process is to * create a new process, so we patch the -d option to * -D for the second time we get invoked so we don't * keep on creating new processes forever. */ s[-1] = 'D'; daemon = 2; break; case 'D': #endif daemon = 1; break; case 'c': generate_ssl_certificate(); exit(0); break; case 'S': print_server_properties = 1; break; case 'h': show_help(); exit(0); case 'I': #if ENABLE_Trace case 'l': #endif case 'L': case 's': case 'g': #if ENABLE_Plugins case 'P': #endif if (*s == '\0') { if (++ind >= argc) { fprintf(stderr, "%s: error: no argument given to option '%c'\n", progname, c); exit(1); } s = argv[ind]; } switch (c) { case 'I': idle_timeout = strtol(s, 0, 0); break; #if ENABLE_Trace case 'l': log_level = s; parse_trace_mode(log_level, &log_mode); break; #endif case 'L': log_name = s; break; case 's': url = s; break; #if ENABLE_DebugContext case 'g': if (ini_gdb_rsp(s) < 0) { fprintf(stderr, "Cannot create GDB server: %s\n", errno_to_str(errno)); exit(1); } break; #endif #if ENABLE_Plugins case 'P': plugins_path = s; break; #endif } s = NULL; break; default: ILLEGAL_OPTION_HOOK; fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c); show_help(); exit(1); } } } POST_OPTION_HOOK; if (daemon) { #if defined(_WIN32) || defined(__CYGWIN__) become_daemon(daemon > 1 ? argv : NULL); #else become_daemon(); #endif } open_log_file(log_name); #endif bcg = broadcast_group_alloc(); proto = protocol_alloc(); /* The static services must be initialised before the plugins */ #if ENABLE_Cmdline if (interactive) ini_cmdline_handler(interactive, proto); #else if (interactive) fprintf(stderr, "Warning: This version does not support interactive mode.\n"); #endif ini_services(proto, bcg); #if !defined(_WRS_KERNEL) /* Reparse log level in case initialization cause additional * levels to be registered */ if (log_level != NULL && parse_trace_mode(log_level, &log_mode) != 0) { fprintf(stderr, "Cannot parse log level: %s\n", log_level); exit(1); } #endif if (ini_server(url, proto, bcg) < 0) { fprintf(stderr, "Cannot create TCF server: %s\n", errno_to_str(errno)); exit(1); } discovery_start(); if (print_server_properties) { ChannelServer * s; char * server_properties; assert(!list_is_empty(&channel_server_root)); s = servlink2channelserverp(channel_server_root.next); server_properties = channel_peer_to_json(s->ps); printf("Server-Properties: %s\n", server_properties); fflush(stdout); trace(LOG_ALWAYS, "Server-Properties: %s", server_properties); loc_free(server_properties); } PRE_DAEMON_HOOK; #if !defined(_WRS_KERNEL) if (daemon) close_out_and_err(); #endif #if ENABLE_SignalHandlers signal(SIGABRT, signal_handler); signal(SIGILL, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); #if defined(_WIN32) || defined(__CYGWIN__) SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); AddVectoredExceptionHandler(1, VectoredExceptionHandler); #endif #endif /* ENABLE_SignalHandlers */ if (idle_timeout != 0) { add_channel_close_listener(channel_closed); check_idle_timeout(NULL); } /* Process events - must run on the initial thread since ptrace() * returns ECHILD otherwise, thinking we are not the owner. */ run_event_loop(); #if ENABLE_Plugins plugins_destroy(); #endif /* ENABLE_Plugins */ return 0; }