コード例 #1
0
ファイル: fork_and_defunc.c プロジェクト: wcohen/uprobe_tests
main(int argc, char **argv)
{
	int i,num_threads;
	pthread_t thread[MAX_THREADS];
	int niter;

	if ( (argc != 3 || (num_threads = atoi(argv[1])) <= 0 )
			 || (niter = atoi(argv[2])) <= 0) {
		fprintf(stderr,"Usage: %s number_of_threads num_iterations\n",
			 argv[0]);
                exit(1);
        }


	wait_for_kthread(); /* stop here and wait for the uprobe
			       mod to be loaded */
	/* start fork threads */
	for(i=0;i<num_threads;i++){
		if(pthread_create(&thread[i],NULL,(void *)fork_thread,&niter)){
			perror("pthread_create failed");
			report_test_fail("pthread_create failed");
		}
	}
	
	/* Gather around */
	int results;
	for(i=0;i<num_threads;i++){
		if (pthread_join(thread[i],(void **)&results) != 0)
			report_test_fail("pthread_join returned an error\n");
		if ( results != 0 ) break;
	}
	if(debug) printf("%d threads returned\n",i);
	if ((i==num_threads)&&( results == 0 )) report_pass();
	report_fail(); 
}
コード例 #2
0
ファイル: sys_err.c プロジェクト: Nirosun/18342
void check_return(int r,int expected,const char *str) {
	if(r == expected) 
		report_suc(str);
	else {
		printf("expect %d, get %d\n",expected,r);
		report_fail(str);
	}
}
コード例 #3
0
ファイル: test.c プロジェクト: ibr-cm/contiki-inga
void
test_geq(uint32_t a, uint32_t b, char* test) {
  if (!(a >= b)) {
    suite.errors++;
    report_fail(a, b, test);
    ABORT();
  }
}
コード例 #4
0
ファイル: chibi.c プロジェクト: weiju/chibi_test
static int _chibi_suite_run(chibi_suite *suite, void (*report_num_tests)(int),
                            void (*report_success)(int, chibi_testcase *),
                            void (*report_fail)(int, chibi_testcase *),
                            int tcnum, int level)
{
    if (suite) {
        chibi_testcase *testcase;

        if (suite->first_child) {
            tcnum = _chibi_suite_run(suite->first_child, report_num_tests,
                                     report_success, report_fail, tcnum, level + 1);
        }
        if (suite->next) {
            tcnum = _chibi_suite_run(suite->next, report_num_tests,
                                     report_success, report_fail, tcnum, level + 1);
        }

        /* only report the number of tests at the top level */
        if (level == 0) report_num_tests(_count_tests(suite));

        /* run this level's tests */
        testcase = suite->head;
        while (testcase) {
#ifndef AMIGA
            if (!setjmp(testcase->env)) {
#endif
                if (suite->setup) suite->setup(suite->userdata);
                testcase->fun(testcase);
                if (suite->teardown) suite->teardown(suite->userdata);
#ifndef AMIGA
            }
#endif
            if (testcase->success) report_success(tcnum, testcase);
            else report_fail(tcnum, testcase);
            testcase = testcase->next;
            tcnum++;
        }
    }
    return tcnum;
}
コード例 #5
0
ファイル: getteximage-clamping.c プロジェクト: RAOF/piglit
static enum piglit_result
read_format(const struct format_info *tex_info,
	    const struct read_format_info *read_info,
	    uint32_t texels[][4], int num_texels)
{
	size_t texels_size = num_texels * 4 * sizeof(uint32_t);
	char *expected;
	char *read;
	int i;
	int chans = 0;
	enum piglit_result result;

	if (!test_rg && (read_info->format == GL_RED_INTEGER ||
			 read_info->format == GL_RG_INTEGER)) {
		return PIGLIT_SKIP;
	}

	if (!test_rgb10_a2ui) {
		/* Packed integer pixel formats were introduced with
		 * GL_texture_rgb10_a2ui.
		 */
		switch (read_info->type) {
		case GL_INT:
		case GL_UNSIGNED_INT:
		case GL_SHORT:
		case GL_UNSIGNED_SHORT:
		case GL_BYTE:
		case GL_UNSIGNED_BYTE:
			break;
		default:
			return PIGLIT_SKIP;
		}
	}

	/* FINISHME: Again, not really sure how to handle sign conversion. */
	if (tex_info->sign != read_info->sign)
		return PIGLIT_SKIP;


	printf("Reading from %s to %s/%s\n", tex_info->name,
	       read_info->format_name, read_info->type_name);

	expected = (char *)malloc(texels_size);
	read = (char *)malloc(texels_size);

	memset(expected, 0xd0, texels_size);
	memset(read, 0xd0, texels_size);

	glGetTexImage(GL_TEXTURE_2D, 0,
		      read_info->format, read_info->type, read);

	switch (read_info->format) {
	case GL_RGBA_INTEGER:
		chans = 4;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][0]);
			pack(read_info, expected, i, 1, chans, texels[i][1]);
			pack(read_info, expected, i, 2, chans, texels[i][2]);
			pack(read_info, expected, i, 3, chans, texels[i][3]);
		}
		break;

	case GL_BGRA_INTEGER:
		chans = 4;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][2]);
			pack(read_info, expected, i, 1, chans, texels[i][1]);
			pack(read_info, expected, i, 2, chans, texels[i][0]);
			pack(read_info, expected, i, 3, chans, texels[i][3]);
		}
		break;

	case GL_RGB_INTEGER:
		chans = 3;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][0]);
			pack(read_info, expected, i, 1, chans, texels[i][1]);
			pack(read_info, expected, i, 2, chans, texels[i][2]);
		}
		break;

	case GL_BGR_INTEGER:
		chans = 3;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][2]);
			pack(read_info, expected, i, 1, chans, texels[i][1]);
			pack(read_info, expected, i, 2, chans, texels[i][0]);
		}
		break;

	case GL_RED_INTEGER:
		chans = 1;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][0]);
		}
		break;

	case GL_GREEN_INTEGER:
		chans = 1;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][1]);
		}
		break;

	case GL_BLUE_INTEGER:
		chans = 1;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][2]);
		}
		break;

	case GL_ALPHA_INTEGER:
		chans = 1;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][3]);
		}
		break;

	case GL_RG_INTEGER:
		chans = 2;
		for (i = 0; i < num_texels; i++) {
			pack(read_info, expected, i, 0, chans, texels[i][0]);
			pack(read_info, expected, i, 1, chans, texels[i][1]);
		}
		break;

	default:
		assert(0);
		return PIGLIT_SKIP;
	}

	if (memcmp(expected, read, num_texels * chans * read_info->size / 8)) {
		report_fail(tex_info, read_info, texels, read, expected,
			    num_texels, chans);
		result = PIGLIT_FAIL;
	} else {
		result = PIGLIT_PASS;
	}

	free(read);
	free(expected);

	return result;
}