Esempio n. 1
0
int tst_msg_append(struct tst_msg_store *self, int type, const char *msg_text)
{
	size_t len = strlen(msg_text);
	struct tst_msg *msg;

	msg = malloc(sizeof(struct tst_msg) + len + 1);

	if (msg == NULL) {
		tst_warn("tst_msg: malloc() failed: %s", strerror(errno));
		return 1;
	}

	msg->type = type;
	msg->next = NULL;
	strcpy(msg->msg, msg_text);

	if (self->last == NULL) {
		self->first = msg;
		self->last = msg;
	} else {
		self->last->next = msg;
		self->last = msg;
	}

	return 0;
}
Esempio n. 2
0
/*
 * Removes recursively temporary directory.
 */
static void remove_tmpdir(const char *path)
{
	/*
	 * Assert that we are working in /tmp/
	 */
	if (!strncmp("/tmp/", path, sizeof("/tmp/"))) {
		tst_warn("Path '%s' doesn't start with /tmp/, "
		         "omitting cleanup", path);
		return;
	}

	//TODO: Cleaner solution?
	char buf[256];
	int ret;

	snprintf(buf, sizeof(buf), "rm -rf '%s'", path);
	ret = system(buf);

	if (ret)
		tst_warn("Failed to clean temp dir.");
}
Esempio n. 3
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;
}