mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Merge branch 'wip/smcv/assert-no-errno' into 'master'
Make more use of g_assert_no_errno() See merge request GNOME/glib!1731
This commit is contained in:
commit
7fd0d1c762
@ -11,7 +11,7 @@ setup (Fixture *fixture,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
fixture->applications_dir = g_build_filename (g_get_user_data_dir (), "applications", NULL);
|
||||
g_assert_cmpint (g_mkdir_with_parents (fixture->applications_dir, 0755), ==, 0);
|
||||
g_assert_no_errno (g_mkdir_with_parents (fixture->applications_dir, 0755));
|
||||
|
||||
g_test_message ("Using data directory: %s", g_get_user_data_dir ());
|
||||
}
|
||||
@ -20,7 +20,7 @@ static void
|
||||
teardown (Fixture *fixture,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
g_assert_cmpint (g_rmdir (fixture->applications_dir), ==, 0);
|
||||
g_assert_no_errno (g_rmdir (fixture->applications_dir));
|
||||
g_clear_pointer (&fixture->applications_dir, g_free);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ static void
|
||||
teardown (Fixture *fixture,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
g_assert_cmpint (g_rmdir (fixture->tmp_dir), ==, 0);
|
||||
g_assert_no_errno (g_rmdir (fixture->tmp_dir));
|
||||
g_clear_pointer (&fixture->tmp_dir, g_free);
|
||||
}
|
||||
|
||||
@ -1844,7 +1844,7 @@ test_keyfile (Fixture *fixture,
|
||||
g_signal_connect (settings, "writable-changed::greeting",
|
||||
G_CALLBACK (key_changed_cb), &called);
|
||||
|
||||
g_chmod (keyfile_path, 0500);
|
||||
g_assert_no_errno (g_chmod (keyfile_path, 0500));
|
||||
while (!called)
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
g_signal_handlers_disconnect_by_func (settings, key_changed_cb, &called);
|
||||
@ -1859,9 +1859,9 @@ test_keyfile (Fixture *fixture,
|
||||
g_object_unref (settings);
|
||||
|
||||
/* Clean up the temporary directory. */
|
||||
g_chmod (keyfile_path, 0777);
|
||||
g_assert_cmpint (g_remove (store_path), ==, 0);
|
||||
g_rmdir (keyfile_path);
|
||||
g_assert_no_errno (g_chmod (keyfile_path, 0777));
|
||||
g_assert_no_errno (g_remove (store_path));
|
||||
g_assert_no_errno (g_rmdir (keyfile_path));
|
||||
g_free (store_path);
|
||||
g_free (keyfile_path);
|
||||
}
|
||||
|
@ -149,13 +149,13 @@ check_cap_dac_override (const char *tmpdir)
|
||||
dac_denies_write = g_build_filename (tmpdir, "dac-denies-write", NULL);
|
||||
inside = g_build_filename (dac_denies_write, "inside", NULL);
|
||||
|
||||
g_assert_cmpint (mkdir (dac_denies_write, S_IRWXU) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_cmpint (chmod (dac_denies_write, 0) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (mkdir (dac_denies_write, S_IRWXU));
|
||||
g_assert_no_errno (chmod (dac_denies_write, 0));
|
||||
|
||||
if (mkdir (inside, S_IRWXU) == 0)
|
||||
{
|
||||
g_test_message ("Looks like we have CAP_DAC_OVERRIDE or equivalent");
|
||||
g_assert_cmpint (rmdir (inside) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (rmdir (inside));
|
||||
have_cap = TRUE;
|
||||
}
|
||||
else
|
||||
@ -167,8 +167,8 @@ check_cap_dac_override (const char *tmpdir)
|
||||
have_cap = FALSE;
|
||||
}
|
||||
|
||||
g_assert_cmpint (chmod (dac_denies_write, S_IRWXU) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_cmpint (rmdir (dac_denies_write) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (chmod (dac_denies_write, S_IRWXU));
|
||||
g_assert_no_errno (rmdir (dac_denies_write));
|
||||
g_free (dac_denies_write);
|
||||
g_free (inside);
|
||||
return have_cap;
|
||||
|
@ -557,13 +557,13 @@ check_cap_dac_override (const char *tmpdir)
|
||||
dac_denies_write = g_build_filename (tmpdir, "dac-denies-write", NULL);
|
||||
inside = g_build_filename (dac_denies_write, "inside", NULL);
|
||||
|
||||
g_assert_cmpint (mkdir (dac_denies_write, S_IRWXU) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_cmpint (chmod (dac_denies_write, 0) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (mkdir (dac_denies_write, S_IRWXU));
|
||||
g_assert_no_errno (chmod (dac_denies_write, 0));
|
||||
|
||||
if (mkdir (inside, S_IRWXU) == 0)
|
||||
{
|
||||
g_test_message ("Looks like we have CAP_DAC_OVERRIDE or equivalent");
|
||||
g_assert_cmpint (rmdir (inside) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (rmdir (inside));
|
||||
have_cap = TRUE;
|
||||
}
|
||||
else
|
||||
@ -575,8 +575,8 @@ check_cap_dac_override (const char *tmpdir)
|
||||
have_cap = FALSE;
|
||||
}
|
||||
|
||||
g_assert_cmpint (chmod (dac_denies_write, S_IRWXU) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_cmpint (rmdir (dac_denies_write) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (chmod (dac_denies_write, S_IRWXU));
|
||||
g_assert_no_errno (rmdir (dac_denies_write));
|
||||
g_free (dac_denies_write);
|
||||
g_free (inside);
|
||||
return have_cap;
|
||||
@ -606,8 +606,8 @@ test_mkdir_with_parents_permission (void)
|
||||
subdir = g_build_filename (tmpdir, "sub", NULL);
|
||||
subdir2 = g_build_filename (subdir, "sub2", NULL);
|
||||
subdir3 = g_build_filename (subdir2, "sub3", NULL);
|
||||
g_assert_cmpint (g_mkdir (subdir, 0700) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_cmpint (g_chmod (subdir, 0) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (g_mkdir (subdir, 0700));
|
||||
g_assert_no_errno (g_chmod (subdir, 0));
|
||||
|
||||
if (have_cap_dac_override)
|
||||
{
|
||||
@ -625,11 +625,11 @@ test_mkdir_with_parents_permission (void)
|
||||
g_assert_cmpint (result, ==, -1);
|
||||
g_assert_cmpint (saved_errno, ==, EACCES);
|
||||
|
||||
g_assert_cmpint (g_chmod (subdir, 0700) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (g_chmod (subdir, 0700));
|
||||
}
|
||||
|
||||
g_assert_cmpint (g_remove (subdir) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_cmpint (g_remove (tmpdir) == 0 ? 0 : errno, ==, 0);
|
||||
g_assert_no_errno (g_remove (subdir));
|
||||
g_assert_no_errno (g_remove (tmpdir));
|
||||
g_free (subdir3);
|
||||
g_free (subdir2);
|
||||
g_free (subdir);
|
||||
|
Loading…
Reference in New Issue
Block a user