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

📄 status.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
 * Update the pass and error count for the test. Also, update the "system     * * status" and "System passes" if necessary.				      * * Input: test_id, the internal test i.d. of the test.			      * ******************************************************************************/update_status(test_id)int	test_id;{  int	least;  int	i, x, y;  if (tests[test_id]->msg == NULL) return;  /* invalid handle(not on screen) */  if (!tty_mode)    (void)panel_set(tests[test_id]->msg, PANEL_LABEL_STRING,				build_status_label(test_id), 0);	  else  {    x = (int)tests[test_id]->msg & 0xff;	/* row # */    y = (int)tests[test_id]->msg >> 8;		/* page # */    (void)mvwaddstr(tty_status[y], x, STATUS_1, build_status_label(test_id));    if (window_type == STATUS_TTY && status_index == y)      (void)wrefresh(tty_status[y]);  }  if (!fail_flag)		/* no test failed yet */    if (tests[test_id]->error != 0)    {	fail_flag = 1;		/* at least one failed now */	status_display();	/* show it by updating the "System status" */    }  if (tests[test_id]->pass == sys_pass+1)	/* the bottleneck */  {    least = sys_pass+1;    for (i=0; i != exist_tests; ++i)      if (((tests[i]->enable && tests[i]->dev_enable) || tests[i]->pid != 0) &&           tests[i]->type != 2)      /* only if it is enabled or still running(after been killed) */        if (least > tests[i]->pass) least = tests[i]->pass;    if (least != sys_pass)    {      sys_pass = least;      pass_display();		/* update the "System passes" */    }  }  if (tty_mode && window_type == STATUS_TTY)  {    (void)wrefresh(status_button);    (void)refresh();		/* restore the cursor */  }}/****************************************************************************** * Update the pass and error count of all enabled tests.		      * ******************************************************************************/print_status(){  Panel_item	item;  int	group;				/* current group id(index to groups[] */  int	cur_test_i;			/* current test index(to tests[]) */  fail_flag = 0;			/* reinitialize the flag */  sys_error = 0;  sys_pass = 0;  if (tty_mode)  {    status_page = 0;    status_row = 0;    (void)wclear(tty_status[0]);  }  if (tty_mode || start_status_row != START_ROW)  /* need to clear the old status first */  {    for (cur_test_i=0; cur_test_i != ngroups; ++cur_test_i)      if ((item=groups[cur_test_i].msg) != NULL)      {	groups[cur_test_i].msg = NULL;	if (!tty_mode)	{	  (void)panel_set(item, PANEL_SHOW_ITEM, FALSE, 0);/* erase it first */	  (void)panel_destroy_item(item);	}      }    for (cur_test_i=0; cur_test_i != exist_tests; ++cur_test_i)      if ((item=tests[cur_test_i]->msg) != NULL)      {	tests[cur_test_i]->msg = NULL;	if (!tty_mode)	{	  (void)panel_set(item, PANEL_SHOW_ITEM, FALSE, 0);/* erase it first */	  (void)panel_destroy_item(item);	}      }    start_status_row = START_ROW;  }  for (cur_test_i=0; cur_test_i != exist_tests;)					/* gone through all existing devices */  {    if (((tests[cur_test_i]->enable && tests[cur_test_i]->dev_enable) ||		tests[cur_test_i]->pid != 0) && tests[cur_test_i]->type != 2)		/* only if it is enabled or still running(after been killed) */    {      if (sys_pass == 0) sys_pass = tests[cur_test_i]->pass;      group = tests[cur_test_i]->group;	/* get the current group */      init_group_status(group);		/* display the group's status label */      while (tests[cur_test_i]->group == group)      {	if (((tests[cur_test_i]->enable && tests[cur_test_i]->dev_enable) ||		tests[cur_test_i]->pid != 0) && tests[cur_test_i]->type != 2)		/* only if it is enabled or still running(after been killed) */	{	  init_test_status(cur_test_i);		/* display the test's msg item */		/* also initialize the msg item handle */	  sys_error += tests[cur_test_i]->error;	  if (sys_pass > tests[cur_test_i]->pass)	    sys_pass = tests[cur_test_i]->pass;		/* get the smallest */	  if (!fail_flag)	    if (tests[cur_test_i]->error != 0)	      fail_flag = 1;		/* at least one failed now */	}	if (++cur_test_i == exist_tests) break;		/* no more */      }    }    else	++cur_test_i;  }  if (tty_mode)    status_max = status_page;  status_display();			/* display the testing status line */  pass_display();			/* display system pass count */  error_display();			/* display total errors */  if (tty_mode && window_type == STATUS_TTY)  {    (void)wrefresh(status_button);    (void)wrefresh(tty_status[status_index]);    (void)refresh();			/* restore the cursor */  }  if (!tty_mode)  {    item = panel_create_item(sundiag_status, PANEL_MESSAGE,		PANEL_SHOW_ITEM,	FALSE,		PANEL_ITEM_X,		ATTR_COL(SEL_COL),		PANEL_ITEM_Y,		ATTR_ROW(start_status_row),		0);    (void)scrollbar_set(status_bar, SCROLL_OBJECT_LENGTH,		(int)panel_get(item, PANEL_ITEM_Y)-1, 0);    (void)scrollbar_paint(status_bar);	/* update the bubble */    (void)panel_destroy_item(item);  }}/****************************************************************************** * Logs the current test status to INFO file(including "System passes", and   * * "Total errors").							      * ******************************************************************************/log_status(){  int	cur_test_i;  char	*temp;  unsigned hour, minute, second;  second = elapse_count%60;  minute = elapse_count/60;  hour = minute/60;  minute = minute%60;  if (fprintf(info_fp,	" System passes: %d, Total errors: %d, Elapsed time: %03d:%02d:%02d\n",		sys_pass, sys_error, hour, minute, second) == EOF)  {    perror("Writing log file");    return;  }  for (cur_test_i=0; cur_test_i != exist_tests; ++cur_test_i)  {    if (tests[cur_test_i]->enable && tests[cur_test_i]->dev_enable &&         tests[cur_test_i]->type != 2)    {	temp = build_status_label(cur_test_i);	*temp = ' ';		/* don't need the '*' */	if (fprintf(info_fp, "%s\n", temp) == EOF)	{	  perror("Writing log file");	  break;	}    }  }  (void)fflush(info_fp);}/****************************************************************************** * Logs the "Enable test" message to the INFO file when a test is enabled     * * while the tests are running(System status is "running").		      * * Input: cur_test_i, the internal test i.d. of the enabled test.	      * ******************************************************************************/start_log(cur_test_i)int	cur_test_i;{  char	buff[82];  char	*temp;  temp = build_status_label(cur_test_i);  *temp = ' ';			/* don't need the '*' */  (void)sprintf((char *)buff, enable_test_info, temp); 					/* "*** Enable test ***\n%s" */  logmsg(buff, 0, ENABLE_TEST_INFO);		/* log to information file */}/****************************************************************************** * Logs the "Disable test" message to the INFO file when a test is disabled   * * while the tests are running(System status is "running").		      * * Input: cur_test_i, the internal test i.d. of the disabled test.	      * ******************************************************************************/stop_log(cur_test_i)int	cur_test_i;{  char	buff[82];  char	*temp;  temp = build_status_label(cur_test_i);  *temp = ' ';			/* don't need the '*' */  (void)sprintf((char *)buff, disable_test_info, temp);  				/* "*** Disable test ***\n%s" */  logmsg(buff, 0, DISABLE_TEST_INFO);		/* log to information file */}/****************************************************************************** * Logs the "Failed test" message to both INFO and ERROR files when a test    * * is failed.								      * * Input: cur_test_i, the internal test i.d. of the failed test.	      * ******************************************************************************/failed_log(cur_test_i)int	cur_test_i;{  char	buff[82];  char	*temp;  temp = build_status_label(cur_test_i);  *temp = ' ';				/* don't need the '*' */  (void)sprintf((char *)buff, test_failed_info, temp);  					/* "*** Failed test ***\n%s" */  logmsg(buff, 1, TEST_FAILED_INFO);	/* log to both INFO and ERROR files */}

⌨️ 快捷键说明

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