Beispiel #1
0
static void test_req_sent(struct network_test *t)
{
	int s = t->nt_s;
	fd_set fds;
	struct timeval tv;
	char buf[1024];
	int rc;

	FD_ZERO(&fds);
	FD_SET(s, &fds);

	tv.tv_sec  = 0;
	tv.tv_usec = 0;

	if (select(s + 1, &fds, NULL, NULL, &tv) == -1)
		err(1, "select()");

	if (!FD_ISSET(s, &fds))
		return;

	rc = recv(s, buf, sizeof(buf) - 1, 0);
	if (rc == -1) {
		test_finish(t, errno);
		return;
	}

	if (rc == 0) {
		test_finish(t, TEST_ERR_DISCONNECT);
		return;
	}

	buf[rc] = 0;

	if (strncmp(buf, TEST_REPLY, strlen(TEST_REPLY)) != 0) {
		test_finish(t, TEST_ERR_BADINPUT);
		return;
	}

	t->nt_flags = atoi(&buf[rc - 1]);

	if (t->nt_proto == TEST_TCP && t->nt_crypt == 1) {
		test_finish(t, TEST_ERR_UNEXPECTED_CRYPT);
		return;
	}

	if (t->nt_proto == TEST_CRYPT && t->nt_crypt != 1) {
		test_finish(t, TEST_ERR_NO_CRYPT);
		return;
	}

	test_success(t);
}
/*
 *	条件チェックのエラー処理
 */
void
_check_assert(const char *expr, const char *file, int_t line)
{
	syslog_3(LOG_ERROR, "## Assertion `%s' failed at %s:%u.",
								expr, file, line);
	test_finish();
}
Beispiel #3
0
void
main_task(intptr_t exinf)
{
	test_start(__FILE__);

	test_empty();

	syslog(LOG_NOTICE, "-- for fitting parameters --");
	test_dly_nse(0);
	test_dly_nse(SIL_DLY_TIM1);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 1);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 2);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 3);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 4);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 5);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 10);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 20);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 50);

	syslog(LOG_NOTICE, "-- for checking boundary conditions --");
	test_dly_nse(SIL_DLY_TIM1 + 1);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 1 + 1);
	test_dly_nse(SIL_DLY_TIM1 + SIL_DLY_TIM2 * 2 + 1);

	test_finish();
}
Beispiel #4
0
void
main_task(intptr_t exinf)
{
	SYSUTM		sysutm, prev_sysutm;
	char		*prev_sysutm_pos;
	ulong_t		i;

	cyclic_count = 0U;
	get_utm(&recent_sysutm);
	syslog(LOG_NOTICE, "system performance time test starts.");

	for (i = 0; i < NO_LOOP; i++) {
		loc_cpu();
		get_utm(&sysutm);
		prev_sysutm = recent_sysutm;
		prev_sysutm_pos = recent_sysutm_pos;
		recent_sysutm = sysutm;
		recent_sysutm_pos = "TSK";
		unl_cpu();

		if (prev_sysutm > sysutm) {
			syslog(LOG_NOTICE,
				"system performance time goes back: %ld(%s) %ld(TSK)",
				((long_t) prev_sysutm), prev_sysutm_pos, ((ulong_t) sysutm));
		}
	}

	syslog(LOG_NOTICE, "system performance time test finishes.");
	syslog(LOG_NOTICE, "number of cyclic handler execution: %d", cyclic_count);
	test_finish();
}
/*
 *	エラーコードチェックのエラー処理
 */
void
_check_ercd(ER ercd, const char *file, int_t line)
{
	syslog_3(LOG_ERROR, "## Unexpected error %s detected at %s:%u.",
								itron_strerror(ercd), file, line);
	test_finish();
}
/*
 *	完了チェックポイント
 */
void
check_finish(uint_t count)
{
	check_point(count);
	syslog_0(LOG_NOTICE, "All check points passed.");
	test_finish();
}
Beispiel #7
0
void
check_point(uint_t count)
{
	bool_t	errorflag = false;
	ER		rercd;
	ID      prcid;

	SIL_PRE_LOC;

	/*
	 *  割込みロック状態に
	 */
	SIL_LOC_INT();

	/*
	 *  PRCID取得
	 */
	sil_get_pid(&prcid);

	/*
	 *  シーケンスチェック
	 */
	if (++check_count[prcid-1] == count) {
		syslog_2(LOG_NOTICE, "PE %d : Check point %d passed.", prcid, count);
	}
	else {
		syslog_2(LOG_ERROR, "## PE %d : Unexpected check point %d.", prcid, count);
		errorflag = true;
	}

	/*
	 *  カーネルの内部状態の検査
	 */
	if (check_bit_func != NULL) {
		rercd = (*check_bit_func)();
		if (rercd < 0) {
			syslog_2(LOG_ERROR, "## Internal inconsistency detected (%s, %d).",
								itron_strerror(rercd), SERCD(rercd));
			errorflag = true;
		}
	}

	/*
	 *  エラーが検出された場合は,テストプログラムを終了する.
	 */
	if (errorflag) {
		test_finish();
	}

	/*
	 *  割込みロック状態を解除
	 */
	SIL_UNL_INT();
}
Beispiel #8
0
static
void
test_done(
    MMSDispatcherDelegate* delegate,
    MMSDispatcher* dispatcher)
{
    Test* test = MMS_CAST(delegate,Test,delegate);
    if (!mms_handler_test_receive_pending(test->handler, NULL)) {
        test_finish(test);
    }
}
Beispiel #9
0
static void test_connecting(struct network_test *t)
{
	int s = t->nt_s;
	struct timeval tv;
	fd_set fds;
	int rc;
	socklen_t sz = sizeof(rc);
	char *buf = NULL;
	unsigned char sid[1024];
	unsigned int sidlen = sizeof(sid);
	struct sockaddr_in s_in;
	socklen_t sl = sizeof(s_in);

	tv.tv_sec  = 0;
	tv.tv_usec = 0;

	FD_ZERO(&fds);
	FD_SET(s, &fds);

	if (select(s + 1, NULL, &fds, NULL, &tv) == -1)
		err(1, "select()");

	if (!FD_ISSET(s, &fds))
		return;

	if (getsockopt(s, SOL_SOCKET, SO_ERROR, &rc, &sz) == -1)
		err(1, "getsockopt()");

	if (rc != 0) {
		test_finish(t, rc);
		return;
	}

	if (getsockname(s, (struct sockaddr*) &s_in, &sl) == -1)
		err(1, "getsockname()");

	t->nt_ctl.tcc_src = s_in.sin_addr;

	rc = tcpcryptd_getsockopt(&t->nt_ctl, TCP_CRYPT_SESSID, sid, &sidlen);

	if (rc == EBUSY)
		return;

	t->nt_crypt = rc != -1;

	assert(t->nt_req < (sizeof(REQS) / sizeof(*REQS)));
	buf = REQS[t->nt_req];

	if (send(s, buf, strlen(buf), 0) != strlen(buf))
		err(1, "send()");

	t->nt_state = TEST_STATE_REQ_SENT;
}
Beispiel #10
0
static int test_vphn(void)
{
	static struct test *test;

	for (test = all_tests; test->descr; test++) {
		int ret;

		ret = test_one(test);
		test_finish(test->descr, ret);
		if (ret)
			return ret;
	}

	return 0;
}
Beispiel #11
0
/*
 *  main task (high priority)
 */
void main_task(intptr_t exinf)
{
	syslog_0(LOG_NOTICE, "Performance evaluation program (3)");
	syslog_flush();

	perf_eval(0);
	perf_eval(1);
	perf_eval(2);
	perf_eval(3);
	perf_eval(4);
	perf_eval(5);
	perf_eval(10);
	perf_eval(20);
	test_finish();
}
Beispiel #12
0
/*
 *  main task (low priority)
 */
void main_task(intptr_t exinf)
{
	syslog_0(LOG_NOTICE, "Performance evaluation program (1)");
	init_hist(1, MAX_TIME, histarea1);
	init_hist(2, MAX_TIME, histarea2);
	syslog_flush();

	act_tsk(TASK1);
	act_tsk(TASK2);

	syslog_0(LOG_NOTICE, "Execution times of wup_tsk -> slp_tsk");
	print_hist(1);
	syslog_0(LOG_NOTICE, "Execution times of slp_tsk -> wup_tsk");
	print_hist(2);
	test_finish();
}
Beispiel #13
0
/*
 *  main task
 */
void main_task(intptr_t exinf)
{
	uint_t	i;

	syslog_0(LOG_NOTICE, "Performance evaluation program (0)");
	init_hist(1, MAX_TIME, histarea1);
	syslog_flush();

	for (i = 0; i < NO_MEASURE; i++) {
		begin_measure(1);
		end_measure(1);
	}

	syslog_0(LOG_NOTICE, "Measurement overhead");
	print_hist(1);
	test_finish();
}
Beispiel #14
0
static void run_network_test(struct network_test *t)
{
	if (t->nt_start && (time(NULL) - t->nt_start) > 5) {
		test_finish(t, TEST_ERR_TIMEOUT);
		return;
	}

	switch (t->nt_state) {
	case TEST_STATE_START:
		test_connect(t);
		break;

	case TEST_STATE_CONNECTING:
		test_connecting(t);
		break;

	case TEST_STATE_REQ_SENT:
		test_req_sent(t);
		break;
	}
}
Beispiel #15
0
/*
 *	完了チェックポイント
 */
void
check_finish(uint_t count)
{
	volatile uint_t i, j;
	volatile uint_t flag;
	ID       prcid;

	/*
	 *  PRCID取得
	 */
	sil_get_pid(&prcid);

	check_point(count);
	syslog_1(LOG_NOTICE, "PE %d : All check points passed.", prcid);

	/*
	 * ext_ker()発行前に全プロセッサの同期をとる
	 */
	check_finish_enter[prcid - 1] = 1;

	if (prcid == TOPPERS_MASTER_PRCID) {
		do{
			flag = 0;
			for(i = 0; i < TNUM_PRCID; i++){
				if (check_finish_enter[i] == 1){
					flag++;
				}
			}
			for (j = 0; j < 100; j++);
		}while (flag < TNUM_PRCID);
		check_finish_leave = 1;
	}
	else {
		while (check_finish_leave != 1) {
			for (j = 0; j < 100; j++);
		}
	}

	test_finish();
}
Beispiel #16
0
int test_harness(int (test_function)(void), char *name)
{
	int rc;

	test_start(name);
	test_set_git_version(GIT_VERSION);

	if (sigaction(SIGALRM, &alarm_action, NULL)) {
		perror("sigaction");
		test_error(name);
		return 1;
	}

	rc = run_test(test_function, name);

	if (rc == MAGIC_SKIP_RETURN_VALUE)
		test_skip(name);
	else
		test_finish(name, rc);

	return rc;
}
Beispiel #17
0
int main (int argc, char * const argv[]) {
	
	test_start();
	
	cl_ulong gMemSize;
	clFFT_Direction dir = clFFT_Forward;
	int numIter = 1;
	clFFT_Dim3 n = { 1024, 1, 1 };
	int batchSize = 1;
	clFFT_DataFormat dataFormat = clFFT_SplitComplexFormat;
	clFFT_Dimension dim = clFFT_1D;
	clFFT_TestType testType = clFFT_OUT_OF_PLACE;
	cl_device_id device_ids[16];
	
	FILE *paramFile;
			
	cl_int err;
	unsigned int num_devices;
	
	cl_device_type device_type = getGlobalDeviceType();	
	if(device_type != CL_DEVICE_TYPE_GPU) 
	{
		log_info("Test only supported on DEVICE_TYPE_GPU\n");
		test_finish();
		exit(0);
	}
	
	err = clGetDeviceIDs(NULL, device_type, sizeof(device_ids), device_ids, &num_devices);
	if(err) 
	{		
		log_error("clGetComputeDevice failed\n");
		test_finish();
		return -1;
	}
	
	device_id = NULL;
	
	unsigned int i;
	for(i = 0; i < num_devices; i++)
	{
	    cl_bool available;
	    err = clGetDeviceInfo(device_ids[i], CL_DEVICE_AVAILABLE, sizeof(cl_bool), &available, NULL);
	    if(err)
	    {
	         log_error("Cannot check device availability of device # %d\n", i);
	    }
	    
	    if(available)
	    {
	        device_id = device_ids[i];
	        break;
	    }
	    else
	    {
	        char name[200];
	        err = clGetDeviceInfo(device_ids[i], CL_DEVICE_NAME, sizeof(name), name, NULL);
	        if(err == CL_SUCCESS)
	        {
	             log_info("Device %s not available for compute\n", name);
	        }
	        else
	        {
	             log_info("Device # %d not available for compute\n", i);
	        }
	    }
	}
	
	if(!device_id)
	{
	    log_error("None of the devices available for compute ... aborting test\n");
	    test_finish();
	    return -1;
	}
	
	context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
	if(!context || err) 
	{
		log_error("clCreateContext failed\n");
		test_finish();
		return -1;
	}
	
    queue = clCreateCommandQueue(context, device_id, 0, &err);
    if(!queue || err)
	{
        log_error("clCreateCommandQueue() failed.\n");
		clReleaseContext(context);
        test_finish();
        return -1;
    }  
	
	err = clGetDeviceInfo(device_id, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &gMemSize, NULL);
	if(err)
	{
		log_error("Failed to get global mem size\n");
		clReleaseContext(context);
		clReleaseCommandQueue(queue);
		test_finish();
		return -2;
	}
	
	gMemSize /= (1024*1024);
			
	char delim[] = " \n";
	char tmpStr[100];
	char line[200];
	char *param, *val;	
	int total_errors = 0;
	if(argc == 1) {
		log_error("Need file name with list of parameters to run the test\n");
		test_finish();
		return -1;
	}
	
	if(argc == 2) {	// arguments are supplied in a file with arguments for a single run are all on the same line
		paramFile = fopen(argv[1], "r");
		if(!paramFile) {
			log_error("Cannot open the parameter file\n");
			clReleaseContext(context);
			clReleaseCommandQueue(queue);			
			test_finish();
			return -3;
		}
		while(fgets(line, 199, paramFile)) {
			if(!strcmp(line, "") || !strcmp(line, "\n") || ifLineCommented(line))
				continue;
			param = strtok(line, delim);
			while(param) {
				val = strtok(NULL, delim);
				if(!strcmp(param, "-n")) {
					sscanf(val, "%d", &n.x);
					val = strtok(NULL, delim);
					sscanf(val, "%d", &n.y);
					val = strtok(NULL, delim);
					sscanf(val, "%d", &n.z);					
				}
				else if(!strcmp(param, "-batchsize")) 
					sscanf(val, "%d", &batchSize);
				else if(!strcmp(param, "-dir")) {
					sscanf(val, "%s", tmpStr);
					if(!strcmp(tmpStr, "forward"))
						dir = clFFT_Forward;
					else if(!strcmp(tmpStr, "inverse"))
						dir = clFFT_Inverse;
				}
				else if(!strcmp(param, "-dim")) {
					sscanf(val, "%s", tmpStr);
					if(!strcmp(tmpStr, "1D"))
						dim = clFFT_1D;
					else if(!strcmp(tmpStr, "2D"))
						dim = clFFT_2D; 
					else if(!strcmp(tmpStr, "3D"))
						dim = clFFT_3D;					
				}
				else if(!strcmp(param, "-format")) {
					sscanf(val, "%s", tmpStr);
					if(!strcmp(tmpStr, "plannar"))
						dataFormat = clFFT_SplitComplexFormat;
					else if(!strcmp(tmpStr, "interleaved"))
						dataFormat = clFFT_InterleavedComplexFormat;					
				}
				else if(!strcmp(param, "-numiter"))
					sscanf(val, "%d", &numIter);
				else if(!strcmp(param, "-testtype")) {
					sscanf(val, "%s", tmpStr);
					if(!strcmp(tmpStr, "out-of-place"))
						testType = clFFT_OUT_OF_PLACE;
					else if(!strcmp(tmpStr, "in-place"))
						testType = clFFT_IN_PLACE;										
				}
				param = strtok(NULL, delim);
			}
			
			if(checkMemRequirements(n, batchSize, testType, gMemSize)) {
				log_info("This test cannot run because memory requirements canot be met by the available device\n");
				continue;
			}
				
			err = runTest(n, batchSize, dir, dim, dataFormat, numIter, testType);
			if (err)
				total_errors++;
		}
	}
	
	clReleaseContext(context);
	clReleaseCommandQueue(queue);
	
	test_finish();
	return total_errors;		
}
Beispiel #18
0
static void test_success(struct network_test *t)
{
	t->nt_state = TEST_SUCCESS;
	test_finish(t, 0);
}