Example #1
0
/* Test several threads running (*body)(struct test *m) for increasing settings
   of m->iterations, until about timeout_s to 2*timeout_s seconds have elapsed.
   If extra!=NULL, run (*extra)(m) in an additional thread.  */
static void test(const char *name, void (*body)(void *m),
                 void (*extra)(void *m), int timeout_s) {
  gpr_int64 iterations = 1024;
  struct test *m;
  gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
  gpr_timespec time_taken;
  gpr_timespec deadline = gpr_time_add(
      start, gpr_time_from_micros(timeout_s * 1000000, GPR_TIMESPAN));
  fprintf(stderr, "%s:", name);
  while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
    iterations <<= 1;
    fprintf(stderr, " %ld", (long)iterations);
    m = test_new(10, iterations);
    if (extra != NULL) {
      gpr_thd_id id;
      GPR_ASSERT(gpr_thd_new(&id, extra, m, NULL));
      m->done++; /* one more thread to wait for */
    }
    test_create_threads(m, body);
    test_wait(m);
    if (m->counter != m->threads * m->iterations) {
      fprintf(stderr, "counter %ld  threads %d  iterations %ld\n",
              (long)m->counter, m->threads, (long)m->iterations);
      GPR_ASSERT(0);
    }
    test_destroy(m);
  }
  time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
  fprintf(stderr, " done %ld.%09d s\n", (long)time_taken.tv_sec,
          (int)time_taken.tv_nsec);
}
Example #2
0
bool test_is_Wheel_Direction_Right(uint8_t pMotorId){
	//flush encodeur
	quad_readCounters(&HandleRobot.HandleQuad[0]);
	quad_readCounters(&HandleRobot.HandleQuad[1]);

	dcMotor_setDirection(&HandleRobot.HandleMotor[pMotorId],RIGHT);
	dcMotor_setPWM(&HandleRobot.HandleMotor[pMotorId],900);
	test_wait();
	dcMotor_setPWM(&HandleRobot.HandleMotor[pMotorId],EPWM_BRAKE);
	test_wait();

	quad_readCounters(&HandleRobot.HandleQuad[0]);
	quad_readCounters(&HandleRobot.HandleQuad[1]);

	int16_t lCount = 0;
	if(pMotorId == 0){
		lCount = HandleRobot.HandleQuad[0].Count0;
	}
	else if(pMotorId == 1){
		lCount = HandleRobot.HandleQuad[0].Count1;
	}
	else if(pMotorId == 2){
		lCount = HandleRobot.HandleQuad[1].Count0;
	}
	else if(pMotorId == 3){
		lCount = HandleRobot.HandleQuad[1].Count1;
	}

	if(lCount > 0){
		System_printf("Right Direction Motor %d [OK]\r\n",pMotorId);
		return true;
	}
	else{
		System_printf("Right Direction Motor %d [Fail]\r\n",pMotorId);
		return false;
	}
}
Example #3
0
bool test_is_Encoder_is_Matched_With_Wheel(uint8_t pMotorId){

	//flush encodeur
	quad_readCounters(&HandleRobot.HandleQuad[0]);
	quad_readCounters(&HandleRobot.HandleQuad[1]);

	dcMotor_setPWM(&HandleRobot.HandleMotor[pMotorId],900);
	test_wait();
	dcMotor_setPWM(&HandleRobot.HandleMotor[pMotorId],EPWM_BRAKE);
	test_wait();

	quad_readCounters(&HandleRobot.HandleQuad[0]);
	quad_readCounters(&HandleRobot.HandleQuad[1]);

	int16_t lCount = 0;
	if(pMotorId == 0){
		lCount = HandleRobot.HandleQuad[0].Count0;
	}
	else if(pMotorId == 1){
		lCount = HandleRobot.HandleQuad[0].Count1;
	}
	else if(pMotorId == 2){
		lCount = HandleRobot.HandleQuad[1].Count0;
	}
	else if(pMotorId == 3){
		lCount = HandleRobot.HandleQuad[1].Count1;
	}

	if(lCount != 0){
		System_printf("Encoder %d [OK]\r\n",pMotorId);
		return true;
	}
	else{
		System_printf("Encoder %d [Fail]\r\n",pMotorId);
		return false;
	}
}
int
main(int argc, char **argv)
{
    test_create_dynamic() ;
    test_create_static() ;
    test_thread_create() ;
    test_yield() ;
    test_wait() ;
    test_broadcast() ;
    test_pc() ;
    test_pc_big() ;
    test_recursive() ;
    test_sem() ;
    test_lock() ;
    test_func_pointer() ;
    test_ready() ;
    test_kill() ;
    test_reset() ;

    return 0 ;
}
Example #5
0
void test_is_Wheel_System_Working_Well(){
	bool lSuccess = true;
	System_printf("*******Wheel testing********\r\n");

	//flush encodeur
	quad_readCounters(&HandleRobot.HandleQuad[0]);
	quad_readCounters(&HandleRobot.HandleQuad[1]);

	//MotorRotation
	dcMotor_setPWM(&HandleRobot.HandleMotor[0],900);
	dcMotor_setPWM(&HandleRobot.HandleMotor[1],900);
	dcMotor_setPWM(&HandleRobot.HandleMotor[2],900);
	dcMotor_setPWM(&HandleRobot.HandleMotor[3],900);

	test_wait();

	dcMotor_setPWM(&HandleRobot.HandleMotor[0],EPWM_BRAKE);
	dcMotor_setPWM(&HandleRobot.HandleMotor[1],EPWM_BRAKE);
	dcMotor_setPWM(&HandleRobot.HandleMotor[2],EPWM_BRAKE);
	dcMotor_setPWM(&HandleRobot.HandleMotor[3],EPWM_BRAKE);

	test_wait();

	quad_readCounters(&HandleRobot.HandleQuad[0]);
	quad_readCounters(&HandleRobot.HandleQuad[1]);

	if(HandleRobot.HandleQuad[0].Count0 != 0){
		System_printf("Wheel 0 [OK]\r\n");
	}
	else{
		System_printf("Wheel 0 [FAIL]\r\n");
		lSuccess = false;
	}

	if(HandleRobot.HandleQuad[0].Count1 != 0){
		System_printf("Wheel 1 [OK]\r\n");
	}
	else{
		System_printf("Wheel 1 [FAIL]\r\n");
		lSuccess = false;
	}

	if(HandleRobot.HandleQuad[1].Count0 != 0){
		System_printf("Wheel 2 [OK]\r\n");
	}
	else{
		System_printf("Wheel 2 [FAIL]\r\n");
		lSuccess = false;
	}

	if(HandleRobot.HandleQuad[1].Count1 != 0){
		System_printf("Wheel 3 [OK]\r\n");
	}
	else{
		System_printf("Wheel 3 [FAIL]\r\n");
		lSuccess = false;
	}

	System_flush();

	if(lSuccess){
		System_printf("[SUCCESS]\r\n");
	}
	else{
		System_printf("[FAILURE]\r\n");
	}

	System_flush();
}