示例#1
0
文件: Pixel.c 项目: m1ch4ls/gfxprim
static int pixel_flags(void)
{
	int fail = 0;

	if (!GP_PixelHasFlags(GP_PIXEL_RGB888, GP_PIXEL_IS_RGB)) {
		tst_msg("RGB888 is RGB failed");
		fail++;
	}
	
	if (GP_PixelHasFlags(GP_PIXEL_G1, GP_PIXEL_IS_RGB)) {
		tst_msg("G1 is RGB succeeded");
		fail++;
	}
	
	if (!GP_PixelHasFlags(GP_PIXEL_RGBA8888, GP_PIXEL_HAS_ALPHA)) {
		tst_msg("RGBA8888 has Alpha failed");
		fail++;
	}
	
	if (!GP_PixelHasFlags(GP_PIXEL_RGBA8888,
	                      GP_PIXEL_HAS_ALPHA | GP_PIXEL_IS_RGB)) {
		tst_msg("RGBA8888 has Alpha and is RGB failed");
		fail++;
	}

	if (fail)
		return TST_FAILED;

	return TST_SUCCESS;
}
示例#2
0
static int test_load_PNG(const char *path)
{
	GP_Context *img;

	errno = 0;

	img = GP_LoadPNG(path, NULL);

	if (img == NULL) {
		switch (errno) {
		case ENOSYS:
			tst_msg("Not Implemented");
			return TST_SKIPPED;
		default:
			tst_msg("Got %s", strerror(errno));
			return TST_FAILED;
		}
	}

	/*
	 * TODO: check correct data.
	 */

	GP_ContextFree(img);

	return TST_SUCCESS;
}
示例#3
0
文件: test.c 项目: m1ch4ls/gfxprim
int success_fn(void)
{
	tst_msg("This test does nothing");
	tst_msg("But successfully");
	
	return TST_SUCCESS;
}
示例#4
0
static int test_save_PNG(GP_PixelType pixel_type)
{
	GP_Context *ctx;
	int ret;

	ctx = GP_ContextAlloc(100, 100, pixel_type);

	if (ctx == NULL) {
		tst_msg("Failed to allocate context");
		return TST_UNTESTED;
	}

	errno = 0;

	ret = GP_SavePNG(ctx, "/dev/null", NULL);

	if (ret == 0) {
		tst_msg("Saved successfully");
		GP_ContextFree(ctx);
		return TST_SUCCESS;
	}

	switch (errno) {
	case ENOSYS:
		tst_msg("Not Implemented");
		GP_ContextFree(ctx);
		return TST_SKIPPED;
	default:
		tst_msg("Failed and errno is not ENOSYS (%i)", errno);
		GP_ContextFree(ctx);
		return TST_FAILED;
	}
}
示例#5
0
static int test_circle(const char *pattern, gp_size w, gp_size h,
                       gp_coord x, gp_coord y, const int r, uint8_t seg_flag)
{
	gp_pixmap *c;
	int err;

	c = gp_pixmap_alloc(w, h, GP_PIXEL_G8);

	if (c == NULL) {
		tst_err("Failed to allocate pixmap");
		return TST_UNTESTED;
	}

	/* zero the pixels buffer */
	memset(c->pixels, 0, c->w * c->h);

	gp_circle_seg(c, x, y, r, seg_flag, 1);

	err = compare_buffers(pattern, c);

	if (err) {
		tst_msg("Patterns are different");
		return TST_FAILED;
	}

	return TST_SUCCESS;
}
示例#6
0
static void debug_handler(const struct GP_DebugMsg *msg)
{
	(void)msg;
	handler_called = 1;
	errno = 0;
	tst_msg("Errno changed in debug handler");
}
示例#7
0
文件: test.c 项目: m1ch4ls/gfxprim
int barrier_allocation(void)
{
	char *buf = tst_alloc_barrier_right(31);

	int i;

	for (i = 0; i < 31; i++)
		buf[i] = 0;

	tst_msg("About to use address after the buffer with barrier");
	
	buf[31] = 0;

	tst_msg("This is not printed at all");

	return TST_SUCCESS;
}
示例#8
0
static int test_load_PNG_check_color(struct check_color_test *test)
{
	GP_Context *img;

	errno = 0;

	img = GP_LoadPNG(test->path, NULL);

	if (img == NULL) {
		switch (errno) {
		case ENOSYS:
			tst_msg("Not Implemented");
			return TST_SKIPPED;
		default:
			tst_msg("Got %s", strerror(errno));
			return TST_FAILED;
		}
	}

	unsigned int x, y, fail = 0;

	for (x = 0; x < img->w; x++) {
		for (y = 0; y < img->w; y++) {
			GP_Pixel p = GP_GetPixel(img, x, y);

			if (p != test->pixel) {
				if (!fail)
					tst_msg("First failed at %u,%u %x %x",
					        x, y, p, test->pixel);
				fail = 1;
			}
		}
	}

	if (!fail)
		tst_msg("Context pixels are correct");

	GP_ContextFree(img);

	if (fail)
		return TST_FAILED;

	return TST_SUCCESS;
}
示例#9
0
文件: test.c 项目: m1ch4ls/gfxprim
int temp_dir_fn(void)
{
	char buf[256], *res;

	/* log current working directory */
	res = getcwd(buf, sizeof(buf));
	tst_msg("CWD is '%s'", res);

	return TST_SUCCESS;
}
示例#10
0
static int load_eacces(enum fmt fmt)
{
	char buf[256];
	GP_Context *img;

	snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt));
	
	FILE *f = fopen(buf, "w");

	if (f == NULL) {
		tst_err("Failed to create file 'test': %s", strerror(errno));
		return TST_UNTESTED;
	}

	fclose(f);

	if (chmod(buf, 200)) {
		tst_err("chmod failed: %s", strerror(errno));
		return TST_UNTESTED;
	}

	img = load(fmt, "test");

	if (img != NULL) {
		tst_msg("Test succedded unexpectedly");
		return TST_FAILED;
	}
	
	if (errno == ENOSYS) {
		tst_msg("Load %s: ENOSYS", strfmt(fmt));
		return TST_SKIPPED;
	}

	if (errno != EACCES) {
		tst_msg("Expected errno = EACCES, have %s",
		              strerror(errno));
		return TST_FAILED;
	}

	return TST_SUCCESS;
}
示例#11
0
/*
 * Check that GP_DEBUG() preserves errno.
 */
static int DEBUG_preserves_errno(void)
{
	GP_SetDebugHandler(debug_handler);
	GP_SetDebugLevel(1);

	handler_called = 0;
	errno = 1;

	GP_DEBUG(1, "Debug message");

	if (!handler_called) {
		tst_msg("Debug handler wasn't called");
		return TST_FAILED;
	}

	if (errno != 1) {
		tst_msg("Errno not preserved");
		return TST_FAILED;
	}

	return TST_SUCCESS;
}
示例#12
0
static int load_enoent(enum fmt fmt)
{
	GP_Context *img;
	
	img = load(fmt, "nonexistent");	
	
	if (img != NULL) {
		tst_msg("Test succedded unexpectedly");
		return TST_FAILED;
	}
	
	if (errno == ENOSYS) {
		tst_msg("Load %s: ENOSYS", strfmt(fmt));
		return TST_SKIPPED;
	}

	if (errno != ENOENT) {
		tst_msg("Expected errno = ENOENT, have %s", strerror(errno));
		return TST_FAILED;
	}

	return TST_SUCCESS;
}
示例#13
0
文件: GIF.c 项目: gfxprim/gfxprim
static int test_load_gif(const char *path)
{
	gp_pixmap *img;

	errno = 0;

	img = gp_load_gif(path, NULL);

	if (img == NULL) {
		switch (errno) {
		case ENOSYS:
			tst_msg("Not Implemented");
			return TST_SKIPPED;
		default:
			tst_msg("Got %s", strerror(errno));
			return TST_FAILED;
		}
	}

	gp_pixmap_free(img);

	return TST_SUCCESS;
}
示例#14
0
static int save_load(enum fmt fmt, GP_Size w, GP_Size h)
{
	GP_Context *img, *res;

	img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888);
	
	if (img == NULL) {
		tst_warn("GP_ContextAlloc failed");
		return TST_UNTESTED;
	}

	int ret = save_img(fmt, img, "test");

	if (ret) {
		if (errno == ENOSYS) {
			tst_msg("Save %s: ENOSYS", strfmt(fmt));
			return TST_SKIPPED;
		}
		
		tst_msg("Failed to save %s: %s",
		           strfmt(fmt), strerror(errno));
		return TST_FAILED;
	}

	res = load(fmt, "test");

	if (res == NULL) {
		tst_msg("Failed to load %s: %s",
		           strfmt(fmt), strerror(errno));
		return TST_FAILED;
	}

	GP_ContextFree(img);
	GP_ContextFree(res);

	return TST_SUCCESS;
}
示例#15
0
文件: test.c 项目: m1ch4ls/gfxprim
int malloc_leak_fn(void)
{
	void *p, *q, *r;
	
	q = malloc(100);
	p = malloc(4);
	p = malloc(3);
	r = malloc(20);

	free(p);
	free(q);
	free(r);

	tst_msg("Leaking 1 chunks 4 bytes total");

	return TST_SUCCESS;
}
示例#16
0
文件: test.c 项目: m1ch4ls/gfxprim
int timeout_fn(void)
{
	tst_msg("Sleeping for ten seconds");
	sleep(10);
	return TST_SUCCESS;
}