📄 opfile.c
字号:
#ifndef lintstatic char sccsid[] = "@(#)opfile.c 1.1 92/07/30 Copyright Sun Micro";#endif/* * Copyright (c) 1987 by Sun Microsystems, Inc. */#include "sundiag.h"#include "../../lib/include/probe_sundiag.h"#include "struct.h"#ifndef sun386#include <sys/mtio.h>#else#include "mtio.h"#endif#include <sys/file.h>#include "sundiag_msg.h"extern char run_time_file[];extern long runtime;extern char *vmem_waittime[];extern char audbri_ref_file[];extern char *strtok(), *fgets(), *malloc();extern char *strcpy(), *sprintf();static char *enable="enable";static char *disable="disable";/****************************************************************************** * system_select(), selects the tests according to specification. * * Input: value, could be SEL_DEF, SEL_NON, or SEL_ALL. * * Output: none. * ******************************************************************************/static void system_select(value)int value;{ int test_id, group_id; if (!tty_mode) (void)panel_set(select_item, PANEL_VALUE, value, 0); switch (value) { case SEL_DEF: /* disable all the tests first */ group_id = -1; /* initialize the id(to flag the first group) */ for (test_id=0; test_id != exist_tests; ++test_id) { if (tests[test_id]->type == 2) continue; /* skip this */ if (group_id != tests[test_id]->group) /* clear the group too */ { group_id = tests[test_id]->group; /* save it for next */ groups[group_id].enable = FALSE; } tests[test_id]->enable = FALSE; if (tests[test_id]->test_no > 1) { tests[test_id]->dev_enable = FALSE; if (tests[test_id]->which_test > 1) continue; } } for (test_id=0; test_id != exist_tests; ++test_id) { if (tests[test_id]->type == 0) /* this is a default test */ { group_id = tests[test_id]->group; if (!groups[group_id].enable) groups[group_id].enable = TRUE; tests[test_id]->enable = TRUE; if (tests[test_id]->test_no > 1) tests[test_id]->dev_enable = TRUE; } } break; case SEL_NON: group_id = -1; /* initialize the id(to flag the first group) */ for (test_id=0; test_id != exist_tests; ++test_id) { if (tests[test_id]->type == 2) continue; /* skip this */ if (group_id != tests[test_id]->group) /* clear the group too */ { group_id = tests[test_id]->group; /* save it for next */ groups[group_id].enable = FALSE; } tests[test_id]->enable = FALSE; if (tests[test_id]->test_no > 1) tests[test_id]->dev_enable = DISABLE; } break; case SEL_ALL: group_id = -1; /* initialize the id(to flag the first group) */ for (test_id=0; test_id != exist_tests; ++test_id) { if (tests[test_id]->type == 2) continue; /* skip this */ if (group_id != tests[test_id]->group) /* set the group too */ { group_id = tests[test_id]->group; /* save it for next */ groups[group_id].enable = TRUE; } tests[test_id]->enable = TRUE; if (tests[test_id]->test_no > 1) tests[test_id]->dev_enable = ENABLE; } break; default: break; }}/****************************************************************************** * store_system_options(), store the system-wide options to the specified * * file. * * Input: opt_fp, the file pointer of the file to be stored to. * * Output: none. * ******************************************************************************/static void store_system_options(opt_fp)FILE *opt_fp;{ char *temp; (void)fprintf(opt_fp, "\n#Followings are system options:\n"); switch (select_value) { case 1: temp = "none"; break; case 2: temp = "all"; break; default: temp = "default"; } (void)fprintf(opt_fp, "option test_selections %s\n", temp); (void)fprintf(opt_fp, "option selection_flag %s\n", selection_flag?enable:disable); (void)fprintf(opt_fp, "option intervention %s\n", intervention?enable:disable); (void)fprintf(opt_fp, "option core_files %s\n", core_file?enable:disable); (void)fprintf(opt_fp, "option single_pass %s\n", single_pass?enable:disable); (void)fprintf(opt_fp, "option quick_test %s\n", quick_test?enable:disable); (void)fprintf(opt_fp, "option verbose %s\n", verbose?enable:disable); (void)fprintf(opt_fp, "option trace %s\n", trace?enable:disable); (void)fprintf(opt_fp, "option auto_start %s\n", auto_start?enable:disable); (void)fprintf(opt_fp, "option schedule_file %s\n", schedule_file?enable:disable); (void)fprintf(opt_fp, "option runtime %s\n", run_time_file); (void)fprintf(opt_fp, "option run_on_error %s\n", run_error?enable:disable); (void)fprintf(opt_fp, "option max_passes %d\n", max_sys_pass); (void)fprintf(opt_fp, "option max_errors %d\n", max_errors); (void)fprintf(opt_fp, "option concurrent_tests %d\n", max_tests); (void)fprintf(opt_fp, "option send_email %s\n", send_email==1?"on_error": (send_email==2?"periodically": (send_email==3?"both":disable))); (void)fprintf(opt_fp, "option log_period %d\n", log_period); (void)fprintf(opt_fp, "option email_address %s\n", eaddress); (void)fprintf(opt_fp, "option printer_name %s\n", printer_name);}/****************************************************************************** * load_system_options(), load the system-wide options from the specified * * file. * * Input: param, parsed option tokens. * * Output: none. * ******************************************************************************/load_system_options(param)char *param[];{ int endis=9; int i; if (strcmp(param[2], enable) == 0) endis = 1; else if (strcmp(param[2], disable) == 0) endis = 0; if (strcmp(param[1], "intervention") == 0) { if (endis < 2 && intervention != endis) { intervention = endis; if (intervention) { for (i=0 ; i != exist_tests; ++i) if (tests[i]->type == 2) tests[i]->type = 12; /* enable intervention */ } else { for (i=0 ; i != exist_tests; ++i) if (tests[i]->type == 12) tests[i]->type = 2; /* disable intervention */ } if (!tty_mode) (void)panel_set(mode_item, PANEL_VALUE, intervention, 0); } } else if (strcmp(param[1], "test_selections") == 0) { if (strcmp(param[2], "default") == 0) select_value = 0; else if (strcmp(param[2], "all") == 0) select_value = 2; else select_value = 1; system_select(select_value); } else if (strcmp(param[1], "selection_flag") == 0) selection_flag = (endis<2 ? endis : selection_flag); else if (strcmp(param[1], "core_files") == 0) core_file = (endis<2 ? endis : core_file); else if (strcmp(param[1], "single_pass") == 0) single_pass = (endis<2 ? endis : single_pass); else if (strcmp(param[1], "quick_test") == 0) quick_test = (endis<2 ? endis : quick_test); else if (strcmp(param[1], "verbose") == 0) verbose = (endis<2 ? endis : verbose); else if (strcmp(param[1], "trace") == 0) trace = (endis<2 ? endis : trace); else if (strcmp(param[1], "auto_start") == 0) auto_start = (endis<2 ? endis : auto_start); else if (strcmp(param[1], "schedule_file") == 0) schedule_file = (endis<2 ? endis : schedule_file); else if (strcmp(param[1], "runtime") == 0) { /* Since delimiter interfears with our format, rebuild it */ strcpy(run_time_file, param[2]); strcat(run_time_file, ":"); strcat(run_time_file, param[3]); strcat(run_time_file, ":"); strcat(run_time_file, param[4]); runtime = get_run_time(); } else if (strcmp(param[1], "run_on_error") == 0) run_error = (endis<2 ? endis : run_error); else if (strcmp(param[1], "max_passes") == 0) max_sys_pass = atoi(param[2]); else if (strcmp(param[1], "max_errors") == 0) max_errors = atoi(param[2]); else if (strcmp(param[1], "concurrent_tests") == 0) { max_tests = atoi(param[2]); set_max_tests(max_tests); } else if (strcmp(param[1], "send_email") == 0) { if (strcmp(param[2], "on_error") == 0) send_email = 1; else if (strcmp(param[2], "periodically") == 0) send_email = 2; else if (strcmp(param[2], "both") == 0) send_email = 3; else send_email = 0; } else if (strcmp(param[1], "log_period") == 0) log_period = atoi(param[2]); else if (strcmp(param[1], "email_address") == 0) strcpy(eaddress, param[2]); else if (strcmp(param[1], "printer_name") == 0) (void)strcpy(printer_name, param[2]);}/****************************************************************************** * store_test_options(), store the individual test options to the specified * * file. * * Input: opt_fp, the file pointer of the file to be stored to. * * Output: none. * ******************************************************************************/static void store_test_options(opt_fp)FILE *opt_fp;{ int i, j, num, b; char *temp; (void)fprintf(opt_fp, "\n#Followings are individual test options:\n"); for (i=0; i != exist_tests; ++i) /* go through the entire test structure */ { (void)fprintf(opt_fp, "%s %s %s %s", tests[i]->devname, tests[i]->testname, tests[i]->enable?"on":"off", tests[i]->dev_enable?"on":"off"); switch (tests[i]->id) /* depend on which test it is */ { case VMEM: (void)fprintf(opt_fp, " wait_time:%s", vmem_waittime[(int)tests[i]->data]); (void)fprintf(opt_fp, " reserve:%d\n", (int)tests[i]->special); break; case AUDIO: if (tests[i]->conf->uval.devinfo.status == 0) { (void)fprintf(opt_fp, " audio_output:%s", ((int)tests[i]->data&1)?"jack":"speaker"); (void)fprintf(opt_fp, " volume:%d\n", (int)tests[i]->special); } else { (void)fprintf(opt_fp, " audbri_loopback:%s audbri_type:%d audbri_calib:%s audbri_crystal:%s audbri_controls:%s audbri_audio:%s audbri_ref_file:%s\n", (int)tests[i]->data&0x4?enable:disable, (int)tests[i]->data&0x1, (int)tests[i]->data&0x8?enable:disable, (int)tests[i]->data&0x10?enable:disable, (int)tests[i]->data&0x20?enable:disable, (int)tests[i]->data&0x40?enable:disable, (int)tests[i]->special); } break; case ENET0: case ENET1: case ENET2: case OMNI_NET: case FDDI: case TRNET: (void)fprintf(opt_fp, " spray:%s delay:%d warning:%s\n", ((int)tests[i]->data&1)?enable:disable, (int)tests[i]->special, ((int)tests[i]->data&2)?enable:disable); break; case CPU_SP: switch ((int)tests[i]->data) { case 0: temp = "a"; break; case 1: temp = "b"; break; case 2: temp = "ab"; break; default: temp = "a-b"; } (void)fprintf(opt_fp, " loopback:%s\n", temp); break; case CPU_SP1: switch ((int)tests[i]->data) { case 0: temp = "c"; break; case 1: temp = "d"; break; case 2: temp = "cd"; break; default: temp = "c-d"; } (void)fprintf(opt_fp, " loopback:%s\n", temp); break; case CDROM: switch ((int)tests[i]->data & 7) { case 1: temp = "sony2"; break; case 2: temp = "hitachi4"; break; case 3: temp = "pdo"; break; case 4: temp = "other"; break; default: temp = "cdassist"; } (void)fprintf(opt_fp, " cdtype:%s data1:%s data2:%s audiotest:%s volume:%d datatrack:%d readmode:%s\n", temp, (int)tests[i]->data&8?disable:enable, (int)tests[i]->data&0x40?disable:enable, (int)tests[i]->data&0x10?disable:enable, (int)tests[i]->special, (int)tests[i]->data>>8, (int)tests[i]->data&0x20?"sequential":"random"); break; case SCSIDISK1: case XYDISK1: case XDDISK1: case IPIDISK1: case IDDISK1: case SFDISK1: case OBFDISK1: (void)fprintf(opt_fp, " rawtest_mode:%s", (int)tests[i]->data&0x8?"write_read" : "readonly" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -