?? tests.c
字號:
******************************************************************************/ats_start_test(testname, devname)char *testname, *devname;{ int test_id; int group_id; int id; for (test_id=0; test_id != exist_tests; ++test_id) /* gone through all existing devices */ if (strcmp(devname, tests[test_id]->devname) == 0 && strcmp(testname, tests[test_id]->testname) == 0) break; if (test_id == exist_tests) /* unknown test */ { send_test_msg(SUNDIAG_ATS_ERROR, 0, testname, devname, "unknown test"); return; } if (tests[test_id]->type == 2) { send_test_msg(SUNDIAG_ATS_ERROR, 0, testname, devname, "disabled intervention test"); return; /* return if disabled intervention/manufacturing tests */ } if (!tty_mode) /* remove test slections mark */ (void)panel_set(select_item, PANEL_FEEDBACK, PANEL_NONE, 0); selection_flag = FALSE; if (tests[test_id]->enable == ENABLE) return; /* already enabled */ tests[test_id]->enable = ENABLE; if (tests[test_id]->test_no > 1) /* multiple tests */ { for (id=test_id; tests[id]->which_test != 1; --id); /* find the first test for this device */ if (!tty_mode) (void)panel_set(tests[id]->select, PANEL_TOGGLE_VALUE, 0, TRUE, 0); else display_enable(id, TRUE); for (; tests[id]->which_test != tests[id]->test_no; ++id) tests[id]->dev_enable = ENABLE; tests[id]->dev_enable = ENABLE; } else { if (!tty_mode) (void)panel_set(tests[test_id]->select, PANEL_TOGGLE_VALUE, 0, TRUE, 0); else display_enable(test_id, TRUE); } if (running == GO || running == SUSPEND) /* tests are running */ start_log(test_id); /* log to information file */ print_status(); /* display it */ group_id = tests[test_id]->group; /* update the group toggle too */ if (!groups[group_id].enable) { groups[group_id].enable = ENABLE; if (!tty_mode) (void)panel_set(groups[group_id].select, PANEL_TOGGLE_VALUE, 0, TRUE, 0); }}/****************************************************************************** * ats_stop_test was called when ATS tried to disselect a test by passing in * * the desired test name and device name. * * Input: testname, test name; devname, device name. * * Output: none. * ******************************************************************************/ats_stop_test(testname, devname)char *testname, *devname;{ int test_id; int group_id; int id, tmp; for (test_id=0; test_id != exist_tests; ++test_id) /* gone through all existing devices */ if (strcmp(devname, tests[test_id]->devname) == 0 && strcmp(testname, tests[test_id]->testname) == 0) break; if (test_id == exist_tests) /* unknown test */ { send_test_msg(SUNDIAG_ATS_ERROR, 0, testname, devname, "unknown test"); return; } if (!tty_mode) /* remove test slections mark */ (void)panel_set(select_item, PANEL_FEEDBACK, PANEL_NONE, 0); selection_flag = FALSE; if (tests[test_id]->enable == DISABLE) return; /* already disabled */ tests[test_id]->enable = DISABLE; if (tests[test_id]->test_no > 1) /* multiple tests */ { for (id=test_id; tests[id]->which_test != 1; --id); /* find the first test for this device */ for (tmp=id; tests[tmp]->which_test != tests[tmp]->test_no; ++tmp) if (tests[tmp]->enable) break; /* at least one is still enabled */ if (!tests[tmp]->enable) /* none was enabled now */ { if (!tty_mode) (void)panel_set(tests[id]->select, PANEL_TOGGLE_VALUE, 0, FALSE, 0); else display_enable(id, FALSE); for (; tests[id]->which_test != tests[id]->test_no; ++id) tests[id]->dev_enable = DISABLE; tests[id]->dev_enable = DISABLE; } } else { if (!tty_mode) (void)panel_set(tests[test_id]->select, PANEL_TOGGLE_VALUE, 0, FALSE, 0); else display_enable(test_id, FALSE); } if (tests[test_id]->pid == 0) /* test is not currently running */ print_status(); /* just remove it */ else (void)kill(tests[test_id]->pid, SIGINT); if (running == GO || running == SUSPEND) /* tests are running */ stop_log(test_id); /* log to information file */ group_id = tests[test_id]->group; test_id = groups[group_id].first; for (; test_id != exist_tests; ++test_id) { if (tests[test_id]->group != group_id) break; /* none was enabled */ if (tests[test_id]->dev_enable && (tests[test_id]->enable || tests[test_id]->test_no > 1) && tests[test_id]->type != 2) return; /* at least one is still enabled */ } if (groups[group_id].enable) { groups[group_id].enable = DISABLE; if (!tty_mode) (void)panel_set(groups[group_id].select, PANEL_TOGGLE_VALUE, 0, FALSE, 0); }}/****************************************************************************** * Initialize the group select toggle on the control subwindow. * * Input: group_id, the internal group number of the group to be initialized. * * Output: none. * ******************************************************************************/static init_group_tog(group_id)int group_id; /* group number, index to groups[] */{ Panel_item handle; handle = panel_create_item(sundiag_control, PANEL_TOGGLE, PANEL_CHOICE_STRINGS, groups[group_id].c_label, 0, PANEL_TOGGLE_VALUE, 0, groups[group_id].enable, PANEL_NOTIFY_PROC, group_sel_proc, PANEL_CLIENT_DATA, group_id, PANEL_ITEM_X, ATTR_COL(GROUP_COL), PANEL_ITEM_Y, ATTR_ROW(start_row++), PANEL_SHOW_MENU, FALSE, 0); groups[group_id].select = handle; /* keep the panel item handle */}/****************************************************************************** * Initialize the test select toggle on the control subwindow. * * Input: test_id, the internal test number of the group to be initialized. * * Output: none. * ******************************************************************************/static init_test_tog(test_id)int test_id; /* test number, index to tests[] */{ Panel_item handle; int toggle_value=0; if (tests[test_id]->test_no > 1) /* multiple tests */ { if (tests[test_id]->type != 2) /* it is not a disabled intervention tests */ toggle_value = tests[test_id]->dev_enable; else toggle_value = FALSE; } else toggle_value = (tests[test_id]->enable && tests[test_id]->type != 2); handle = panel_create_item(sundiag_control, PANEL_TOGGLE, PANEL_CHOICE_STRINGS, build_sel_label(test_id), 0, PANEL_TOGGLE_VALUE, 0, toggle_value, PANEL_NOTIFY_PROC, test_sel_proc, PANEL_CLIENT_DATA, test_id, PANEL_ITEM_X, ATTR_COL(SEL_COL), PANEL_ITEM_Y, ATTR_ROW(start_row++), PANEL_SHOW_MENU, FALSE, 0); tests[test_id]->select = handle; /* keep the panel item handle */}/****************************************************************************** * opt_sel_proc, option button notify procedure. * ******************************************************************************//*ARGSUSED*/static opt_sel_proc(item, value, event)Panel_item item;int value;Event *event;{ int test_id; Panel panel_handle; test_id = (int)panel_get(item, PANEL_CLIENT_DATA); /* get the internal test number of the test */ if (tests[test_id]->popup) /* option popup is really needed */ { if (option_frame != NULL) /* destroy the old one, if there is one */ frame_destroy_proc(option_frame); option_frame = window_create(sundiag_frame, FRAME, FRAME_SHOW_LABEL, TRUE, WIN_X, (int)((STATUS_WIDTH+PERFMON_WIDTH)*frame_width)+15, WIN_Y, 20, FRAME_DONE_PROC, frame_destroy_proc, 0); panel_handle = init_opt_panel(test_id); /* initialize rest of the control subwindow */ /* return popup panel's handle */ window_fit(panel_handle); window_fit(option_frame); (void)window_set(option_frame, WIN_SHOW, TRUE, 0); }}/****************************************************************************** * Initialize the test option button on the control subwindow. * * Input: test_id, the internal test number of the option button to be * * initialized. * * Output: none. * ******************************************************************************/static init_opt_button(test_id)int test_id; /* index to tests[] */{ Panel_item handle; int cur_row; cur_row = (int)panel_get(tests[test_id]->select, PANEL_ITEM_Y) + 2; /* get the row to display the option button on */ if (tests[test_id]->popup) /* check whether the option popup is needed */ { handle = panel_create_item(sundiag_control, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(sundiag_control, "Option", 6, (Pixfont *)NULL), PANEL_NOTIFY_PROC, opt_sel_proc, PANEL_ITEM_X, ATTR_COL(OPT_COL), PANEL_ITEM_Y, cur_row, PANEL_CLIENT_DATA, test_id, 0); tests[test_id]->option = handle; }}/****************************************************************************** * test_items() creates and initializes all of the select toggles on control * * panel. * ******************************************************************************/test_items(){ int group, i; /* current group id(index to groups[] */ int cur_test_i; /* current test index(to tests[]) */ for (i=0; i != ngroups; ++i) groups[i].enable = DISABLE; for (cur_test_i=0; cur_test_i != exist_tests; ++cur_test_i) /* gone through all existing devices */ { group = tests[cur_test_i]->group; /* get the current group */ if (tests[cur_test_i]->dev_enable && (tests[cur_test_i]->enable || tests[cur_test_i]->test_no > 1) && tests[cur_test_i]->type != 2) groups[group].enable = ENABLE; } if (!tty_mode) { for (cur_test_i=0; cur_test_i != exist_tests;) /* gone through all existing devices */ { group = tests[cur_test_i]->group; /* get the current group */ groups[group].first = cur_test_i; /* keep the first test in the group */ init_group_tog(group); /* display the group's toggle item */ while (tests[cur_test_i]->group == group) { if (tests[cur_test_i]->which_test == 1) { init_test_tog(cur_test_i); /* display the test's select toggle item */ /* also initialize the selection panel item handle */ init_opt_button(cur_test_i); /* display the test's option item(e.g. vmem wait time) if any */ /* also initialize the option panel item handle if needed */ } if (++cur_test_i == exist_tests) break; /* no more */ } } (void)scrollbar_paint(control_bar); /* update the bubble */ }}/****************************************************************************** * before_test(), checks to see whether the specified test can be run at this * * time. If not, return 1, otherwise, build the command line arguments(tail) * * according to the user-specified options. * * Input: test_id, internal test number. * * Output: 1, if failed; 0, if succeed. * * Also, command line arguments will be built in tests[]->tail. * ******************************************************************************/static int before_test(test_id){ static int done_clean[48]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* up to 16 tape drives for st, mt and xt */ static char opt_code[122]; char unit, *loopback, clock, rawtest_part, rawtest_size[10]; int type, T, i; static int vmem_waitvar; char dev_name[8], tmp_buf[82]; int sdlc; /* Sbus HSI test: sdlc or hdlc protocol */ int internal_loopback; /* interal loopback for Sbus HSI: 3-7 */ /* 3 = None * 4 = Simple * 5 = Clockless * 6 = Silent * 7 = Silent & Clockless */ /* stop testing if exceeded error limit/finished one pass for all tests */ if ((max_errors != 0 && sys_error >= max_errors) || (single_pass && sys_pass >= 1)) { stop_proc(); /* stop all tests */ return(1); /* do not start anymore tests */ } if (!run_error && tests[test_id]->error >= 1) return(1); /* this test has failed at least once and run-on-error is not enabled */ if (single_pass && tests[test_id]->pass >= 1) return(1); /* this test has been run more than once */ tests[test_id]->tail = opt_code; (void)strcpy(opt_code, "s "); /* pass "s" to tests as default */ switch (tests[test_id]->id) /* check which test it is */ { case MAGTAPE1: case MAGTAPE2: case SCSITAPE: if (tests[test_id]->id == MAGTAPE1) type = 1; else if (tests[test_id]->id == MAGTAPE2) type = 2; else type = 0; type = type*16; /* up to 16 drives per tape type */ if (!((int)tests[test_id]->data & 0x400) && ((unsigned)tests[test_id]->data>>16) != 0) if (tests[test_id]->pass != 0 && tests[test_id]->pass%((unsigned)tests[test_id]->data>>16) == 0) { /* it's time to clean the head */ if (!done_clean[tests[test_id]->unit+type]) /* user hasn't responded yet */ { if (!tty_mode) { sprintf(tmp_buf, "Clean the head of %s, then click \"Done\" to continue.", tests[test_id]->devname); (void)popup_info(tmp_buf, &done_clean[tests[test_id]->unit+type]); return(1); /* can't run it yet */ } else { sprintf(tmp_buf, "Clean the head of %s, then reselect the test.", tests[test_id]->devname); tty_message(tmp_buf); /* disable the test here */ tty_test_sel_proc(tests[test_id]->devname); done_clean[tests[test_id]->unit+type] = TRUE; return(1); /* can't run it yet */ } } else done_clean[tests[test_id]->unit+type] = FALSE; /* reset */ } if (tests[test_id]->conf->uval.tapeinfo.t_type == MT_ISEXABYTE) { (int)tests[test_id]->data |= 0x200; /* always skip retension */ (int)tests[test_id]->data &= 0xffffff7f; /* always disable recon */ }#ifdef NEW if (tests[test_id]->conf->uval.tapeinfo.t_type == MT_ISEXB8500) { (int)tests[test_id]->data |= 0x200; /* always skip retension */ (int)tests[test_id]->data &= 0xffffff7f; /* always disable recon */ }#endif NEW (void)sprintf(opt_code, "s D=/dev/r%s op=%d", tests[test_id]->devname, (int)tests[test_id]->data); if ((((int)tests[test_id]->data & 0x18) >> 3) == 1) /* specified */ (void)sprintf(opt_code, "%s b=%u", opt_code, (unsigned)(tests[test_id]->special)); break;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -