⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tests.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	  if (temp <= 100) temp = 0;	  else	 	 temp = ((temp -1)/200) + 1;	  if (temp > 6) temp = 6;          (int)tmp_tests[j]->data &= ~0x70;          (int)tmp_tests[j]->data |= temp << 4;	  tmp_tests[++j] = make_test(test_no+1, dev_ptr->unit);			/* enable the read/write test too */	 	  break;	case SCSITAPE:	  temp = dev_ptr->u_tag.uval.tapeinfo.t_type;	/* get the tape type */	  if (temp == MT_ISEXABYTE)	    (int)tmp_tests[j]->data = 0x80060;#ifdef NEW	  else if (temp == MT_ISEXB8500)	    (int)tmp_tests[j]->data = 0x80060;#endif NEW	  else if (temp == MT_ISHP || temp == MT_ISKENNEDY)	    (int)tmp_tests[j]->data = 0x190043;	  else if (temp == MT_ISVIPER1 || temp == MT_ISWANGTEK1)	    (int)tmp_tests[j]->data = 0xa0040;		/* QIC-150 format */	  else (int)tmp_tests[j]->data = 0xa0042;	/* to be sure */	  break;        case MTI:        case MCP:	case SCSISP1:	case SCSISP2:	  tmp = malloc(sizeof(struct loopback));	  if (tmp_tests[j]->id == MCP)	  {	    (void)strcpy(((struct loopback *)tmp)->from, sp2_src);	    (void)strcpy(((struct loopback *)tmp)->to, sp2_des);	  }	  else if (tmp_tests[j]->id == MTI)	  {	    (void)strcpy(((struct loopback *)tmp)->from, sp_src);	    (void)strcpy(((struct loopback *)tmp)->to, sp_des);	  }	  else	  {	    (void)strcpy(((struct loopback *)tmp)->from, scsisp_src);	    (void)strcpy(((struct loopback *)tmp)->to, scsisp_des);	  }	  tmp_tests[j]->data = (caddr_t)tmp;	  if (tmp_tests[j]->id == MCP)	  {	    if (dev_ptr->u_tag.uval.devinfo.status == IFDDEVONLY)	    /* SunLink was installed */	    {	      tmp_tests[j] = make_test(test_no+2, dev_ptr->unit);	        /* SCP2 SunLink test, overwrite tty test*/	      tmp = malloc(sizeof(struct loopback));	      (void)strcpy(((struct loopback *)tmp)->from,				sunlink_src[tmp_tests[j]->unit]);	      (void)strcpy(((struct loopback *)tmp)->to,				sunlink_des[tmp_tests[j]->unit]);	      tmp_tests[j]->data = (caddr_t)tmp;	    }            if (dev_ptr->u_tag.uval.devinfo.status == MCPOK)              tmp_tests[++j] = make_test(test_no+1, dev_ptr->unit);                        /* also enable the MCP printer test */	  }	  break;        case SCP:	  tmp = malloc(sizeof(struct loopback));	  (void)strcpy(((struct loopback *)tmp)->from, sunlink_src[0]);	  (void)strcpy(((struct loopback *)tmp)->to, sunlink_des[0]);	  tmp_tests[j]->data = (caddr_t)tmp;	  break;	case COLOR2:	case TV1:		/* need 1MB of swap */	  cg2 = 1;	  break;	case COLOR3:	case COLOR4:	  cg4 = 1;	  break;	case COLOR5:#ifdef	sun386	  cg2 = 1;		/* using color test(not cg5test) */#else	sun386	  cg5 = 1;		/* double frame buffer boards */#endif	sun386	  break;	case COLOR6:		/* LEGO */	case COLOR8:		/* IBIS */	case COLOR9:		/* CRANE */	  ibis = 1;		/* IBIS board */	  break;	case GP2:	  gp2 = 1;	  break;	case CG12:	  cg12 = 1;	  break;	case GT:	  gttest = 1;	  break;	case ZEBRA2:		/* lpvi device (zebra board) */	  ++zebra;	  break;	case TAAC:	  taac = 1;		/* there's a taac board */	  break;	case IPC:	  if (ipcs == 0)			/* do followings only once */	  {	    (void)gethostname(buff, 80);		/* get the host name */	    tmp = malloc((unsigned)strlen(buff)+20);		/* make sure it is long enough */	    (void)sprintf(tmp, "SYSDIAG_HOST=%s", buff);	    (void)putenv(tmp);	    (void)sprintf(buff, "IPC_MSG_DIR=%s", LOG_DIR);	    tmp = malloc((unsigned)strlen(buff)+2);	    (void)strcpy(tmp, buff);	    (void)putenv(tmp);	  }	  ++ipcs;	  break;        default:	  break;      }      if ( (!ats_nohost && already_log == 0) || (config_file_only == TRUE && already_log == 0) )      {            if (tmp_tests[j]->unit == -1)	      (void)fprintf(conf_fp, "%s\t0\n", tmp_tests[j]->devname);            else	      (void)fprintf(conf_fp, "%s%d\t0\n", tmp_tests[j]->devname,							tmp_tests[j]->unit);      }      else	already_log = 0;    }    ++dev_ptr;  }  exist_tests = j+1;			/* total number of tests */  if (!ats_nohost || config_file_only == TRUE)    (void)fclose(conf_fp);  temp = 0;			/* used to keep track of # of "mt" devices */  for (i=0, k=0; i != TEST_NO; ++i)	/* sort the tests according to group */  {    if (tests_base[i].which_test > 1) continue;	/* skip "non-1st" tests */    for (j=0; j != exist_tests; ++j)      if (tmp_tests[j]->id == i)      {	if (i == MAGTAPE1) ++temp;	else if (i == MAGTAPE2) tmp_tests[j]->unit += temp;	tests[k++] = tmp_tests[j];		/* right spot for it */	if (tmp_tests[j]->test_no != 1)	/* should be followed by all tests for this device */	{	  do	  {		++j;		tests[k++] = tmp_tests[j];	  }	  while (tmp_tests[j]->which_test != tmp_tests[j]->test_no);	}      }  }  for (i=0 ; i != exist_tests; ++i)	/* build the unit # into device name */    if (tests[i]->unit != -1)      if (tests[i]->id != IDDISK1 && tests[i]->id != IDDISK2)        (void)sprintf(tests[i]->devname,			"%s%d", tests[i]->devname, tests[i]->unit);      else        (void)sprintf(tests[i]->devname,			"%s%03x", tests[i]->devname, tests[i]->unit);  if (!ats_nohost)  {    intervention = ENABLE;		/* defaults to enabling intervention */    for (i=0 ; i != exist_tests; ++i)	/* disable all tests */    {      tests[i]->enable = DISABLE;      if (tests[i]->test_no > 1)      /* more than one tests for this device */        tests[i]->dev_enable = DISABLE;      if (tests[i]->type == 2) tests[i]->type = 12;   /* enable intervention */    }  }  build_user_tests();  for (i=0; i != MAX_ARG; ++i)    child_arg[i] = NULL;		/* initialize the test arg's array */}/****************************************************************************** * Build the device label(english name + info.) for the device, which is to   * * be displayed in Control subwindow.					      * * Input: test_id, the internal test number of the test label to be built.    * * Output: none.							      * ******************************************************************************/char *build_sel_label(test_id)int	test_id;{  static char	label_buf[82];  switch (tests[test_id]->id)		/* depend on which test it is */  {    case SCSIDISK1:			/* multi-unit devices */    case XYDISK1:    case XDDISK1:    case IPIDISK1:    case SFDISK1:    case OBFDISK1:    case IPC:    case MCP:    case MAGTAPE1:    case MAGTAPE2:    case MTI:    case SCSITAPE:    case SCP:    case SCP2:    case HSI:    case SBUS_HSI:    case GT:    case PP:    case CDROM:	(void)sprintf(label_buf, "(%s) %s%d ",  tests[test_id]->devname,		tests[test_id]->label, tests[test_id]->unit);	break;    case IDDISK1:	(void)sprintf(label_buf, "(%s) %s%03x ",  tests[test_id]->devname,		tests[test_id]->label, tests[test_id]->unit);	break;    case SPIF:	(void)sprintf(label_buf, "(stc%d) %s%d ", tests[test_id]->unit, 		tests[test_id]->label, tests[test_id]->unit + 1); 	break;    default:	if (tests[test_id]->devname != NULL)	  (void)sprintf(label_buf, "(%s) %s",			tests[test_id]->devname, tests[test_id]->label);	else	  (void)strcpy(label_buf, tests[test_id]->label);	break;  }  return((char *)label_buf);}/****************************************************************************** * group_sel_proc, the panel notify procedure for the group selection toggle. * ******************************************************************************/static group_sel_proc(item, value)Panel_item item;int	value;{  int	group_id, test_id;  int	flag=0, iflag=0;  group_id = (int)panel_get(item, PANEL_CLIENT_DATA);  /* get the internal test number */  groups[group_id].enable = (value & 1);  test_id = groups[group_id].first;  /* get the first test number in the group */  while (test_id != exist_tests)	/* check the entire group */  {    if (tests[test_id]->group == group_id)    {      if (tests[test_id]->type != 2)/* if not the disabled intervention tests */      {        if (value & 1)		/* if the entire group is to be enabled */	{	  tests[test_id]->enable = TRUE;	  flag = 1;	  if (running == GO || running == SUSPEND)  /* if tests are running */	    start_log(test_id);	}        else			/* if the entire group is to be disabled */        {	  tests[test_id]->enable = FALSE;	  if (tests[test_id]->pid != 0)		/* test is currently running */	    (void)kill(tests[test_id]->pid, SIGINT);	  if (running == GO || running == SUSPEND)  /* if tests are running */	    stop_log(test_id);        }	if (tests[test_id]->which_test == 1)	/* the toggle item was only kept in the first test for the device */          (void)panel_set(tests[test_id]->select, PANEL_TOGGLE_VALUE,					0, tests[test_id]->enable, 0);	if (tests[test_id]->test_no > 1)	/* for device with more than one tests */	  tests[test_id]->dev_enable = tests[test_id]->enable;      }      else if (value & 1)	/* and to enable the entire group */	iflag = 1;      ++test_id;	/* next test in the group */    }    else	break;		/* done */  }  if ((value & 1) && flag == 0)		/* nothing got enabled */  {	(void)panel_set(groups[group_id].select,				PANEL_TOGGLE_VALUE, 0, FALSE, 0);	groups[group_id].enable = DISABLE;	if (iflag == 1) (void)confirm(	"The 'Intervention' mode was not enabled, no tests selected.", TRUE);  }  else  {    (void)panel_set(select_item, PANEL_FEEDBACK, PANEL_NONE, 0);    /* no test slections mark */    selection_flag = FALSE;    print_status();		/* update the status */  }}/****************************************************************************** * test_sel_proc, the panel notify procedure for the test selection toggle.   * ******************************************************************************/static test_sel_proc(item, value)Panel_item item;int	value;{  int	test_id;  int	group_id;  test_id = (int)panel_get(item, PANEL_CLIENT_DATA);  /* get the internal test number */  if (tests[test_id]->type == 2)  {	(void)panel_set(tests[test_id]->select,				PANEL_TOGGLE_VALUE, 0, FALSE, 0);	(void)confirm(	"Please enable the 'Intervention' mode before select this test.", TRUE);	return;	/* return if disabled intervention/manufacturing tests */  }  (void)panel_set(select_item, PANEL_FEEDBACK, PANEL_NONE, 0);  /* no test slections mark */  selection_flag = FALSE;  if (tests[test_id]->test_no > 1)    multi_tests(test_id, value);	/* handle multiple tests for a device */  else  {    tests[test_id]->enable = (value & 1);    if (tests[test_id]->enable)		/* if test is to be enabled */    {      print_status();			/* display it on status subwindow */      if (running == GO || running == SUSPEND)	/* if tests are running */        start_log(test_id);		/* log to information file */    }    else				/* if test is to be disabled */    {      if (tests[test_id]->pid == 0)	/* if test is not currently running */	print_status();			/* just remove it */      else	(void)kill(tests[test_id]->pid, SIGINT);      if (running == GO || running == SUSPEND)	/* if tests are running */        stop_log(test_id);		/* log to information file */    }  }  group_id = tests[test_id]->group;	/* get the group number of the test */  test_id = groups[group_id].first;	/* get the first test in the group */  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)    {	if (!groups[group_id].enable)	{	  groups[group_id].enable = TRUE;	  (void)panel_set(groups[group_id].select, PANEL_TOGGLE_VALUE,					0, TRUE, 0);	}	return;				/* done */    }  }  if (groups[group_id].enable)  {    groups[group_id].enable = FALSE;    (void)panel_set(groups[group_id].select, PANEL_TOGGLE_VALUE,					0, FALSE, 0);  }}/****************************************************************************** * ats_start_test was called when ATS tried to select a test by passing in    * * the desired test name and device name.				      * * Input: testname, test name; devname, device name.			      * * Output: none.							      *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -