Commit 08b61888 authored by Slava Monich's avatar Slava Monich

[test_resize] Don't use g_file_copy, it crashes qemu

Now it should be possible to automatically run unit tests in OBS
parent 6a87b890
......@@ -319,6 +319,31 @@ test_png_size(
return ok;
}
static
gboolean
test_file_copy(
const char* src,
const char* dest)
{
gboolean ok = FALSE;
FILE* in = fopen(src, "rb");
if (in) {
FILE* out = fopen(dest, "wb");
if (out) {
const size_t buflen = 4096;
size_t nbytes;
void* buf = g_malloc(buflen);
while ((nbytes = fread(buf, 1, buflen, in)) > 0 &&
fwrite(buf, 1, nbytes, out) == nbytes);
ok = (feof(in) && !ferror(in) && !ferror(out));
g_free(buf);
fclose(out);
}
fclose(in);
}
return ok;
}
static
int
test_run_one(
......@@ -334,9 +359,7 @@ test_run_one(
if (dir) {
GError* error = NULL;
char* testfile = g_strconcat(dir, "/", name, NULL);
GFile* src = g_file_new_for_path(test->file);
GFile* dest = g_file_new_for_path(testfile);
if (g_file_copy(src, dest, 0, NULL, NULL, NULL, &error)) {
if (test_file_copy(test->file, testfile)) {
MMSAttachment* at;
MMSAttachmentInfo info;
MMSConfig test_config = *config;
......@@ -377,11 +400,8 @@ test_run_one(
g_error_free(error);
}
} else {
MMS_ERR("%s", MMS_ERRMSG(error));
g_error_free(error);
MMS_ERR("Failed to copy %s -> %s", test->file, testfile);
}
g_object_unref(src);
g_object_unref(dest);
g_free(testfile);
}
MMS_INFO("%s: %s", (ret == RET_OK) ? "OK" : "FAILED", test->name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment