Commit dec19db2 authored by Slava Monich's avatar Slava Monich

[test] Updated test_retrieve to use glib test framework

parent 75c00c08
......@@ -58,6 +58,35 @@ test_dirs_cleanup(
g_free(dirs->attic);
}
gboolean
test_files_equal(
const char* path1,
const char* path2)
{
gboolean equal = FALSE;
if (path1 && path2) {
GError* error = NULL;
GMappedFile* f1 = g_mapped_file_new(path1, FALSE, &error);
if (f1) {
GMappedFile* f2 = g_mapped_file_new(path2, FALSE, &error);
if (f2) {
const gsize size = g_mapped_file_get_length(f1);
if (g_mapped_file_get_length(f2) == size) {
const void* data1 = g_mapped_file_get_contents(f1);
const void* data2 = g_mapped_file_get_contents(f2);
equal = !memcmp(data1, data2, size);
}
g_mapped_file_unref(f2);
}
g_mapped_file_unref(f1);
}
}
if (!equal) {
GERR("%s is not identical to %s", path1, path2);
}
return equal;
}
/* Should be invoked after g_test_init */
void
test_init(
......
......@@ -42,6 +42,11 @@ test_dirs_cleanup(
TestDirs* dirs,
gboolean remove);
gboolean
test_files_equal(
const char* path1,
const char* path2);
/* Should be invoked after g_test_init */
void
test_init(
......
# -*- Mode: makefile-gmake -*-
EXE = test_retrieve
SRC = $(EXE).c
COMMON_SRC = test_connection.c test_connman.c test_handler.c test_http.c \
test_transfer_list.c test_util.c
......
This diff is collapsed.
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