Пример #1
0
static int proc_args(int argc, char *argv[]) {

  unsigned long seconds, timer, freq;
  char *str;
  long num;

  /*check the function to test: if the first characters match, accept it */
  if (strncmp(argv[1], "timer", strlen("timer")) == 0) {
	  if( argc != 3 ) {
		  printf("wrong no of arguments for test of timer_test_config() \n");
		  return 1;
	  }
	  if( (timer = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  if(timer!=0 && timer!=1 && timer!=2){
		  printf("argument timer ranges from 0 to 2\n");
			  return 1;
	  }
	  printf("timer_test_config(%lu)\n",timer); /* Actually, it was already invoked */
	  timer_test_config(timer);
	  return 0;
  } else if (strncmp(argv[1], "freq", strlen("freq")) == 0) {
	  if( argc != 3 ) {
		  printf("wrong no of arguments for test of timer_test_square() \n");
		  return 1;
	  }
	  if( (freq = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  printf("timer_test_square(%lu)\n",freq);
	  timer_test_square(freq);
	  return 0;
  } else if (strncmp(argv[1], "chronometer", strlen("chronometer")) == 0) {
	  if( argc != 3 ) {
		  printf("wrong no of arguments for test of timer_test_int() \n");
		  return 1;
	  }
	  if( (seconds = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  printf("timer_test_int(%lu)\n",seconds);
	  timer_test_int(seconds);
	  return 0;
  }  else {
	  printf(" non valid function \"%s\" to test\n", argv[1]);
	  return 1;
  }
}
Пример #2
0
static int proc_args(int argc, char *argv[]) {

	unsigned long freq, timer, time;
	char *str;
	long num;

	if (strncmp(argv[1], "test_square", strlen("test_square")) == 0) {
		if (argc != 3) {
			printf(
					"lab2: wrong no of arguments for test of timer_test_square() \n");
			return 1;
		}
		if ((freq = parse_ulong(argv[2], 10)) == ULONG_MAX)
			return 1;
		printf("lab2::timer_test_square(%d)\n", (unsigned) freq);
		timer_test_square(freq);
		return 0;
	} else if (strncmp(argv[1], "test_config", strlen("test_config")) == 0) {
		if (argc != 3) {
			printf(
					"lab2: wrong no of arguments for test of timer_test_config() \n");
			return 1;
		}
		if ((timer = parse_ulong(argv[2], 16)) == ULONG_MAX)
			return 1;
		printf("lab2::timer_test_config(0x%X)\n", (unsigned) timer);
		timer_test_config(timer);
		return 0;
	} else if (strncmp(argv[1], "test_int", strlen("test_int")) == 0) {
		if (argc != 3) {
			printf(
					"lab2: wrong no of arguments for test of timer_set_square() \n");
			return 1;
		}
		if ((time = parse_ulong(argv[2], 10)) == ULONG_MAX)
			return 1;
		printf("lab2::timer_set_square(%d)\n", (unsigned) time);
		timer_test_int(time);
		return 0;
	} else {
		printf("lab2: non valid function \"%s\" to test\n", argv[1]);
		return 1;
	}
}
Пример #3
0
static int proc_args(int argc, char *argv[]) {

  unsigned long freq, time;
  unsigned char conf;

  /* check the function to test: if the first characters match, accept it */
  if (strncmp(argv[1], "display_conf", strlen("display_conf")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_display_conf() \n");
		  return 1;
	  }
	  if( (conf = parse_ulong(argv[2], 0)) == ULONG_MAX )
	 		  return 1;
	  printf("timer:: timer_display_conf(%d)\n", conf);
	  timer_display_conf(conf);
	  return 0;
  } else if (strncmp(argv[1], "test_int", strlen("test_int")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_int() \n");
		  return 1;
	  }
	  if( (time = parse_ulong(argv[2], 16)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_int(%d)\n", time);
	  timer_test_int(time);
	  return 0;
  } else if (strncmp(argv[1], "test_square", strlen("test_square")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_square() \n");
		  return 1;
	  }
	  if( (freq = parse_ulong(argv[2], 16)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_square(%d)\n", freq);
	  return timer_test_square(freq);
  } else {
	  printf("timer: non valid function \"%s\" to test\n", argv[1]);
	  return 1;
  }
}
Пример #4
0
static int proc_args(int argc, char *argv[]) {

  unsigned long timer, freq, time;

  /* check the function to test: if the first characters match, accept it */
  if (strncmp(argv[1], "config", strlen("config")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_config() \n");
		  return 1;
	  }
	  if( (timer = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  printf("timer:: timer_test_config(%lu)\n", timer);
	  return  timer_test_config(timer);
  } else if (strncmp(argv[1], "square", strlen("square")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_square() \n");
		  return 1;
	  }
	  if( (freq = parse_ulong(argv[2], 10)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_square(%lu)\n", freq);
	  return timer_test_square(freq);;
  } else if (strncmp(argv[1], "test_int", strlen("test_int")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_int() \n");
		  return 1;
	  }
	  if( (time = parse_ulong(argv[2], 10)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_int(%lu)\n", time);
	  return timer_test_int(time);;
  } else {
	  printf("timer: non valid function \"%s\" to test\n", argv[1]);
	  return 1;
  }
}