📄 tests.c
字号:
type = (( (int)tests[test_id]->data & 0xf0000) >> 16); /* Parity */ switch (type) { case 0: strcat(opt_code, " P=none"); /* none */ break; case 1: strcat(opt_code, " P=odd"); /* odd */ break; case 2: strcat(opt_code, " P=even"); /* even */ break; default: strcat(opt_code, " P=none"); break; } type = (( (int)tests[test_id]->data & 0xf00000) >> 20); /* flow ctl */ switch (type) { case 0: strcat(opt_code, " F=xonoff"); break; case 1: strcat(opt_code, " F=rtscts"); break; case 2: strcat(opt_code, " F=both"); break; default: strcat(opt_code, " F=rtscts"); break; } type = (( (int)tests[test_id]->data & 0xf0000000) >> 28); /* pattern */ switch (type) { case 0: strcat(opt_code, " I=5"); break; case 1: strcat(opt_code, " I=a"); break; case 2: strcat(opt_code, " I=r"); break; default: strcat(opt_code, " I=5"); break; } /* printf("spiftest Command args= %s\n", opt_code); */ break; case HSI: if ((int)tests[test_id]->data & 16) clock = 'e'; else clock = 'o'; unit = (int)tests[test_id]->data & 3; type = ((int)tests[test_id]->data & 12) >> 2; switch (unit) { case 0: /* 0, 2 */ case 1: /* 1, 3 */ unit += tests[test_id]->unit*2; switch (type) { case 1: (void)sprintf(opt_code, "s hss%c%dv", clock, unit); break; case 2: (void)sprintf(opt_code, "s hss%c%dr,%c%dv", clock, unit, clock, unit); break; default: (void)sprintf(opt_code, "s hss%c%dr", clock, unit); break; } break; case 2: /* 0 1, 2 3 */ unit = tests[test_id]->unit*2; switch (type) { case 1: (void)sprintf(opt_code, "s hss%c%dv,%c%dv", clock, unit, clock, unit+1); break; case 2: (void)sprintf(opt_code, "s hss%c%dr,%c%dr,%c%dv,%c%dv", clock, unit, clock, unit+1, clock, unit, clock, unit+1); break; default: (void)sprintf(opt_code, "s hss%c%dr,%c%dr", clock, unit, clock, unit+1); break; } break; case 3: /* 0-1, 2-3 */ default: unit = tests[test_id]->unit*2; switch (type) { case 1: (void)sprintf(opt_code, "s hss%c%dv hss%c%dv", clock, unit, clock, unit+1); break; case 2: (void)sprintf(opt_code, "s hss%c%dr,%c%dv hss%c%dr,%c%dv", clock, unit, clock, unit, clock, unit+1, clock, unit+1); break; case 3: (void)sprintf(opt_code, "s hss%c%dr,%c%dv hss%c%dv,%c%dr", clock, unit, clock, unit, clock, unit+1, clock, unit+1); break; default: (void)sprintf(opt_code, "s hss%c%dr hss%c%dr", clock, unit, clock, unit+1); break; } break; } break; case SBUS_HSI: if ((int)tests[test_id]->data & 1) clock = 'e'; /* in order to use external clock source, the user */ else /* must physically loopback xmit & recv pins and*/ clock = 'o'; /* provide external clock source */ unit = ((int)tests[test_id]->data & 0x070) >> 4; /* loopback type */ internal_loopback = (((int)tests[test_id]->data & 2) >> 1); switch (unit) { case 0: /* 0, 4, 8 */ case 1: /* 1, 5, 9 */ case 2: /* 2, 6, 10 */ case 3: /* 3, 7, 11 */ unit += tests[test_id]->unit*4; (void)sprintf(opt_code, "s hih%c%d", clock, unit); break; case 4: /* 0 1 2 3 */ unit = tests[test_id]->unit*4; (void)sprintf(opt_code, "s hih%c%d,%c%d,%c%d,%c%d", clock, unit , clock, unit+1, clock, unit+2, clock, unit+3); break; case 5: /* 0-1, 2-3 */ default: unit = tests[test_id]->unit*4; (void)sprintf(opt_code,"s i%d hih%c%d,%c%d %s%c%d,%c%d", clock, unit , clock, unit+2, clock, unit+1, clock, unit+3); break; case 6: /* 0-2, 1-3 */ unit = tests[test_id]->unit*4; (void)sprintf(opt_code,"s i%d hih%c%d,%c%d %s%c%d,%c%d", clock, unit , clock, unit+1, clock, unit+2, clock, unit+3); break; case 7: /* 0-3, 1-2 */ unit = tests[test_id]->unit*4; (void)sprintf(opt_code,"s i%d hih%c%d,%c%d %s%c%d,%c%d", clock, unit , clock, unit+1, clock, unit+3, clock, unit+2); break; } if (internal_loopback) (void)strcat(opt_code, " I"); break; case PRINTER: (void)sprintf(opt_code, "s p%d", tests[test_id]->unit); break; case CG12: /* Egret graphic accelerator test */ (void)sprintf(opt_code, "s D=/dev/%s F=%d B=%d S=%d", tests[test_id]->devname, (int)tests[test_id]->data >> 12, (int)tests[test_id]->special, ~(int)tests[test_id]->data & 0x7FF); /* bit 1/0 == on/off */ break; case GT: /* Hawk graphic accelerator test */ (void)sprintf(opt_code, "s D=/dev/%s S=%d F=%d B=%d", tests[test_id]->devname, (int)tests[test_id]->data & 0x1FFFFF, (int)tests[test_id]->data >> 21, (int)tests[test_id]->special); /* bit 1/0 == on/off */ break; case MP4: /* Multiple processors (Galaxy) */ (void)sprintf(opt_code, "s T=%d C=%d", ~((int)tests[test_id]->data) & 0xf, (~(((int)tests[test_id]->data & 0xf0) >> 4)) & processors_mask); break; case ZEBRA1: /* Sbus bidirectional parallel (printer) port */ (void)sprintf(opt_code, "s D=/dev/%s W M=%s", tests[test_id]->devname, bpp_mode[(int)tests[test_id]->data >> 2]); break; case ZEBRA2: /* SBus serial video port */ (void)sprintf(opt_code, "s D=/dev/%s W M=%s I=%s R=%s", tests[test_id]->devname, lpvi_mode[((int)tests[test_id]->data & 0xC)>> 2], lpvi_image[((int)tests[test_id]->data & 0x30)>> 4], lpvi_resolution[((int)tests[test_id]->data & 0xC0)>> 6]); break; case USER: if (tests[test_id]->env != NULL) (void)strcat(opt_code, tests[test_id]->env); /* get command tail */ break; default: break; } if (core_file) (void)strcat(opt_code, " c"); /* generate core files */ if (single_pass) (void)strcat(opt_code, " p");/* single pass mode */ if (verbose) (void)strcat(opt_code, " v"); /* verbose mode */ if (trace) (void)strcat(opt_code, " t"); /* trace mode */ if (quick_test) (void)strcat(opt_code, " q"); /* quick test mode */ if (run_error) (void)strcat(opt_code, " r"); /* run_on_error mode */ return(0); /* the test is O.K. to be run */}/****************************************************************************** * after_test(), checks to see whether there is anything needs to be done to * * clean up after the specified test is done. * * Input: test_id, internal test number. * * Output: none. * ******************************************************************************/static int after_test(test_id){ switch (tests[test_id]->id) /* check which test it is */ { case VMEM: vmem_wait = elapse_count; /* remember when did VMEM exit */ break; case COLOR3: case COLOR4: case COLOR6: case COLOR8: fb_delay = FB_WAIT; /* delay at least FB_WAIT seconds before it can be restarted */ break; case COLOR2: case COLOR5: case COLOR9: case GP2: if (fb_inuse > 0) if (--fb_inuse == 0) fb_delay = FB_WAIT; /* delay at least FB_WAIT seconds before it can be restarted */ break; case ENET0: case ENET1: case ENET2: case OMNI_NET: case FDDI: case TRNET: net_flag = 0; /* allow others to start */ break; case MCP: case SCP2: mcp_flag[tests[test_id]->unit] = 0; /* reset the occupied flag */ break; case SCP: dcp_kernel[tests[test_id]->unit] = 1; /* don't need to load kernel next time */ break; default: /* nothing to be done */ break; }}/****************************************************************************** * The child process termination notify procedure, to be called when one of * * the forked tests exits. * ******************************************************************************//*ARGSUSED*/static Notify_value wait_child(me, pid, status, rusage)int *me;int pid;union wait *status;struct rusage *rusage;{ int idx; char tmp_msg[82]; char corename[82]; /* new name of the core file */ if (sundiag_done) return(NOTIFY_IGNORED); /* quitting sundiag */ /* Note: Could handle child stopping differently from child death */ /* Break out of notification loop */ if (WIFSTOPPED(*status)) return(NOTIFY_IGNORED); if ((idx = get_pid(pid)) == -1) { (void)sprintf(tmp_msg, pid_valid_error, pid); logmsg(tmp_msg, 2, PID_VALID_ERROR); /* "pid %d is not valid" */ return(NOTIFY_IGNORED); } else { if (status->w_coredump) { (void)sprintf(corename,"core.%s.XXXXXX",tests[idx]->testname); (void)mktemp(corename); /* make temporary file's name */ (void)sprintf(tmp_msg, core_dump_error, tests[idx]->devname, tests[idx]->testname, pid); /* "(%s) %s(pid %d) dumped core"*/ if (rename("core", corename) == 0) (void)sprintf(tmp_msg,"%s Core file= %s",tmp_msg,corename); logmsg(tmp_msg, 2, CORE_DUMP_ERROR); if (!ats_nohost) send_test_msg(SUNDIAG_ATS_ERROR, 0, tests[idx]->testname, tests[idx]->devname, tmp_msg); ++tests[idx]->error; /* increase the error count */ ++sys_error; error_display(); /* refresh total errors */ failed_log(idx); /* log pass and error counts */ } else if (status->w_termsig) { if (status->w_termsig != SIGTERM && status->w_termsig != SIGINT && status->w_termsig != SIGHUP) { (void)sprintf(tmp_msg, term_signal_error, /*"(%s) %s(pid %d) died due to signal %d."*/ tests[idx]->devname, tests[idx]->testname, pid, status->w_termsig); logmsg(tmp_msg, 2, TERM_SIGNAL_ERROR); if (!ats_nohost) send_test_msg(SUNDIAG_ATS_ERROR, 0, tests[idx]->testname, tests[idx]->devname, tmp_msg); ++tests[idx]->error; /* increase the error count */ ++sys_error; error_display(); /* refresh total errors */ failed_log(idx); /* log pass and error counts */ } } else if (status->w_retcode) { if (status->w_retcode != 98) /* == 98, if been killed */ { ++tests[idx]->error; /* increase the error count */ ++sys_error; error_display(); /* refresh total errors */ if (status->w_retcode == 97)/* RPC send_log_msg() failed */ { (void)sprintf(tmp_msg, send_message_error, /*"(%s) %s failed sending message to sundiag."*/ tests[idx]->devname, tests[idx]->testname); logmsg(tmp_msg, 2, SEND_MESSAGE_ERROR); /* log to INFO & ERROR files */ if (!ats_nohost) send_test_msg(SUNDIAG_ATS_ERROR, 0, tests[idx]->testname, tests[idx]->devname, tmp_msg); } else if (status->w_retcode == 94) /* RPC init failed */ { (void)sprintf(tmp_msg, rpcinit_error, /*"(%s) %s failed to initialize RPC."*/ tests[idx]->devname, tests[idx]->testname); logmsg(tmp_msg, 2, RPCINIT_ERROR); /* log to INFO & ERROR files */ if (!ats_nohost) send_test_msg(SUNDIAG_ATS_ERROR, 0, tests[idx]->testname, tests[idx]->devname, tmp_msg); } else if (status->w_retcode == 255) /* error in forking(lower 8 bits of -1) */ { (void)sprintf(tmp_msg, fork_error, tests[idx]->testname, tests[idx]->devname); /* "Failed forking %s for device (%s)" */ logmsg(tmp_msg, 2, FORK_ERROR); /* log to INFO & ERROR files */ if (!ats_nohost) send_test_msg(SUNDIAG_ATS_ERROR, 0, tests[idx]->testname, tests[idx]->devname, tmp_msg); } failed_log(idx); /* log pass and error counts */ } } else { ++tests[idx]->pass; /* increase the pass count */ if (!ats_nohost) send_start_stop(SUNDIAG_ATS_STOP, tests[idx]->testname, tests[idx]->devname, tests[idx]->pass); } tests[idx]->pid = 0; -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -