mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
tests: Remove custom printerr logging from live-g-file
Use `g_test_message()` instead, so that the logs get treated properly for TAP output. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
6ed23087b5
commit
5d469dbe5a
@ -177,20 +177,6 @@ check_cap_dac_override (const char *tmpdir)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G_HAVE_ISO_VARARGS
|
||||
#define log(...) if (verbose) g_printerr (__VA_ARGS__)
|
||||
#elif defined(G_HAVE_GNUC_VARARGS)
|
||||
#define log(msg...) if (verbose) g_printerr (msg)
|
||||
#else /* no varargs macros */
|
||||
static void log (const g_char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
if (verbose) g_printerr (format, args);
|
||||
va_end (args);
|
||||
}
|
||||
#endif
|
||||
|
||||
static GFile *
|
||||
create_empty_file (GFile * parent, const char *filename,
|
||||
GFileCreateFlags create_flags)
|
||||
@ -257,8 +243,8 @@ test_create_structure (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Going to create testing structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
g_test_message ("\n Going to create testing structure in '%s'...",
|
||||
(char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -280,16 +266,16 @@ test_create_structure (gconstpointer test_data)
|
||||
switch (item.file_type)
|
||||
{
|
||||
case G_FILE_TYPE_REGULAR:
|
||||
log (" Creating file '%s'...\n", item.filename);
|
||||
g_test_message (" Creating file '%s'...", item.filename);
|
||||
child = create_empty_file (root, item.filename, item.create_flags);
|
||||
break;
|
||||
case G_FILE_TYPE_DIRECTORY:
|
||||
log (" Creating directory '%s'...\n", item.filename);
|
||||
g_test_message (" Creating directory '%s'...", item.filename);
|
||||
child = create_empty_dir (root, item.filename);
|
||||
break;
|
||||
case G_FILE_TYPE_SYMBOLIC_LINK:
|
||||
log (" Creating symlink '%s' --> '%s'...\n", item.filename,
|
||||
item.link_to);
|
||||
g_test_message (" Creating symlink '%s' --> '%s'...", item.filename,
|
||||
item.link_to);
|
||||
child = create_symlink (root, item.filename, item.link_to);
|
||||
break;
|
||||
case G_FILE_TYPE_UNKNOWN:
|
||||
@ -334,7 +320,7 @@ test_create_structure (gconstpointer test_data)
|
||||
}
|
||||
|
||||
/* create a pattern file */
|
||||
log (" Creating pattern file...");
|
||||
g_test_message (" Creating pattern file...");
|
||||
child = g_file_get_child (root, "pattern_file");
|
||||
g_assert_nonnull (child);
|
||||
|
||||
@ -356,7 +342,7 @@ test_create_structure (gconstpointer test_data)
|
||||
g_object_unref (outds);
|
||||
g_object_unref (outs);
|
||||
g_object_unref (child);
|
||||
log (" done.\n");
|
||||
g_test_message (" done.");
|
||||
|
||||
g_object_unref (root);
|
||||
}
|
||||
@ -503,7 +489,7 @@ test_initial_structure (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Testing sample structure in '%s'...\n", (char *) test_data);
|
||||
g_test_message (" Testing sample structure in '%s'...", (char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -518,7 +504,7 @@ test_initial_structure (gconstpointer test_data)
|
||||
|| (item.handle_special))
|
||||
continue;
|
||||
|
||||
log (" Testing file '%s'...\n", item.filename);
|
||||
g_test_message (" Testing file '%s'...", item.filename);
|
||||
|
||||
child = file_exists (root, item.filename, &res);
|
||||
g_assert_nonnull (child);
|
||||
@ -538,7 +524,7 @@ test_initial_structure (gconstpointer test_data)
|
||||
}
|
||||
|
||||
/* read and test the pattern file */
|
||||
log (" Testing pattern file...\n");
|
||||
g_test_message (" Testing pattern file...");
|
||||
child = file_exists (root, "pattern_file", &res);
|
||||
g_assert_nonnull (child);
|
||||
g_assert_true (res);
|
||||
@ -569,8 +555,8 @@ test_initial_structure (gconstpointer test_data)
|
||||
PATTERN_FILE_SIZE, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
total_read += read;
|
||||
log (" read %"G_GSSIZE_FORMAT" bytes, total = %"G_GSSIZE_FORMAT" of %d.\n",
|
||||
read, total_read, PATTERN_FILE_SIZE);
|
||||
g_test_message (" read %"G_GSSIZE_FORMAT" bytes, total = %"G_GSSIZE_FORMAT" of %d.",
|
||||
read, total_read, PATTERN_FILE_SIZE);
|
||||
}
|
||||
g_assert_cmpint (total_read, ==, PATTERN_FILE_SIZE);
|
||||
|
||||
@ -635,8 +621,8 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
}
|
||||
g_assert_true (found);
|
||||
|
||||
log (" Found file %s, relative to root: %s\n",
|
||||
g_file_info_get_display_name (info), relative_path);
|
||||
g_test_message (" Found file %s, relative to root: %s",
|
||||
g_file_info_get_display_name (info), relative_path);
|
||||
|
||||
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
|
||||
traverse_recurse_dirs (descend, root);
|
||||
@ -666,8 +652,8 @@ test_traverse_structure (gconstpointer test_data)
|
||||
gboolean res;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Traversing through the sample structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
g_test_message (" Traversing through the sample structure in '%s'...",
|
||||
(char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -695,7 +681,7 @@ test_enumerate (gconstpointer test_data)
|
||||
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Test enumerate '%s'...\n", (char *) test_data);
|
||||
g_test_message (" Test enumerate '%s'...", (char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -715,7 +701,7 @@ test_enumerate (gconstpointer test_data)
|
||||
|| ((item.extra_flags & TEST_ENUMERATE_FILE) ==
|
||||
TEST_ENUMERATE_FILE))
|
||||
{
|
||||
log (" Testing file '%s'\n", item.filename);
|
||||
g_test_message (" Testing file '%s'", item.filename);
|
||||
child = g_file_get_child (root, item.filename);
|
||||
g_assert_nonnull (child);
|
||||
error = NULL;
|
||||
@ -774,7 +760,7 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
gboolean have_cap_dac_override = check_cap_dac_override (g_file_peek_path (root));
|
||||
#endif
|
||||
|
||||
log (" do_copy_move: '%s' --> '%s'\n", item.filename, target_dir);
|
||||
g_test_message (" do_copy_move: '%s' --> '%s'", item.filename, target_dir);
|
||||
|
||||
dst_dir = g_file_get_child (root, target_dir);
|
||||
g_assert_nonnull (dst_dir);
|
||||
@ -797,8 +783,8 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
NULL, NULL, &error);
|
||||
|
||||
if (error)
|
||||
log (" res = %d, error code %d = %s\n", res, error->code,
|
||||
error->message);
|
||||
g_test_message (" res = %d, error code %d = %s", res, error->code,
|
||||
error->message);
|
||||
|
||||
/* copying file/directory to itself (".") */
|
||||
if (((item.extra_flags & TEST_NOT_EXISTS) != TEST_NOT_EXISTS) &&
|
||||
@ -873,8 +859,6 @@ test_copy_move (gconstpointer test_data)
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
|
||||
log ("\n");
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -966,7 +950,6 @@ test_create (gconstpointer test_data)
|
||||
GFileOutputStream *os;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n");
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -981,7 +964,7 @@ test_create (gconstpointer test_data)
|
||||
((item.extra_flags & TEST_REPLACE) == TEST_REPLACE) ||
|
||||
((item.extra_flags & TEST_APPEND) == TEST_APPEND))
|
||||
{
|
||||
log (" test_create: '%s'\n", item.filename);
|
||||
g_test_message (" test_create: '%s'", item.filename);
|
||||
|
||||
child = g_file_get_child (root, item.filename);
|
||||
g_assert_nonnull (child);
|
||||
@ -999,7 +982,7 @@ test_create (gconstpointer test_data)
|
||||
|
||||
|
||||
if (error)
|
||||
log (" error code %d = %s\n", error->code, error->message);
|
||||
g_test_message (" error code %d = %s", error->code, error->message);
|
||||
|
||||
if (((item.extra_flags & TEST_NOT_EXISTS) == 0) &&
|
||||
((item.extra_flags & TEST_CREATE) == TEST_CREATE))
|
||||
@ -1030,8 +1013,8 @@ test_create (gconstpointer test_data)
|
||||
res =
|
||||
g_output_stream_close (G_OUTPUT_STREAM (os), NULL, &error);
|
||||
if (error)
|
||||
log (" g_output_stream_close: error %d = %s\n",
|
||||
error->code, error->message);
|
||||
g_test_message (" g_output_stream_close: error %d = %s",
|
||||
error->code, error->message);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
g_object_unref (os);
|
||||
@ -1053,7 +1036,6 @@ test_open (gconstpointer test_data)
|
||||
GFileInputStream *input_stream;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n");
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -1069,7 +1051,7 @@ test_open (gconstpointer test_data)
|
||||
|
||||
if ((item.extra_flags & TEST_OPEN) == TEST_OPEN)
|
||||
{
|
||||
log (" test_open: '%s'\n", item.filename);
|
||||
g_test_message (" test_open: '%s'", item.filename);
|
||||
|
||||
child = g_file_get_child (root, item.filename);
|
||||
g_assert_nonnull (child);
|
||||
@ -1125,7 +1107,6 @@ test_delete (gconstpointer test_data)
|
||||
gchar *path;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n");
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
@ -1147,7 +1128,7 @@ test_delete (gconstpointer test_data)
|
||||
/* we don't care about result here */
|
||||
|
||||
path = g_file_get_path (child);
|
||||
log (" Deleting %s, path = %s\n", item.filename, path);
|
||||
g_test_message (" Deleting %s, path = %s", item.filename, path);
|
||||
g_free (path);
|
||||
|
||||
error = NULL;
|
||||
@ -1175,7 +1156,7 @@ test_delete (gconstpointer test_data)
|
||||
|
||||
if (error)
|
||||
{
|
||||
log (" result = %d, error = %s\n", res, error->message);
|
||||
g_test_message (" result = %d, error = %s", res, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
@ -1313,7 +1294,7 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
||||
g_assert_nonnull (relative_path);
|
||||
g_free (relative_path);
|
||||
|
||||
log (" deleting '%s'\n", g_file_info_get_display_name (info));
|
||||
g_test_message (" deleting '%s'", g_file_info_get_display_name (info));
|
||||
|
||||
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
|
||||
cleanup_dir_recurse (descend, root);
|
||||
@ -1344,8 +1325,8 @@ prep_clean_structure (gconstpointer test_data)
|
||||
GFile *root;
|
||||
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Cleaning target testing structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
g_test_message (" Cleaning target testing structure in '%s'...",
|
||||
(char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert_nonnull (root);
|
||||
|
Loading…
Reference in New Issue
Block a user