config/tests: avoid test failure for valgrind due to g_file_copy()

Valgrind doesn't like it, so don't use g_file_copy().

  ==10410== Syscall param ioctl(generic) points to unaddressable byte(s)
  ==10410==    at 0x82E1707: ioctl (syscall-template.S:84)
  ==10410==    by 0x7712E71: btrfs_reflink_with_progress (gfile.c:3012)
  ==10410==    by 0x7712E71: file_copy_fallback (gfile.c:3186)
  ==10410==    by 0x7712E71: g_file_copy (gfile.c:3394)
  ==10410==    by 0x1350CA: test_config_state_file (test-config.c:948)
  ==10410==    by 0x7D0845A: test_case_run (gtestutils.c:2158)
  ==10410==    by 0x7D0845A: g_test_run_suite_internal (gtestutils.c:2241)
  ==10410==    by 0x7D08622: g_test_run_suite_internal (gtestutils.c:2253)
  ==10410==    by 0x7D0882D: g_test_run_suite (gtestutils.c:2328)
  ==10410==    by 0x7D08850: g_test_run (gtestutils.c:1596)
  ==10410==    by 0x12EFA4: main (test-config.c:1032)
  ==10410==  Address 0x9 is not stack'd, malloc'd or (recently) free'd
  ==10410==

Fixes: e3a30665d7
This commit is contained in:
Thomas Haller 2016-04-08 10:34:25 +02:00
parent d0836be0eb
commit 8f8bf0d315

View file

@ -935,21 +935,19 @@ test_config_state_file (void)
{
NMConfig *config;
const NMConfigState *state;
gs_unref_object GFile *src = NULL, *dst = NULL;
const char *tmp_file = BUILDDIR "/tmp.state";
GError *error = NULL;
gs_free_error GError *error = NULL;
gboolean ret;
gs_free char *file_data = NULL;
gsize file_size;
const char *const TMP_FILE = BUILDDIR "/tmp.state";
src = g_file_new_for_path (SRCDIR "/NetworkManager.state");
g_assert (src);
dst = g_file_new_for_path (tmp_file);
g_assert (dst);
ret = g_file_copy (src, dst, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error);
ret = g_file_get_contents (SRCDIR "/NetworkManager.state", &file_data, &file_size, &error);
nmtst_assert_success (ret, error);
ret = g_file_set_contents (TMP_FILE, file_data, file_size, &error);
nmtst_assert_success (ret, error);
config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "",
"--state-file", tmp_file, NULL);
"--state-file", TMP_FILE, NULL);
g_assert (config);
state = nm_config_state_get (config);
@ -975,7 +973,7 @@ test_config_state_file (void)
/* Reload configuration */
config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "",
"--state-file", tmp_file, NULL);
"--state-file", TMP_FILE, NULL);
g_assert (config);
state = nm_config_state_get (config);
@ -986,7 +984,7 @@ test_config_state_file (void)
g_assert_cmpint (state->wwan_enabled, ==, FALSE);
g_object_unref (config);
unlink (tmp_file);
unlink (TMP_FILE);
}
/*****************************************************************************/