Пример #1
0
static int stress(const char *name,
		  int (*test_routine)(void),
		  const int iteration)
{
	int i;

	for (i = 0; i < iteration; ++i) {
		if (i % 10 == 0) {
			ccprintf("\r%s...%d/%d", name, i, iteration);
			usleep(RAND_US());
		}
		if (test_routine() != EC_SUCCESS)
			return EC_ERROR_UNKNOWN;
	}

	ccprintf("\r%s...%d/%d\n", name, iteration, iteration);
	return EC_SUCCESS;
}
Пример #2
0
TEST_RESULT_T test_main(TEST_PARAMETER_T *ptTestParameter)
{
	TEST_RESULT_T tTestResult;
	USER_PARAMETER_T *ptUserParameter;


	/* Initialize the SYSTIME unit.
	 * This is important for delays and SYS LED blink sequences.
	 */
	systime_init();

	/* Show a welcome message including the version. */
	uprintf("\f. *** Test skeleton by [email protected] ***\n");
	uprintf("V" VERSION_ALL "\n\n");

	/* Switch off SYS LED. */
	rdy_run_setLEDs(RDYRUN_OFF);

	/* Show the address of the test parameter. */
	uprintf("ptTestParameter: 0x%08x\n", ptTestParameter);

	/* Get the user parameter. */
	ptUserParameter = (USER_PARAMETER_T*)(ptTestParameter->pvUserParameter);

	/* Show the address of the user parameter. */
	uprintf("ptUserParameter: 0x%08x\n", ptUserParameter);

	/* Call the test routine. */
	tTestResult = test_routine(ptUserParameter);

	/* Set the RDY/RUN LED to green if the result of the test is "OK".
	 * Set it to yellow if an error occured.
	 */
	if( tTestResult==TEST_RESULT_OK )
	{
		rdy_run_setLEDs(RDYRUN_GREEN);
	}
	else
	{
		rdy_run_setLEDs(RDYRUN_YELLOW);
	}

	return tTestResult;
}
Пример #3
0
void run_test() {
  int n;
  pid_t pid;

  n = NUM_PROC;
  while(n-- > 0) {
    pid = x_fork();
    
    if(IS_CHILD(pid)) {
      // do something;
      test_routine();

      exit(0);
    }
  }

  n = NUM_PROC;
  while(n-- > 0) {
    pid = x_wait(NULL);
    //printf("Done: %d\n", pid);
  }
}
Пример #4
0
int main(int argc, char *argv[]) 
{
#ifdef UNENCRYPTED_BUILD
    printf("block_ofs, block_len, key_ofs, key_len: 0x%lX 0x%lX 0x%lX 0x%lX\n",
        SPC_SMC_OFFSET(SPC_SMC_BLOCK_ADDR(test)),
        SPC_SMC_BLOCK_LEN(test),
        SPC_SMC_OFFSET(SPC_SMC_KEY_ADDR(test)),
        SPC_SMC_KEY_LEN(test)
    );

    return 0;
#endif
    
    spc_smc_decrypt(
        SPC_SMC_BLOCK_ADDR(test),
        SPC_SMC_BLOCK_LEN(test),
        SPC_SMC_KEY_ADDR(test),
        SPC_SMC_KEY_LEN(test)
    );

    test_routine();
    
    return 0;
}
Пример #5
0
int main(int argc, char** argv) {
   
   int ret,quiet,i;

   struct perf_event_attr pe;

   char test_string[]="Testing if reset clears multiplex fields...";

   quiet=test_quiet();
   
   if (!quiet) {
      printf("The PERF_EVENT_IOC_RESET ioctl() clears the event count.\n");
      printf("  Check to see if it clears other fields too, such as\n");
      printf("  time_enabled and time_running.  Traditionall it does not.\n");
   }

   /* Setup 10 counters */

   for(i=0;i<NUM_EVENTS;i++) {

      memset(&pe,0,sizeof(struct perf_event_attr));
      pe.type=PERF_TYPE_HARDWARE;
      pe.size=sizeof(struct perf_event_attr);
      pe.config=events[i];
      pe.disabled=1;
      pe.exclude_kernel=1;
      pe.exclude_hv=1;
      pe.read_format=PERF_FORMAT_TOTAL_TIME_ENABLED | 
	             PERF_FORMAT_TOTAL_TIME_RUNNING;

      arch_adjust_domain(&pe,quiet);

      fd[i]=perf_event_open(&pe,0,-1,-1,0);
      if (fd[i]<0) {
	 fprintf(stderr,"Failed adding mpx event %d %s\n",i,strerror(errno));
         test_fail(test_string);
	 return -1;
      }
   }


   /**************************/
   /* Start all the counters */
   /**************************/

   for(i=0;i<NUM_EVENTS;i++) {
      ret=ioctl(fd[i], PERF_EVENT_IOC_ENABLE,0);
      if (ret<0) {
	 fprintf(stderr,"Error starting event %d\n",i);
      }
   }

   test_routine();

   /*************************/
   /* Stop all the counters */
   /*************************/

   for(i=0;i<NUM_EVENTS;i++) {
      ret=ioctl(fd[i], PERF_EVENT_IOC_DISABLE,0);
      if (ret<0) {
	 fprintf(stderr,"Error stopping event %d\n",i);
      }
   }

   if (!quiet) printf("Initial results\n");

   /*********************/
   /* Read the counters */
   /*********************/

   for(i=0;i<NUM_EVENTS;i++) {
      ret=read(fd[i],&base_results[i],5*sizeof(long long));
      if (ret<3*sizeof(long long)) {
	fprintf(stderr,"Event %d unexpected read size %d\n",i,ret);
        test_fail(test_string);
      }
      if (!quiet) {
         printf("\t%d %lld %lld %lld\n",i,
	     base_results[i][0],base_results[i][1],base_results[i][2]);
      }
   }

   /**********************/
   /* Reset the counters */
   /**********************/

   for(i=0;i<NUM_EVENTS;i++) {
      ret=ioctl(fd[i], PERF_EVENT_IOC_RESET,0);
      if (ret<0) {
	 fprintf(stderr,"Error resetting event %d\n",i);
      }
   }

   /************************/
   /* Re-read the counters */
   /************************/
     

   if (!quiet) printf("After reset:\n");

   for(i=0;i<NUM_EVENTS;i++) {
      ret=read(fd[i],&mpx_results[i],5*sizeof(long long));
      if (ret<3*sizeof(long long)) {
	fprintf(stderr,"Event %d unexpected read size %d\n",i,ret);
        test_fail(test_string);
      }
      if (!quiet) {
         printf("\t%d %lld %lld %lld\n",i,
	     mpx_results[i][0],mpx_results[i][1],mpx_results[i][2]);
      }
      if (mpx_results[i][0]!=0) {
	 fprintf(stderr,"Event %d not reset to 0\n",i);
         test_fail(test_string);
      }

      if (mpx_results[i][1]==0) {
	 fprintf(stderr,"Enabled %d should not be 0\n",i);
         test_fail(test_string);
      }

      if (mpx_results[i][2]==0) {
	 fprintf(stderr,"Running %d should not be  0\n",i);
         test_fail(test_string);
      }

   }

   test_pass(test_string);
      
   return 0;
}
Пример #6
0
void
test(int N, int D, int& num_passed, int& num_failed)
{
    static const cl2func_name_pair cfuncs[] = {
        { &cl2f_1_8, "cl2f_1_8" },
#ifdef __SSE2__
        { &cl2v_2_32, "cl2v_2_32" },
#endif
    };

    static const sl2func_name_pair sfuncs[] = {
        { &sl2f_1_8, "sl2f_1_8" },
#ifdef __SSE__
        { &sl2u_2_8, "sl2u_2_8" },
#endif
    };

    static const dl2func_name_pair dfuncs[] = {
        { &dl2f_1_8, "dl2f_1_8" },
#ifdef __SSE2__
        { &dl2v_2_8, "dl2v_2_8" },
#endif
    };
    
    unsigned char* pnts_uc;
    float* pnts_s;
    double* pnts_d;

    // Arrays of points
    pnts_d = gen_unit_random<double>(N, D, 42);
    pnts_s = new float[N*D];
    pnts_uc = new unsigned char[N*D];
    
    for (int i=0; i < N*D; ++i) pnts_s[i] = (float)pnts_d[i];
    for (int i=0; i < N*D; ++i) pnts_uc[i] = (unsigned char)(256.0*pnts_d[i]);
    unsigned* pnts_uc_dm_slow = new unsigned[N*N];
    float* pnts_s_dm_slow = new float[N*N];
    double* pnts_d_dm_slow = new double[N*N];

    compute_distance_matrix(&cl2s, pnts_uc, N, D, pnts_uc_dm_slow);
    compute_distance_matrix(&sl2s, pnts_s, N, D, pnts_s_dm_slow);
    compute_distance_matrix(&dl2s, pnts_d, N, D, pnts_d_dm_slow);

    // UC
    for (size_t i=0; i < sizeof(cfuncs)/sizeof(cl2func_name_pair); ++i) {
        bool res = test_routine(pnts_uc_dm_slow, pnts_uc, N, D, cfuncs[i].func, 0.0);
        if (res) {
            printf("%10d %10d %30s %20s\n", N, D, cfuncs[i].name, "PASSED");
            num_passed++;
        }
        else {
            printf("%10d %10d %30s %20s\n", N, D, cfuncs[i].name, "FAILED");
            num_failed++;
        }
    }
    
    // S
    for (size_t i=0; i < sizeof(sfuncs)/sizeof(sl2func_name_pair); ++i) {
        bool res = test_routine(pnts_s_dm_slow, pnts_s, N, D, sfuncs[i].func, 1.e-4);
        if (res) {
            printf("%10d %10d %30s %20s\n", N, D, sfuncs[i].name, "PASSED");
            num_passed++;
        }
        else {
            printf("%10d %10d %30s %20s\n", N, D, sfuncs[i].name, "FAILED");
            num_failed++;
        }
    }
    
    // D
    for (size_t i=0; i < sizeof(dfuncs)/sizeof(dl2func_name_pair); ++i) {
        bool res = test_routine(pnts_d_dm_slow, pnts_d, N, D, dfuncs[i].func, 1.e-10);
        if (res) {
            printf("%10d %10d %30s %20s\n", N, D, dfuncs[i].name, "PASSED");
            num_passed++;
        }
        else {
            printf("%10d %10d %30s %20s\n", N, D, dfuncs[i].name, "FAILED");
            num_failed++;
        }
    }

    delete[] pnts_d_dm_slow;
    delete[] pnts_s_dm_slow;
    delete[] pnts_uc_dm_slow;

    delete[] pnts_d;
    delete[] pnts_s;
    delete[] pnts_uc;
}