summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/libostreetest.c40
-rw-r--r--tests/libostreetest.h12
-rw-r--r--tests/repo-finder-mount.c50
-rw-r--r--tests/test-basic-c.c280
-rw-r--r--tests/test-bloom.c37
-rw-r--r--tests/test-bsdiff.c34
-rw-r--r--tests/test-checksum.c25
-rw-r--r--tests/test-commit-sign-sh-ext.c33
-rw-r--r--tests/test-gpg-verify-result.c354
-rw-r--r--tests/test-include-ostree-h.c5
-rw-r--r--tests/test-kargs.c71
-rw-r--r--tests/test-keyfile-utils.c155
-rw-r--r--tests/test-libarchive-import.c182
-rw-r--r--tests/test-lzma.c65
-rw-r--r--tests/test-mock-gio.c38
-rw-r--r--tests/test-mock-gio.h92
-rw-r--r--tests/test-mutable-tree.c52
-rw-r--r--tests/test-ot-opt-utils.c15
-rw-r--r--tests/test-ot-tool-util.c29
-rw-r--r--tests/test-ot-unix-utils.c15
-rw-r--r--tests/test-pull-c.c52
-rw-r--r--tests/test-repo-finder-avahi.c117
-rw-r--r--tests/test-repo-finder-config.c210
-rw-r--r--tests/test-repo-finder-mount.c327
-rw-r--r--tests/test-repo.c275
-rw-r--r--tests/test-rfc2616-dates.c97
-rw-r--r--tests/test-rollsum-cli.c10
-rw-r--r--tests/test-rollsum.c90
-rw-r--r--tests/test-sysroot-c.c25
-rw-r--r--tests/test-varint.c23
30 files changed, 1294 insertions, 1516 deletions
diff --git a/tests/libostreetest.c b/tests/libostreetest.c
index 08abb9f1..a1953561 100644
--- a/tests/libostreetest.c
+++ b/tests/libostreetest.c
@@ -34,11 +34,11 @@ ot_test_run_libtest (const char *cmd, GError **error)
g_assert (srcdir != NULL);
g_assert (cmd != NULL);
- g_autoptr(GPtrArray) argv = g_ptr_array_new ();
+ g_autoptr (GPtrArray) argv = g_ptr_array_new ();
g_ptr_array_add (argv, "bash");
g_ptr_array_add (argv, "-c");
- g_autoptr(GString) cmdstr = g_string_new ("");
+ g_autoptr (GString) cmdstr = g_string_new ("");
g_string_append (cmdstr, "set -xeuo pipefail; . ");
g_string_append (cmdstr, srcdir);
g_string_append (cmdstr, "/tests/libtest.sh; ");
@@ -48,8 +48,8 @@ ot_test_run_libtest (const char *cmd, GError **error)
g_ptr_array_add (argv, NULL);
int estatus;
- if (!g_spawn_sync (NULL, (char**)argv->pdata, NULL, G_SPAWN_SEARCH_PATH,
- NULL, NULL, NULL, NULL, &estatus, error))
+ if (!g_spawn_sync (NULL, (char **)argv->pdata, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL,
+ &estatus, error))
return FALSE;
if (!g_spawn_check_exit_status (estatus, error))
return FALSE;
@@ -58,14 +58,13 @@ ot_test_run_libtest (const char *cmd, GError **error)
}
OstreeRepo *
-ot_test_setup_repo (GCancellable *cancellable,
- GError **error)
+ot_test_setup_repo (GCancellable *cancellable, GError **error)
{
if (!ot_test_run_libtest ("setup_test_repository archive", error))
return NULL;
- g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
- g_autoptr(OstreeRepo) ret_repo = ostree_repo_new (repo_path);
+ g_autoptr (GFile) repo_path = g_file_new_for_path ("repo");
+ g_autoptr (OstreeRepo) ret_repo = ostree_repo_new (repo_path);
if (!ostree_repo_open (ret_repo, cancellable, error))
return NULL;
@@ -74,15 +73,16 @@ ot_test_setup_repo (GCancellable *cancellable,
/* Determine whether we're able to relabel files. Needed for bare tests. */
gboolean
-ot_check_relabeling (gboolean *can_relabel,
- GError **error)
+ot_check_relabeling (gboolean *can_relabel, GError **error)
{
- g_auto(GLnxTmpfile) tmpf = { 0, };
+ g_auto (GLnxTmpfile) tmpf = {
+ 0,
+ };
if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, ".", O_RDWR | O_CLOEXEC, &tmpf, error))
return FALSE;
- g_autoptr(GError) local_error = NULL;
- g_autoptr(GBytes) bytes = glnx_fgetxattr_bytes (tmpf.fd, "security.selinux", &local_error);
+ g_autoptr (GError) local_error = NULL;
+ g_autoptr (GBytes) bytes = glnx_fgetxattr_bytes (tmpf.fd, "security.selinux", &local_error);
if (!bytes)
{
/* libglnx preserves errno. The EOPNOTSUPP case can't be part of a
@@ -115,10 +115,11 @@ ot_check_relabeling (gboolean *can_relabel,
/* Determine whether the filesystem supports getting/setting user xattrs. */
gboolean
-ot_check_user_xattrs (gboolean *has_user_xattrs,
- GError **error)
+ot_check_user_xattrs (gboolean *has_user_xattrs, GError **error)
{
- g_auto(GLnxTmpfile) tmpf = { 0, };
+ g_auto (GLnxTmpfile) tmpf = {
+ 0,
+ };
if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, ".", O_RDWR | O_CLOEXEC, &tmpf, error))
return FALSE;
@@ -137,13 +138,12 @@ ot_check_user_xattrs (gboolean *has_user_xattrs,
}
OstreeSysroot *
-ot_test_setup_sysroot (GCancellable *cancellable,
- GError **error)
+ot_test_setup_sysroot (GCancellable *cancellable, GError **error)
{
if (!ot_test_run_libtest ("setup_os_repository \"archive\" \"syslinux\"", error))
return FALSE;
- g_autoptr(GString) buf = g_string_new ("mutable-deployments");
+ g_autoptr (GString) buf = g_string_new ("mutable-deployments");
gboolean can_relabel = FALSE;
if (!ot_check_relabeling (&can_relabel, error))
@@ -158,6 +158,6 @@ ot_test_setup_sysroot (GCancellable *cancellable,
if (!g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE))
return glnx_null_throw (error, "Failed to set environment variable OSTREE_SYSROOT_DEBUG");
- g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
+ g_autoptr (GFile) sysroot_path = g_file_new_for_path ("sysroot");
return ostree_sysroot_new (sysroot_path);
}
diff --git a/tests/libostreetest.h b/tests/libostreetest.h
index aacfe5ef..e593ac13 100644
--- a/tests/libostreetest.h
+++ b/tests/libostreetest.h
@@ -28,16 +28,12 @@ G_BEGIN_DECLS
gboolean ot_test_run_libtest (const char *cmd, GError **error);
-OstreeRepo *ot_test_setup_repo (GCancellable *cancellable,
- GError **error);
+OstreeRepo *ot_test_setup_repo (GCancellable *cancellable, GError **error);
-gboolean ot_check_relabeling (gboolean *can_relabel,
- GError **error);
+gboolean ot_check_relabeling (gboolean *can_relabel, GError **error);
-gboolean ot_check_user_xattrs (gboolean *has_user_xattrs,
- GError **error);
+gboolean ot_check_user_xattrs (gboolean *has_user_xattrs, GError **error);
-OstreeSysroot *ot_test_setup_sysroot (GCancellable *cancellable,
- GError **error);
+OstreeSysroot *ot_test_setup_sysroot (GCancellable *cancellable, GError **error);
G_END_DECLS
diff --git a/tests/repo-finder-mount.c b/tests/repo-finder-mount.c
index 66c4ecd7..68a0e3de 100644
--- a/tests/repo-finder-mount.c
+++ b/tests/repo-finder-mount.c
@@ -24,22 +24,20 @@
#include "config.h"
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <libglnx.h>
#include <locale.h>
#include "ostree-autocleanups.h"
#include "ostree-remote-private.h"
-#include "ostree-repo-finder.h"
#include "ostree-repo-finder-mount.h"
+#include "ostree-repo-finder.h"
#include "ostree-types.h"
#include "test-mock-gio.h"
static void
-result_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+result_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
GAsyncResult **result_out = user_data;
*result_out = g_object_ref (result);
@@ -54,33 +52,35 @@ collection_ref_free0 (OstreeCollectionRef *ref)
int
main (int argc, char **argv)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
setlocale (LC_ALL, "");
if (argc < 5 || (argc % 2) != 1)
{
- g_printerr ("Usage: %s REPO MOUNT-ROOT COLLECTION-ID REF-NAME [COLLECTION-ID REF-NAME …]\n", argv[0]);
+ g_printerr ("Usage: %s REPO MOUNT-ROOT COLLECTION-ID REF-NAME [COLLECTION-ID REF-NAME …]\n",
+ argv[0]);
return 1;
}
- g_autoptr(GMainContext) context = g_main_context_new ();
+ g_autoptr (GMainContext) context = g_main_context_new ();
g_main_context_push_thread_default (context);
- g_autoptr(OstreeRepo) parent_repo = ostree_repo_open_at (AT_FDCWD, argv[1], NULL, &error);
+ g_autoptr (OstreeRepo) parent_repo = ostree_repo_open_at (AT_FDCWD, argv[1], NULL, &error);
g_assert_no_error (error);
/* Set up a mock volume. */
- g_autoptr(GFile) mount_root = g_file_new_for_commandline_arg (argv[2]);
- g_autoptr(GMount) mount = G_MOUNT (ostree_mock_mount_new ("mount", mount_root));
+ g_autoptr (GFile) mount_root = g_file_new_for_commandline_arg (argv[2]);
+ g_autoptr (GMount) mount = G_MOUNT (ostree_mock_mount_new ("mount", mount_root));
- g_autoptr(GList) mounts = g_list_prepend (NULL, mount);
+ g_autoptr (GList) mounts = g_list_prepend (NULL, mount);
- g_autoptr(GVolumeMonitor) monitor = ostree_mock_volume_monitor_new (mounts, NULL);
- g_autoptr(OstreeRepoFinderMount) finder = ostree_repo_finder_mount_new (monitor);
+ g_autoptr (GVolumeMonitor) monitor = ostree_mock_volume_monitor_new (mounts, NULL);
+ g_autoptr (OstreeRepoFinderMount) finder = ostree_repo_finder_mount_new (monitor);
/* Resolve the refs. */
- g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func ((GDestroyNotify) collection_ref_free0);
+ g_autoptr (GPtrArray) refs
+ = g_ptr_array_new_with_free_func ((GDestroyNotify)collection_ref_free0);
for (gsize i = 3; i < argc; i += 2)
{
@@ -90,18 +90,18 @@ main (int argc, char **argv)
g_ptr_array_add (refs, ostree_collection_ref_new (collection_id, ref_name));
}
- g_ptr_array_add (refs, NULL); /* NULL terminator */
+ g_ptr_array_add (refs, NULL); /* NULL terminator */
- g_autoptr(GAsyncResult) async_result = NULL;
+ g_autoptr (GAsyncResult) async_result = NULL;
ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder),
- (const OstreeCollectionRef * const *) refs->pdata,
- parent_repo, NULL, result_cb, &async_result);
+ (const OstreeCollectionRef *const *)refs->pdata, parent_repo,
+ NULL, result_cb, &async_result);
while (async_result == NULL)
g_main_context_iteration (context, TRUE);
- g_autoptr(GPtrArray) results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder),
- async_result, &error);
+ g_autoptr (GPtrArray) results
+ = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder), async_result, &error);
g_assert_no_error (error);
/* Check that the results are correct: the invalid refs should have been
@@ -115,11 +115,9 @@ main (int argc, char **argv)
g_hash_table_iter_init (&iter, result->ref_to_checksum);
- while (g_hash_table_iter_next (&iter, (gpointer *) &ref, (gpointer *) &checksum))
- g_print ("%" G_GSIZE_FORMAT " %s %s %s %s\n",
- i, ostree_remote_get_name (result->remote),
- ref->collection_id, ref->ref_name,
- checksum);
+ while (g_hash_table_iter_next (&iter, (gpointer *)&ref, (gpointer *)&checksum))
+ g_print ("%" G_GSIZE_FORMAT " %s %s %s %s\n", i, ostree_remote_get_name (result->remote),
+ ref->collection_id, ref->ref_name, checksum);
}
g_main_context_pop_thread_default (context);
diff --git a/tests/test-basic-c.c b/tests/test-basic-c.c
index 7a6b8ee7..b9a15ef1 100644
--- a/tests/test-basic-c.c
+++ b/tests/test-basic-c.c
@@ -19,11 +19,11 @@
#include "config.h"
-#include <stdlib.h>
-#include <stdbool.h>
+#include <err.h>
#include <gio/gio.h>
+#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
-#include <err.h>
#include "libglnx.h"
#include "libostreetest.h"
@@ -31,25 +31,21 @@
static void
test_repo_is_not_system (gconstpointer data)
{
- OstreeRepo *repo = (void*)data;
+ OstreeRepo *repo = (void *)data;
g_assert (!ostree_repo_is_system (repo));
}
static GBytes *
input_stream_to_bytes (GInputStream *input)
{
- g_autoptr(GOutputStream) mem_out_stream = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GOutputStream) mem_out_stream = NULL;
+ g_autoptr (GError) error = NULL;
if (input == NULL)
return g_bytes_new (NULL, 0);
mem_out_stream = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
- g_output_stream_splice (mem_out_stream,
- input,
- G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- NULL,
- &error);
+ g_output_stream_splice (mem_out_stream, input, G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, NULL, &error);
g_assert_no_error (error);
return g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (mem_out_stream));
@@ -60,56 +56,41 @@ test_raw_file_to_archive_stream (gconstpointer data)
{
OstreeRepo *repo = OSTREE_REPO (data);
g_autofree gchar *commit_checksum = NULL;
- g_autoptr(GHashTable) reachable = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GHashTable) reachable = NULL;
+ g_autoptr (GError) error = NULL;
/* branch name of the test repository, see setup_test_repository in libtest.sh */
const gchar *rev = "test2";
GHashTableIter iter;
GVariant *serialized_object;
guint checks = 0;
- ostree_repo_resolve_rev (repo,
- rev,
- FALSE,
- &commit_checksum,
- &error);
+ ostree_repo_resolve_rev (repo, rev, FALSE, &commit_checksum, &error);
g_assert_no_error (error);
- ostree_repo_traverse_commit (repo,
- commit_checksum,
- -1,
- &reachable,
- NULL,
- &error);
+ ostree_repo_traverse_commit (repo, commit_checksum, -1, &reachable, NULL, &error);
g_assert_no_error (error);
g_hash_table_iter_init (&iter, reachable);
- while (g_hash_table_iter_next (&iter, (gpointer*)&serialized_object, NULL))
+ while (g_hash_table_iter_next (&iter, (gpointer *)&serialized_object, NULL))
{
const gchar *object_checksum;
OstreeObjectType object_type;
- g_autoptr(GInputStream) input = NULL;
- g_autoptr(GFileInfo) info = NULL;
- g_autoptr(GVariant) xattrs = NULL;
- g_autoptr(GBytes) input_bytes = NULL;
- g_autoptr(GInputStream) mem_input = NULL;
- g_autoptr(GInputStream) zlib_stream = NULL;
- g_autoptr(GBytes) zlib_bytes = NULL;
- g_autoptr(GInputStream) mem_zlib = NULL;
- g_autoptr(GInputStream) input2 = NULL;
- g_autoptr(GFileInfo) info2 = NULL;
- g_autoptr(GVariant) xattrs2 = NULL;
- g_autoptr(GBytes) input2_bytes = NULL;
+ g_autoptr (GInputStream) input = NULL;
+ g_autoptr (GFileInfo) info = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
+ g_autoptr (GBytes) input_bytes = NULL;
+ g_autoptr (GInputStream) mem_input = NULL;
+ g_autoptr (GInputStream) zlib_stream = NULL;
+ g_autoptr (GBytes) zlib_bytes = NULL;
+ g_autoptr (GInputStream) mem_zlib = NULL;
+ g_autoptr (GInputStream) input2 = NULL;
+ g_autoptr (GFileInfo) info2 = NULL;
+ g_autoptr (GVariant) xattrs2 = NULL;
+ g_autoptr (GBytes) input2_bytes = NULL;
ostree_object_name_deserialize (serialized_object, &object_checksum, &object_type);
if (object_type != OSTREE_OBJECT_TYPE_FILE)
continue;
- ostree_repo_load_file (repo,
- object_checksum,
- &input,
- &info,
- &xattrs,
- NULL,
- &error);
+ ostree_repo_load_file (repo, object_checksum, &input, &info, &xattrs, NULL, &error);
g_assert_no_error (error);
input_bytes = input_stream_to_bytes (input);
@@ -121,44 +102,21 @@ test_raw_file_to_archive_stream (gconstpointer data)
* GFileDescriptorBased interface. */
if (input != NULL)
mem_input = g_memory_input_stream_new_from_bytes (input_bytes);
- ostree_raw_file_to_archive_z2_stream (mem_input,
- info,
- xattrs,
- &zlib_stream,
- NULL,
- &error);
+ ostree_raw_file_to_archive_z2_stream (mem_input, info, xattrs, &zlib_stream, NULL, &error);
g_assert_no_error (error);
zlib_bytes = input_stream_to_bytes (zlib_stream);
mem_zlib = g_memory_input_stream_new_from_bytes (zlib_bytes);
- ostree_content_stream_parse (FALSE,
- mem_zlib,
- g_bytes_get_size (zlib_bytes),
- FALSE,
- &input2,
- &info2,
- &xattrs2,
- NULL,
- &error);
+ ostree_content_stream_parse (FALSE, mem_zlib, g_bytes_get_size (zlib_bytes), FALSE, &input2,
+ &info2, &xattrs2, NULL, &error);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_clear_error (&error);
- g_seekable_seek (G_SEEKABLE (mem_zlib),
- 0,
- G_SEEK_SET,
- NULL,
- &error);
+ g_seekable_seek (G_SEEKABLE (mem_zlib), 0, G_SEEK_SET, NULL, &error);
g_assert_no_error (error);
- ostree_content_stream_parse (TRUE,
- mem_zlib,
- g_bytes_get_size (zlib_bytes),
- FALSE,
- &input2,
- &info2,
- &xattrs2,
- NULL,
- &error);
+ ostree_content_stream_parse (TRUE, mem_zlib, g_bytes_get_size (zlib_bytes), FALSE, &input2,
+ &info2, &xattrs2, NULL, &error);
g_assert_no_error (error);
input2_bytes = input_stream_to_bytes (input2);
@@ -171,37 +129,38 @@ test_raw_file_to_archive_stream (gconstpointer data)
g_assert_cmpint (checks, >, 0);
}
-static gboolean hi_content_stream_new (GInputStream **out_stream,
- guint64 *out_length,
- GError **error)
+static gboolean
+hi_content_stream_new (GInputStream **out_stream, guint64 *out_length, GError **error)
{
static const char hi[] = "hi";
- const size_t len = sizeof(hi)-1;
- g_autoptr(GMemoryInputStream) hi_memstream = (GMemoryInputStream*)g_memory_input_stream_new_from_data (hi, len, NULL);
- g_autoptr(GFileInfo) finfo = g_file_info_new ();
+ const size_t len = sizeof (hi) - 1;
+ g_autoptr (GMemoryInputStream) hi_memstream
+ = (GMemoryInputStream *)g_memory_input_stream_new_from_data (hi, len, NULL);
+ g_autoptr (GFileInfo) finfo = g_file_info_new ();
g_file_info_set_attribute_uint32 (finfo, "standard::type", G_FILE_TYPE_REGULAR);
g_file_info_set_attribute_boolean (finfo, "standard::is-symlink", FALSE);
g_file_info_set_size (finfo, len);
g_file_info_set_attribute_uint32 (finfo, "unix::uid", 0);
g_file_info_set_attribute_uint32 (finfo, "unix::gid", 0);
- g_file_info_set_attribute_uint32 (finfo, "unix::mode", S_IFREG|0644);
- return ostree_raw_file_to_content_stream ((GInputStream*)hi_memstream, finfo, NULL, out_stream, out_length, NULL, error);
+ g_file_info_set_attribute_uint32 (finfo, "unix::mode", S_IFREG | 0644);
+ return ostree_raw_file_to_content_stream ((GInputStream *)hi_memstream, finfo, NULL, out_stream,
+ out_length, NULL, error);
}
static void
test_validate_remotename (void)
{
- const char *valid[] = {"foo", "hello-world"};
- const char *invalid[] = {"foo/bar", ""};
- for (guint i = 0; i < G_N_ELEMENTS(valid); i++)
+ const char *valid[] = { "foo", "hello-world" };
+ const char *invalid[] = { "foo/bar", "" };
+ for (guint i = 0; i < G_N_ELEMENTS (valid); i++)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
g_assert (ostree_validate_remote_name (valid[i], &error));
g_assert_no_error (error);
}
- for (guint i = 0; i < G_N_ELEMENTS(invalid); i++)
+ for (guint i = 0; i < G_N_ELEMENTS (invalid); i++)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
g_assert (!ostree_validate_remote_name (invalid[i], &error));
g_assert (error != NULL);
}
@@ -211,39 +170,40 @@ static void
test_object_writes (gconstpointer data)
{
OstreeRepo *repo = OSTREE_REPO (data);
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
- static const char hi_sha256[] = "2301b5923720c3edc1f0467addb5c287fd5559e3e0cd1396e7f1edb6b01be9f0";
+ static const char hi_sha256[]
+ = "2301b5923720c3edc1f0467addb5c287fd5559e3e0cd1396e7f1edb6b01be9f0";
/* Successful content write */
- { g_autoptr(GInputStream) hi_memstream = NULL;
+ {
+ g_autoptr (GInputStream) hi_memstream = NULL;
guint64 len;
hi_content_stream_new (&hi_memstream, &len, &error);
g_assert_no_error (error);
g_autofree guchar *csum = NULL;
- (void)ostree_repo_write_content (repo, hi_sha256, hi_memstream, len, &csum,
- NULL, &error);
+ (void)ostree_repo_write_content (repo, hi_sha256, hi_memstream, len, &csum, NULL, &error);
g_assert_no_error (error);
}
/* Invalid content write */
- { g_autoptr(GInputStream) hi_memstream = NULL;
+ {
+ g_autoptr (GInputStream) hi_memstream = NULL;
guint64 len;
hi_content_stream_new (&hi_memstream, &len, &error);
g_assert_no_error (error);
g_autofree guchar *csum = NULL;
- static const char invalid_hi_sha256[] = "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe";
- g_assert (!ostree_repo_write_content (repo, invalid_hi_sha256, hi_memstream, len, &csum,
- NULL, &error));
+ static const char invalid_hi_sha256[]
+ = "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe";
+ g_assert (!ostree_repo_write_content (repo, invalid_hi_sha256, hi_memstream, len, &csum, NULL,
+ &error));
g_assert (error);
g_assert (strstr (error->message, "Corrupted file object"));
}
}
static gboolean
-impl_test_break_hardlink (int tmp_dfd,
- const char *path,
- GError **error)
+impl_test_break_hardlink (int tmp_dfd, const char *path, GError **error)
{
const char *linkedpath = glnx_strjoina (path, ".link");
struct stat orig_stbuf;
@@ -276,8 +236,8 @@ impl_test_break_hardlink (int tmp_dfd,
g_assert_cmpint (orig_stbuf.st_dev, ==, stbuf.st_dev);
g_assert_cmpint (orig_stbuf.st_ino, ==, stbuf.st_ino);
- (void) unlinkat (tmp_dfd, path, 0);
- (void) unlinkat (tmp_dfd, linkedpath, 0);
+ (void)unlinkat (tmp_dfd, path, 0);
+ (void)unlinkat (tmp_dfd, linkedpath, 0);
return TRUE;
}
@@ -286,14 +246,12 @@ static void
test_break_hardlink (void)
{
int tmp_dfd = AT_FDCWD;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
/* Regular file */
const char hello_hardlinked_content[] = "hello hardlinked content";
- glnx_file_replace_contents_at (tmp_dfd, "test-hardlink",
- (guint8*)hello_hardlinked_content,
- strlen (hello_hardlinked_content),
- GLNX_FILE_REPLACE_NODATASYNC,
+ glnx_file_replace_contents_at (tmp_dfd, "test-hardlink", (guint8 *)hello_hardlinked_content,
+ strlen (hello_hardlinked_content), GLNX_FILE_REPLACE_NODATASYNC,
NULL, &error);
g_assert_no_error (error);
(void)impl_test_break_hardlink (tmp_dfd, "test-hardlink", &error);
@@ -306,11 +264,8 @@ test_break_hardlink (void)
g_assert_no_error (error);
}
-static GVariant*
-xattr_cb (OstreeRepo *repo,
- const char *path,
- GFileInfo *file_info,
- gpointer user_data)
+static GVariant *
+xattr_cb (OstreeRepo *repo, const char *path, GFileInfo *file_info, gpointer user_data)
{
GVariant *xattr = user_data;
if (g_str_equal (path, "/baz/cow"))
@@ -322,10 +277,10 @@ xattr_cb (OstreeRepo *repo,
static void
test_devino_cache_xattrs (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
gboolean ret = FALSE;
- g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
+ g_autoptr (GFile) repo_path = g_file_new_for_path ("repo");
/* re-initialize as bare */
ret = ot_test_run_libtest ("setup_test_repository bare", &error);
@@ -349,7 +304,7 @@ test_devino_cache_xattrs (void)
return;
}
- g_autoptr(OstreeRepo) repo = ostree_repo_new (repo_path);
+ g_autoptr (OstreeRepo) repo = ostree_repo_new (repo_path);
ret = ostree_repo_open (repo, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
@@ -359,47 +314,47 @@ test_devino_cache_xattrs (void)
g_assert_no_error (error);
g_assert (ret);
- g_autoptr(OstreeRepoDevInoCache) cache = ostree_repo_devino_cache_new ();
+ g_autoptr (OstreeRepoDevInoCache) cache = ostree_repo_devino_cache_new ();
- OstreeRepoCheckoutAtOptions options = {0,};
+ OstreeRepoCheckoutAtOptions options = {
+ 0,
+ };
options.no_copy_fallback = TRUE;
options.devino_to_csum_cache = cache;
ret = ostree_repo_checkout_at (repo, &options, AT_FDCWD, "checkout", csum, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
- g_autoptr(OstreeMutableTree) mtree = ostree_mutable_tree_new ();
- g_autoptr(OstreeRepoCommitModifier) modifier =
- ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
+ g_autoptr (OstreeMutableTree) mtree = ostree_mutable_tree_new ();
+ g_autoptr (OstreeRepoCommitModifier) modifier
+ = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
ostree_repo_commit_modifier_set_devino_cache (modifier, cache);
- g_auto(GVariantBuilder) builder;
- g_variant_builder_init (&builder, (GVariantType*)"a(ayay)");
- g_variant_builder_add (&builder, "(@ay@ay)",
- g_variant_new_bytestring ("user.myattr"),
+ g_auto (GVariantBuilder) builder;
+ g_variant_builder_init (&builder, (GVariantType *)"a(ayay)");
+ g_variant_builder_add (&builder, "(@ay@ay)", g_variant_new_bytestring ("user.myattr"),
g_variant_new_bytestring ("data"));
- g_autoptr(GVariant) orig_xattrs = g_variant_ref_sink (g_variant_builder_end (&builder));
+ g_autoptr (GVariant) orig_xattrs = g_variant_ref_sink (g_variant_builder_end (&builder));
ret = ostree_repo_prepare_transaction (repo, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
ostree_repo_commit_modifier_set_xattr_callback (modifier, xattr_cb, NULL, orig_xattrs);
- ret = ostree_repo_write_dfd_to_mtree (repo, AT_FDCWD, "checkout",
- mtree, modifier, NULL, &error);
+ ret = ostree_repo_write_dfd_to_mtree (repo, AT_FDCWD, "checkout", mtree, modifier, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
- g_autoptr(GFile) root = NULL;
+ g_autoptr (GFile) root = NULL;
ret = ostree_repo_write_mtree (repo, mtree, &root, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
/* now check that the final xattr matches */
- g_autoptr(GFile) baz_child = g_file_get_child (root, "baz");
- g_autoptr(GFile) cow_child = g_file_get_child (baz_child, "cow");
+ g_autoptr (GFile) baz_child = g_file_get_child (root, "baz");
+ g_autoptr (GFile) cow_child = g_file_get_child (baz_child, "cow");
- g_autoptr(GVariant) xattrs = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
ret = ostree_repo_file_get_xattrs (OSTREE_REPO_FILE (cow_child), &xattrs, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
@@ -408,13 +363,13 @@ test_devino_cache_xattrs (void)
gsize n = g_variant_n_children (xattrs);
for (gsize i = 0; i < n; i++)
{
- const guint8* name;
- const guint8* value;
+ const guint8 *name;
+ const guint8 *value;
g_variant_get_child (xattrs, i, "(^&ay^&ay)", &name, &value);
- if (g_str_equal ((const char*)name, "user.myattr"))
+ if (g_str_equal ((const char *)name, "user.myattr"))
{
- g_assert_cmpstr ((const char*)value, ==, "data");
+ g_assert_cmpstr ((const char *)value, ==, "data");
found_xattr = TRUE;
break;
}
@@ -437,29 +392,28 @@ test_devino_cache_xattrs (void)
static void
test_big_metadata (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
gboolean ret = FALSE;
- g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
+ g_autoptr (GFile) repo_path = g_file_new_for_path ("repo");
/* init as bare-user-only so we run everywhere */
ret = ot_test_run_libtest ("setup_test_repository bare-user-only", &error);
g_assert_no_error (error);
g_assert (ret);
- g_autoptr(OstreeRepo) repo = ostree_repo_new (repo_path);
+ g_autoptr (OstreeRepo) repo = ostree_repo_new (repo_path);
ret = ostree_repo_open (repo, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
- g_autoptr(GFile) object_to_commit = NULL;
+ g_autoptr (GFile) object_to_commit = NULL;
ret = ostree_repo_read_commit (repo, "test2", &object_to_commit, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
- g_autoptr(OstreeMutableTree) mtree = ostree_mutable_tree_new ();
- ret = ostree_repo_write_directory_to_mtree (repo, object_to_commit, mtree, NULL,
- NULL, &error);
+ g_autoptr (OstreeMutableTree) mtree = ostree_mutable_tree_new ();
+ ret = ostree_repo_write_directory_to_mtree (repo, object_to_commit, mtree, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
@@ -467,14 +421,14 @@ test_big_metadata (void)
g_assert_cmpint (len, >, OSTREE_MAX_METADATA_SIZE);
g_autofree char *large_buf = g_malloc (len);
memset (large_buf, 0x42, len);
- g_autoptr(GVariantBuilder) builder =
- g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
g_autofree char *commit_checksum = NULL;
- g_variant_builder_add (builder, "{sv}", "large-value",
- g_variant_new_fixed_array ((GVariantType*)"y",
- large_buf, len, sizeof (char)));
+ g_variant_builder_add (
+ builder, "{sv}", "large-value",
+ g_variant_new_fixed_array ((GVariantType *)"y", large_buf, len, sizeof (char)));
ret = ostree_repo_write_commit (repo, NULL, NULL, NULL, g_variant_builder_end (builder),
- OSTREE_REPO_FILE (object_to_commit), &commit_checksum, NULL, &error);
+ OSTREE_REPO_FILE (object_to_commit), &commit_checksum, NULL,
+ &error);
g_assert_no_error (error);
g_assert (ret);
}
@@ -501,10 +455,12 @@ compare_xattrs (GVariant *orig, GVariant *new)
static void
test_read_xattrs (void)
{
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GError) local_error = NULL;
GError **error = &local_error;
- g_auto(GLnxTmpDir) tmpd = { 0, };
+ g_auto (GLnxTmpDir) tmpd = {
+ 0,
+ };
// Use /var/tmp to hope we get xattr support
glnx_mkdtempat (AT_FDCWD, "/var/tmp/ostree-xattrs-test.XXXXXX", 0700, &tmpd, error);
g_assert_no_error (local_error);
@@ -512,20 +468,20 @@ test_read_xattrs (void)
const char value[] = "foo";
{
- g_autoptr(GVariant) current_xattrs = ostree_fs_get_all_xattrs (tmpd.fd, NULL, error);
+ g_autoptr (GVariant) current_xattrs = ostree_fs_get_all_xattrs (tmpd.fd, NULL, error);
g_assert_no_error (local_error);
int r = fsetxattr (tmpd.fd, "user.ostreetesting", value, sizeof (value), 0);
if (r != 0)
{
- g_autofree gchar *message = g_strdup_printf ("Unable to set extended attributes in /var/tmp: %s",
- g_strerror (errno));
+ g_autofree gchar *message = g_strdup_printf (
+ "Unable to set extended attributes in /var/tmp: %s", g_strerror (errno));
g_test_skip (message);
return;
}
- g_autoptr(GVariant) new_xattrs = ostree_fs_get_all_xattrs (tmpd.fd, NULL, error);
+ g_autoptr (GVariant) new_xattrs = ostree_fs_get_all_xattrs (tmpd.fd, NULL, error);
g_assert_no_error (local_error);
compare_xattrs (current_xattrs, new_xattrs);
@@ -536,9 +492,10 @@ test_read_xattrs (void)
glnx_throw_errno_prefix (error, "symlinkat");
g_assert_no_error (local_error);
- g_autoptr(GVariant) current_xattrs = ostree_fs_get_all_xattrs_at (tmpd.fd, "somelink", NULL, error);
+ g_autoptr (GVariant) current_xattrs
+ = ostree_fs_get_all_xattrs_at (tmpd.fd, "somelink", NULL, error);
g_assert_no_error (local_error);
- (void) current_xattrs;
+ (void)current_xattrs;
// OK, can't do user. xattrs on symlinks unfortunately.
@@ -549,16 +506,17 @@ test_read_xattrs (void)
// glnx_throw_errno_prefix (error, "lsetxattr");
// g_assert_no_error (local_error);
- // g_autoptr(GVariant) new_xattrs = ostree_fs_get_all_xattrs_at (tmpd.fd, "somelink", NULL, error);
- // g_assert_no_error (local_error);
+ // g_autoptr(GVariant) new_xattrs = ostree_fs_get_all_xattrs_at (tmpd.fd, "somelink", NULL,
+ // error); g_assert_no_error (local_error);
// compare_xattrs (current_xattrs, new_xattrs);
}
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
glnx_unref_object OstreeRepo *repo = NULL;
g_test_init (&argc, &argv, NULL);
@@ -576,8 +534,8 @@ int main (int argc, char **argv)
g_test_add_func ("/big-metadata", test_big_metadata);
g_test_add_func ("/read-xattrs", test_read_xattrs);
- return g_test_run();
- out:
+ return g_test_run ();
+out:
if (error)
g_error ("%s", error->message);
return 1;
diff --git a/tests/test-bloom.c b/tests/test-bloom.c
index 970a882f..93f46ebf 100644
--- a/tests/test-bloom.c
+++ b/tests/test-bloom.c
@@ -31,8 +31,8 @@
static void
test_bloom_init (void)
{
- g_autoptr(OstreeBloom) bloom = NULL;
- g_autoptr(GBytes) bytes = NULL;
+ g_autoptr (OstreeBloom) bloom = NULL;
+ g_autoptr (GBytes) bytes = NULL;
bloom = ostree_bloom_new (1, 1, ostree_str_bloom_hash);
g_assert_cmpuint (ostree_bloom_get_size (bloom), ==, 1);
@@ -53,18 +53,12 @@ test_bloom_init (void)
static void
test_bloom_construction (void)
{
- g_autoptr(OstreeBloom) bloom = NULL;
- g_autoptr(OstreeBloom) immutable_bloom = NULL;
- g_autoptr(GBytes) bytes = NULL;
+ g_autoptr (OstreeBloom) bloom = NULL;
+ g_autoptr (OstreeBloom) immutable_bloom = NULL;
+ g_autoptr (GBytes) bytes = NULL;
gsize i;
- const gchar *members[] =
- {
- "hello", "there", "these", "are", "test", "strings"
- };
- const gchar *non_members[] =
- {
- "not", "an", "element"
- };
+ const gchar *members[] = { "hello", "there", "these", "are", "test", "strings" };
+ const gchar *non_members[] = { "not", "an", "element" };
const gsize n_bytes = 256;
const guint8 k = 8;
const OstreeBloomHashFunc hash = ostree_str_bloom_hash;
@@ -94,7 +88,7 @@ test_bloom_construction (void)
static void
test_bloom_empty (void)
{
- g_autoptr(OstreeBloom) bloom = NULL;
+ g_autoptr (OstreeBloom) bloom = NULL;
const gsize n_bytes = 256;
const guint8 k = 8;
const OstreeBloomHashFunc hash = ostree_str_bloom_hash;
@@ -111,12 +105,9 @@ test_bloom_empty (void)
static void
test_bloom_membership_during_construction (void)
{
- g_autoptr(OstreeBloom) bloom = NULL;
+ g_autoptr (OstreeBloom) bloom = NULL;
gsize i, j;
- const gchar *members[] =
- {
- "hello", "there", "these", "are", "test", "strings"
- };
+ const gchar *members[] = { "hello", "there", "these", "are", "test", "strings" };
const gsize n_bytes = 256;
const guint8 k = 8;
const OstreeBloomHashFunc hash = ostree_str_bloom_hash;
@@ -140,14 +131,16 @@ test_bloom_membership_during_construction (void)
}
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/bloom/init", test_bloom_init);
g_test_add_func ("/bloom/construction", test_bloom_construction);
g_test_add_func ("/bloom/empty", test_bloom_empty);
- g_test_add_func ("/bloom/membership-during-construction", test_bloom_membership_during_construction);
+ g_test_add_func ("/bloom/membership-during-construction",
+ test_bloom_membership_during_construction);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-bsdiff.c b/tests/test-bsdiff.c
index 4a9ac6cb..2d6b4722 100644
--- a/tests/test-bsdiff.c
+++ b/tests/test-bsdiff.c
@@ -19,37 +19,29 @@
#include "config.h"
-#include "libglnx.h"
#include "bsdiff/bsdiff.h"
#include "bsdiff/bspatch.h"
+#include "libglnx.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
static int
-bzpatch_read (const struct bspatch_stream* stream, void* buffer, int length)
+bzpatch_read (const struct bspatch_stream *stream, void *buffer, int length)
{
GInputStream *in = stream->opaque;
- if (length && ! g_input_stream_read (in,
- buffer,
- length,
- NULL,
- NULL))
+ if (length && !g_input_stream_read (in, buffer, length, NULL, NULL))
return -1;
return 0;
}
static int
-bzdiff_write (struct bsdiff_stream* stream, const void* buffer, int size)
+bzdiff_write (struct bsdiff_stream *stream, const void *buffer, int size)
{
GOutputStream *out = stream->opaque;
- if (! g_output_stream_write (out,
- buffer,
- size,
- NULL,
- NULL))
+ if (!g_output_stream_write (out, buffer, size, NULL, NULL))
return -1;
return 0;
@@ -59,7 +51,7 @@ static void
test_bsdiff (void)
{
#define OLD_SIZE 512
-#define NEW_SIZE (512+24)
+#define NEW_SIZE (512 + 24)
struct bsdiff_stream bsdiff_stream;
struct bspatch_stream bspatch_stream;
@@ -67,8 +59,8 @@ test_bsdiff (void)
g_autofree guint8 *old = g_new (guint8, OLD_SIZE);
g_autofree guint8 *new = g_new (guint8, NEW_SIZE);
g_autofree guint8 *new_generated = g_new0 (guint8, NEW_SIZE);
- g_autoptr(GOutputStream) out = g_memory_output_stream_new_resizable ();
- g_autoptr(GInputStream) in = NULL;
+ g_autoptr (GOutputStream) out = g_memory_output_stream_new_resizable ();
+ g_autoptr (GInputStream) in = NULL;
new[0] = 'A';
for (i = 0; i < OLD_SIZE; i++)
@@ -88,7 +80,8 @@ test_bsdiff (void)
g_assert (g_output_stream_close (out, NULL, NULL));
/* Now generate NEW_GENERATED from OLD and OUT. */
- { g_autoptr(GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out));
+ {
+ g_autoptr (GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out));
in = g_memory_input_stream_new_from_bytes (bytes);
}
bspatch_stream.read = bzpatch_read;
@@ -99,9 +92,10 @@ test_bsdiff (void)
g_assert_cmpint (memcmp (new, new_generated, NEW_SIZE), ==, 0);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/bsdiff", test_bsdiff);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-checksum.c b/tests/test-checksum.c
index 85d1c262..fabd029a 100644
--- a/tests/test-checksum.c
+++ b/tests/test-checksum.c
@@ -20,11 +20,11 @@
#include "config.h"
#include "libglnx.h"
+#include "ostree-core-private.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include "ostree-core-private.h"
static void
test_ostree_parse_delta_name (void)
@@ -32,7 +32,8 @@ test_ostree_parse_delta_name (void)
{
g_autofree char *from = NULL;
g_autofree char *to = NULL;
- g_assert (_ostree_parse_delta_name ("30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d", &from, &to, NULL));
+ g_assert (_ostree_parse_delta_name (
+ "30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d", &from, &to, NULL));
g_assert_cmpstr (to, ==, "30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d");
g_assert_null (from);
}
@@ -40,7 +41,10 @@ test_ostree_parse_delta_name (void)
{
g_autofree char *from = NULL;
g_autofree char *to = NULL;
- g_assert (_ostree_parse_delta_name ("30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d-5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03", &from, &to, NULL));
+ g_assert (_ostree_parse_delta_name (
+ "30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d-"
+ "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03",
+ &from, &to, NULL));
g_assert_cmpstr (from, ==, "30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d");
g_assert_cmpstr (to, ==, "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03");
}
@@ -64,7 +68,9 @@ test_ostree_parse_delta_name (void)
{
g_autofree char *from = NULL;
g_autofree char *to = NULL;
- g_assert (!_ostree_parse_delta_name ("GARBAGE-5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03", &from, &to, NULL));
+ g_assert (!_ostree_parse_delta_name (
+ "GARBAGE-5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03", &from, &to,
+ NULL));
g_assert_null (from);
g_assert_null (to);
}
@@ -72,15 +78,18 @@ test_ostree_parse_delta_name (void)
{
g_autofree char *from = NULL;
g_autofree char *to = NULL;
- g_assert (!_ostree_parse_delta_name ("30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d-GARBAGE", &from, &to, NULL));
+ g_assert (!_ostree_parse_delta_name (
+ "30d13b73cfe1e6988ffc345eac905f82a18def8ef1f0666fc392019e9eac388d-GARBAGE", &from, &to,
+ NULL));
g_assert_null (from);
g_assert_null (to);
}
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/ostree_parse_delta_name", test_ostree_parse_delta_name);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-commit-sign-sh-ext.c b/tests/test-commit-sign-sh-ext.c
index c11bd0f1..3469471d 100644
--- a/tests/test-commit-sign-sh-ext.c
+++ b/tests/test-commit-sign-sh-ext.c
@@ -52,7 +52,7 @@ corrupt (GBytes *input)
static gboolean
run (GError **error)
{
- g_autoptr(OstreeRepo) repo = ostree_repo_open_at (AT_FDCWD, "repo", NULL, error);
+ g_autoptr (OstreeRepo) repo = ostree_repo_open_at (AT_FDCWD, "repo", NULL, error);
if (!repo)
return FALSE;
@@ -60,45 +60,46 @@ run (GError **error)
if (!ostree_repo_resolve_rev (repo, "origin:main", FALSE, &rev, error))
return FALSE;
g_assert (rev);
- g_autoptr(GVariant) commit = NULL;
+ g_autoptr (GVariant) commit = NULL;
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, rev, &commit, error))
return FALSE;
g_assert (commit);
- g_autoptr(GVariant) detached_meta = NULL;
+ g_autoptr (GVariant) detached_meta = NULL;
if (!ostree_repo_read_commit_detached_metadata (repo, rev, &detached_meta, NULL, error))
return FALSE;
g_assert (detached_meta);
- g_autoptr(GBytes) commit_bytes = g_variant_get_data_as_bytes (commit);
- g_autoptr(GBytes) detached_meta_bytes = g_variant_get_data_as_bytes (detached_meta);
+ g_autoptr (GBytes) commit_bytes = g_variant_get_data_as_bytes (commit);
+ g_autoptr (GBytes) detached_meta_bytes = g_variant_get_data_as_bytes (detached_meta);
g_autofree char *verify_report = NULL;
- if (!ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes, 0,
- &verify_report, error))
+ if (!ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes,
+ 0, &verify_report, error))
return FALSE;
if (ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, detached_meta_bytes,
- OSTREE_REPO_VERIFY_FLAGS_NO_GPG | OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI,
+ OSTREE_REPO_VERIFY_FLAGS_NO_GPG
+ | OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI,
&verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "No commit verification types enabled");
// No signatures
- g_autoptr(GBytes) empty = g_bytes_new_static ("", 0);
+ g_autoptr (GBytes) empty = g_bytes_new_static ("", 0);
if (ostree_repo_signature_verify_commit_data (repo, "origin", commit_bytes, empty, 0,
- &verify_report, error))
+ &verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "no signatures found");
// No such remote
- if (ostree_repo_signature_verify_commit_data (repo, "nosuchremote", commit_bytes, detached_meta_bytes, 0,
- &verify_report, error))
+ if (ostree_repo_signature_verify_commit_data (repo, "nosuchremote", commit_bytes,
+ detached_meta_bytes, 0, &verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "Remote \"nosuchremote\" not found");
// Corrupted commit
- g_autoptr(GBytes) corrupted_commit = corrupt (commit_bytes);
- if (ostree_repo_signature_verify_commit_data (repo, "origin", corrupted_commit, detached_meta_bytes, 0,
- &verify_report, error))
+ g_autoptr (GBytes) corrupted_commit = corrupt (commit_bytes);
+ if (ostree_repo_signature_verify_commit_data (repo, "origin", corrupted_commit,
+ detached_meta_bytes, 0, &verify_report, error))
return glnx_throw (error, "Should not have validated");
assert_error_contains (error, "BAD signature");
@@ -108,7 +109,7 @@ run (GError **error)
int
main (int argc, char **argv)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
if (!run (&error))
{
g_printerr ("error: %s\n", error->message);
diff --git a/tests/test-gpg-verify-result.c b/tests/test-gpg-verify-result.c
index 8485b888..e7171a89 100644
--- a/tests/test-gpg-verify-result.c
+++ b/tests/test-gpg-verify-result.c
@@ -19,51 +19,55 @@
#include "config.h"
-#include <gpgme.h>
#include "libglnx.h"
+#include <gpgme.h>
#include "ostree-gpg-verify-result-private.h"
#define assert_no_gpg_error(err, filename) \
- G_STMT_START { \
- if (err != GPG_ERR_NO_ERROR) { \
- g_autoptr(GString) string = g_string_new ("assertion failed "); \
- g_string_append_printf (string, "%s: %s ", gpgme_strsource (err), gpgme_strerror (err)); \
- g_string_append (string, filename ? filename : ""); \
- g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, string->str); \
- } \
- } G_STMT_END
+ G_STMT_START \
+ { \
+ if (err != GPG_ERR_NO_ERROR) \
+ { \
+ g_autoptr (GString) string = g_string_new ("assertion failed "); \
+ g_string_append_printf (string, "%s: %s ", gpgme_strsource (err), gpgme_strerror (err)); \
+ g_string_append (string, filename ? filename : ""); \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, string->str); \
+ } \
+ } \
+ G_STMT_END
#define assert_str_contains(s1, s2) \
- G_STMT_START { \
+ G_STMT_START \
+ { \
const char *__s1 = (s1), *__s2 = (s2); \
- if (strstr (__s1, __s2) == NULL) { \
- g_autoptr(GString) string = g_string_new ("assertion failed (" #s1 " contains " #s2 "): "); \
- g_autofree char *__es1 = g_strescape (__s1, NULL); \
- g_autofree char *__es2 = g_strescape (__s2, NULL); \
- g_string_append_printf (string, "(\"%s\", \"%s\")", __es1, __es2); \
- g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, string->str); \
- } \
- } G_STMT_END
-
-typedef struct {
+ if (strstr (__s1, __s2) == NULL) \
+ { \
+ g_autoptr (GString) string \
+ = g_string_new ("assertion failed (" #s1 " contains " #s2 "): "); \
+ g_autofree char *__es1 = g_strescape (__s1, NULL); \
+ g_autofree char *__es2 = g_strescape (__s2, NULL); \
+ g_string_append_printf (string, "(\"%s\", \"%s\")", __es1, __es2); \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, string->str); \
+ } \
+ } \
+ G_STMT_END
+
+typedef struct
+{
OstreeGpgVerifyResult *result;
} TestFixture;
static OstreeGpgSignatureAttr some_attributes[] = {
- OSTREE_GPG_SIGNATURE_ATTR_VALID,
- OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
- OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED,
- OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED,
- OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING,
- OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
+ OSTREE_GPG_SIGNATURE_ATTR_VALID, OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
+ OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED, OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED,
+ OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING, OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
};
static void
-test_fixture_setup (TestFixture *fixture,
- gconstpointer user_data)
+test_fixture_setup (TestFixture *fixture, gconstpointer user_data)
{
- const char * const *sig_files = user_data;
+ const char *const *sig_files = user_data;
gpgme_error_t gpg_error;
gpgme_data_t data_buffer;
gpgme_data_t signature_buffer;
@@ -81,8 +85,7 @@ test_fixture_setup (TestFixture *fixture,
gboolean is_ok = g_setenv ("GNUPGHOME", homedir, TRUE);
g_assert (is_ok == TRUE);
- result = g_initable_new (OSTREE_TYPE_GPG_VERIFY_RESULT,
- NULL, &local_error, NULL);
+ result = g_initable_new (OSTREE_TYPE_GPG_VERIFY_RESULT, NULL, &local_error, NULL);
g_assert_no_error (local_error);
g_autofree char *data_filename = g_build_filename (homedir, "lgpl2", NULL);
@@ -102,15 +105,15 @@ test_fixture_setup (TestFixture *fixture,
gpg_error = gpgme_data_new (&signature_buffer);
assert_no_gpg_error (gpg_error, NULL);
- for (const char * const *name = sig_files; *name != NULL; name++)
+ for (const char *const *name = sig_files; *name != NULL; name++)
{
g_autofree char *path = g_build_filename (homedir, *name, NULL);
- g_autoptr(GFile) sig_file = g_file_new_for_path (path);
+ g_autoptr (GFile) sig_file = g_file_new_for_path (path);
g_autofree char *contents = NULL;
gsize len;
- g_assert_true (g_file_load_contents (sig_file, NULL, &contents,
- &len, NULL, &local_error));
+ g_assert_true (
+ g_file_load_contents (sig_file, NULL, &contents, &len, NULL, &local_error));
g_assert_no_error (local_error);
char *cur = contents;
@@ -127,8 +130,7 @@ test_fixture_setup (TestFixture *fixture,
gpgme_data_seek (signature_buffer, 0, SEEK_SET);
}
- gpg_error = gpgme_op_verify (result->context,
- signature_buffer, data_buffer, NULL);
+ gpg_error = gpgme_op_verify (result->context, signature_buffer, data_buffer, NULL);
assert_no_gpg_error (gpg_error, NULL);
result->details = gpgme_op_verify_result (result->context);
@@ -141,15 +143,13 @@ test_fixture_setup (TestFixture *fixture,
}
static void
-test_fixture_teardown (TestFixture *fixture,
- gconstpointer user_data)
+test_fixture_teardown (TestFixture *fixture, gconstpointer user_data)
{
g_clear_object (&fixture->result);
}
static void
-test_check_counts (TestFixture *fixture,
- gconstpointer user_data)
+test_check_counts (TestFixture *fixture, gconstpointer user_data)
{
guint count_all;
guint count_valid;
@@ -162,8 +162,7 @@ test_check_counts (TestFixture *fixture,
}
static void
-test_signature_lookup (TestFixture *fixture,
- gconstpointer user_data)
+test_signature_lookup (TestFixture *fixture, gconstpointer user_data)
{
/* Checking the signature with the revoked key for this case. */
guint expected_signature_index = 2;
@@ -176,33 +175,29 @@ test_signature_lookup (TestFixture *fixture,
/* Lookup full fingerprint. */
signature_index = 999999;
- signature_found = ostree_gpg_verify_result_lookup (fixture->result,
- fingerprint,
- &signature_index);
+ signature_found
+ = ostree_gpg_verify_result_lookup (fixture->result, fingerprint, &signature_index);
g_assert_true (signature_found);
g_assert_cmpint (signature_index, ==, expected_signature_index);
/* Lookup abbreviated key ID. */
signature_index = 999999;
- signature_found = ostree_gpg_verify_result_lookup (fixture->result,
- fingerprint + 32,
- &signature_index);
+ signature_found
+ = ostree_gpg_verify_result_lookup (fixture->result, fingerprint + 32, &signature_index);
g_assert_true (signature_found);
g_assert_cmpint (signature_index, ==, expected_signature_index);
/* Bogus fingerprint, index should remain unchanged. */
signature_index = expected_signature_index = 999999;
fingerprint = "CAFEBABECAFEBABECAFEBABECAFEBABECAFEBABE";
- signature_found = ostree_gpg_verify_result_lookup (fixture->result,
- fingerprint,
- &signature_index);
+ signature_found
+ = ostree_gpg_verify_result_lookup (fixture->result, fingerprint, &signature_index);
g_assert_false (signature_found);
g_assert_cmpint (signature_index, ==, expected_signature_index);
}
static void
-test_attribute_basics (TestFixture *fixture,
- gconstpointer user_data)
+test_attribute_basics (TestFixture *fixture, gconstpointer user_data)
{
guint n_signatures, ii;
@@ -210,7 +205,7 @@ test_attribute_basics (TestFixture *fixture,
for (ii = 0; ii < n_signatures; ii++)
{
- g_autoptr(GVariant) tuple = NULL;
+ g_autoptr (GVariant) tuple = NULL;
const char *attr_string;
const char *type_string;
gboolean key_missing;
@@ -222,31 +217,21 @@ test_attribute_basics (TestFixture *fixture,
/* Check attributes which should be common to all signatures. */
- g_variant_get_child (tuple,
- OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME,
- "&s", &attr_string);
+ g_variant_get_child (tuple, OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME, "&s", &attr_string);
g_assert_cmpstr (attr_string, ==, "RSA");
- g_variant_get_child (tuple,
- OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME,
- "&s", &attr_string);
+ g_variant_get_child (tuple, OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME, "&s", &attr_string);
g_assert_cmpstr (attr_string, ==, "SHA1");
- g_variant_get_child (tuple,
- OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING,
- "b", &key_missing);
+ g_variant_get_child (tuple, OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING, "b", &key_missing);
- g_variant_get_child (tuple,
- OSTREE_GPG_SIGNATURE_ATTR_USER_NAME,
- "&s", &attr_string);
+ g_variant_get_child (tuple, OSTREE_GPG_SIGNATURE_ATTR_USER_NAME, "&s", &attr_string);
if (key_missing)
g_assert_cmpstr (attr_string, ==, "[unknown name]");
else
g_assert_cmpstr (attr_string, ==, "J. Random User");
- g_variant_get_child (tuple,
- OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL,
- "&s", &attr_string);
+ g_variant_get_child (tuple, OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL, "&s", &attr_string);
if (key_missing)
g_assert_cmpstr (attr_string, ==, "[unknown email]");
else
@@ -255,11 +240,10 @@ test_attribute_basics (TestFixture *fixture,
}
static void
-test_valid_signature (TestFixture *fixture,
- gconstpointer user_data)
+test_valid_signature (TestFixture *fixture, gconstpointer user_data)
{
guint signature_index = 0;
- g_autoptr(GVariant) tuple = NULL;
+ g_autoptr (GVariant) tuple = NULL;
gboolean valid;
gboolean sig_expired;
gboolean key_expired;
@@ -267,17 +251,10 @@ test_valid_signature (TestFixture *fixture,
gboolean key_missing;
gint64 key_exp_timestamp;
- tuple = ostree_gpg_verify_result_get (fixture->result,
- signature_index,
- some_attributes,
+ tuple = ostree_gpg_verify_result_get (fixture->result, signature_index, some_attributes,
G_N_ELEMENTS (some_attributes));
- g_variant_get (tuple, "(bbbbbx)",
- &valid,
- &sig_expired,
- &key_expired,
- &key_revoked,
- &key_missing,
+ g_variant_get (tuple, "(bbbbbx)", &valid, &sig_expired, &key_expired, &key_revoked, &key_missing,
&key_exp_timestamp);
g_assert_true (valid);
@@ -289,11 +266,10 @@ test_valid_signature (TestFixture *fixture,
}
static void
-test_expired_key (TestFixture *fixture,
- gconstpointer user_data)
+test_expired_key (TestFixture *fixture, gconstpointer user_data)
{
guint signature_index = 1;
- g_autoptr(GVariant) tuple = NULL;
+ g_autoptr (GVariant) tuple = NULL;
gboolean valid;
gboolean sig_expired;
gboolean key_expired;
@@ -301,17 +277,10 @@ test_expired_key (TestFixture *fixture,
gboolean key_missing;
gint64 key_exp_timestamp;
- tuple = ostree_gpg_verify_result_get (fixture->result,
- signature_index,
- some_attributes,
+ tuple = ostree_gpg_verify_result_get (fixture->result, signature_index, some_attributes,
G_N_ELEMENTS (some_attributes));
- g_variant_get (tuple, "(bbbbbx)",
- &valid,
- &sig_expired,
- &key_expired,
- &key_revoked,
- &key_missing,
+ g_variant_get (tuple, "(bbbbbx)", &valid, &sig_expired, &key_expired, &key_revoked, &key_missing,
&key_exp_timestamp);
g_assert_false (valid);
@@ -323,11 +292,10 @@ test_expired_key (TestFixture *fixture,
}
static void
-test_revoked_key (TestFixture *fixture,
- gconstpointer user_data)
+test_revoked_key (TestFixture *fixture, gconstpointer user_data)
{
guint signature_index = 2;
- g_autoptr(GVariant) tuple = NULL;
+ g_autoptr (GVariant) tuple = NULL;
gboolean valid;
gboolean sig_expired;
gboolean key_expired;
@@ -335,17 +303,10 @@ test_revoked_key (TestFixture *fixture,
gboolean key_missing;
gint64 key_exp_timestamp;
- tuple = ostree_gpg_verify_result_get (fixture->result,
- signature_index,
- some_attributes,
+ tuple = ostree_gpg_verify_result_get (fixture->result, signature_index, some_attributes,
G_N_ELEMENTS (some_attributes));
- g_variant_get (tuple, "(bbbbbx)",
- &valid,
- &sig_expired,
- &key_expired,
- &key_revoked,
- &key_missing,
+ g_variant_get (tuple, "(bbbbbx)", &valid, &sig_expired, &key_expired, &key_revoked, &key_missing,
&key_exp_timestamp);
g_assert_false (valid);
@@ -357,11 +318,10 @@ test_revoked_key (TestFixture *fixture,
}
static void
-test_missing_key (TestFixture *fixture,
- gconstpointer user_data)
+test_missing_key (TestFixture *fixture, gconstpointer user_data)
{
guint signature_index = 3;
- g_autoptr(GVariant) tuple = NULL;
+ g_autoptr (GVariant) tuple = NULL;
gboolean valid;
gboolean sig_expired;
gboolean key_expired;
@@ -369,17 +329,10 @@ test_missing_key (TestFixture *fixture,
gboolean key_missing;
gint64 key_exp_timestamp;
- tuple = ostree_gpg_verify_result_get (fixture->result,
- signature_index,
- some_attributes,
+ tuple = ostree_gpg_verify_result_get (fixture->result, signature_index, some_attributes,
G_N_ELEMENTS (some_attributes));
- g_variant_get (tuple, "(bbbbbx)",
- &valid,
- &sig_expired,
- &key_expired,
- &key_revoked,
- &key_missing,
+ g_variant_get (tuple, "(bbbbbx)", &valid, &sig_expired, &key_expired, &key_revoked, &key_missing,
&key_exp_timestamp);
g_assert_false (valid);
@@ -391,11 +344,10 @@ test_missing_key (TestFixture *fixture,
}
static void
-test_expired_signature (TestFixture *fixture,
- gconstpointer user_data)
+test_expired_signature (TestFixture *fixture, gconstpointer user_data)
{
guint signature_index = 4;
- g_autoptr(GVariant) tuple = NULL;
+ g_autoptr (GVariant) tuple = NULL;
gboolean valid;
gboolean sig_expired;
gboolean key_expired;
@@ -403,17 +355,10 @@ test_expired_signature (TestFixture *fixture,
gboolean key_missing;
gint64 key_exp_timestamp;
- tuple = ostree_gpg_verify_result_get (fixture->result,
- signature_index,
- some_attributes,
+ tuple = ostree_gpg_verify_result_get (fixture->result, signature_index, some_attributes,
G_N_ELEMENTS (some_attributes));
- g_variant_get (tuple, "(bbbbbx)",
- &valid,
- &sig_expired,
- &key_expired,
- &key_revoked,
- &key_missing,
+ g_variant_get (tuple, "(bbbbbx)", &valid, &sig_expired, &key_expired, &key_revoked, &key_missing,
&key_exp_timestamp);
g_assert_false (valid);
@@ -425,71 +370,59 @@ test_expired_signature (TestFixture *fixture,
}
static void
-test_require_valid_signature (TestFixture *fixture,
- gconstpointer user_data)
+test_require_valid_signature (TestFixture *fixture, gconstpointer user_data)
{
GError *error = NULL;
- gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result,
- &error);
+ gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result, &error);
g_assert_true (res);
g_assert_no_error (error);
}
static void
-test_require_valid_signature_expired_key (TestFixture *fixture,
- gconstpointer user_data)
+test_require_valid_signature_expired_key (TestFixture *fixture, gconstpointer user_data)
{
GError *error = NULL;
- gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result,
- &error);
+ gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result, &error);
g_assert_false (res);
g_assert_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_EXPIRED_KEY);
assert_str_contains (error->message, "Key expired");
}
static void
-test_require_valid_signature_revoked_key (TestFixture *fixture,
- gconstpointer user_data)
+test_require_valid_signature_revoked_key (TestFixture *fixture, gconstpointer user_data)
{
GError *error = NULL;
- gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result,
- &error);
+ gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result, &error);
g_assert_false (res);
g_assert_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_REVOKED_KEY);
assert_str_contains (error->message, "Key revoked");
}
static void
-test_require_valid_signature_missing_key (TestFixture *fixture,
- gconstpointer user_data)
+test_require_valid_signature_missing_key (TestFixture *fixture, gconstpointer user_data)
{
GError *error = NULL;
- gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result,
- &error);
+ gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result, &error);
g_assert_false (res);
g_assert_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_MISSING_KEY);
assert_str_contains (error->message, "public key not found");
}
static void
-test_require_valid_signature_expired_signature (TestFixture *fixture,
- gconstpointer user_data)
+test_require_valid_signature_expired_signature (TestFixture *fixture, gconstpointer user_data)
{
GError *error = NULL;
- gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result,
- &error);
+ gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result, &error);
g_assert_false (res);
g_assert_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_EXPIRED_SIGNATURE);
assert_str_contains (error->message, "Signature expired");
}
static void
-test_require_valid_signature_expired_missing_key (TestFixture *fixture,
- gconstpointer user_data)
+test_require_valid_signature_expired_missing_key (TestFixture *fixture, gconstpointer user_data)
{
GError *error = NULL;
- gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result,
- &error);
+ gboolean res = ostree_gpg_verify_result_require_valid_signature (fixture->result, &error);
g_assert_false (res);
/*
@@ -506,110 +439,59 @@ main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
- (void) gpgme_check_version (NULL);
+ (void)gpgme_check_version (NULL);
- g_test_add ("/gpg-verify-result/check-counts",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_check_counts,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/check-counts", TestFixture, NULL, test_fixture_setup,
+ test_check_counts, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/signature-lookup",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_signature_lookup,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/signature-lookup", TestFixture, NULL, test_fixture_setup,
+ test_signature_lookup, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/attribute-basics",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_attribute_basics,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/attribute-basics", TestFixture, NULL, test_fixture_setup,
+ test_attribute_basics, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/valid-signature",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_valid_signature,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/valid-signature", TestFixture, NULL, test_fixture_setup,
+ test_valid_signature, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/expired-key",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_expired_key,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/expired-key", TestFixture, NULL, test_fixture_setup,
+ test_expired_key, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/revoked-key",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_revoked_key,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/revoked-key", TestFixture, NULL, test_fixture_setup,
+ test_revoked_key, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/missing-key",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_missing_key,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/missing-key", TestFixture, NULL, test_fixture_setup,
+ test_missing_key, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/expired-signature",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_expired_signature,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/expired-signature", TestFixture, NULL, test_fixture_setup,
+ test_expired_signature, test_fixture_teardown);
- g_test_add ("/gpg-verify-result/require-valid-signature",
- TestFixture,
- NULL,
- test_fixture_setup,
- test_require_valid_signature,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/require-valid-signature", TestFixture, NULL, test_fixture_setup,
+ test_require_valid_signature, test_fixture_teardown);
const char *expired_key_files[] = { "lgpl2.sig1", NULL };
- g_test_add ("/gpg-verify-result/require-valid-signature-expired-key",
- TestFixture,
- expired_key_files,
- test_fixture_setup,
- test_require_valid_signature_expired_key,
+ g_test_add ("/gpg-verify-result/require-valid-signature-expired-key", TestFixture,
+ expired_key_files, test_fixture_setup, test_require_valid_signature_expired_key,
test_fixture_teardown);
const char *revoked_key_files[] = { "lgpl2.sig2", NULL };
- g_test_add ("/gpg-verify-result/require-valid-signature-revoked-key",
- TestFixture,
- revoked_key_files,
- test_fixture_setup,
- test_require_valid_signature_revoked_key,
+ g_test_add ("/gpg-verify-result/require-valid-signature-revoked-key", TestFixture,
+ revoked_key_files, test_fixture_setup, test_require_valid_signature_revoked_key,
test_fixture_teardown);
const char *missing_key_files[] = { "lgpl2.sig3", NULL };
- g_test_add ("/gpg-verify-result/require-valid-signature-missing-key",
- TestFixture,
- missing_key_files,
- test_fixture_setup,
- test_require_valid_signature_missing_key,
+ g_test_add ("/gpg-verify-result/require-valid-signature-missing-key", TestFixture,
+ missing_key_files, test_fixture_setup, test_require_valid_signature_missing_key,
test_fixture_teardown);
const char *expired_signature_files[] = { "lgpl2.sig4", NULL };
- g_test_add ("/gpg-verify-result/require-valid-signature-expired-signature",
- TestFixture,
- expired_signature_files,
- test_fixture_setup,
- test_require_valid_signature_expired_signature,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/require-valid-signature-expired-signature", TestFixture,
+ expired_signature_files, test_fixture_setup,
+ test_require_valid_signature_expired_signature, test_fixture_teardown);
const char *expired_missing_key_files[] = { "lgpl2.sig1", "lgpl2.sig3", NULL };
- g_test_add ("/gpg-verify-result/require-valid-signature-expired-missing-key",
- TestFixture,
- expired_missing_key_files,
- test_fixture_setup,
- test_require_valid_signature_expired_missing_key,
- test_fixture_teardown);
+ g_test_add ("/gpg-verify-result/require-valid-signature-expired-missing-key", TestFixture,
+ expired_missing_key_files, test_fixture_setup,
+ test_require_valid_signature_expired_missing_key, test_fixture_teardown);
return g_test_run ();
}
diff --git a/tests/test-include-ostree-h.c b/tests/test-include-ostree-h.c
index e23dc185..45b2c055 100644
--- a/tests/test-include-ostree-h.c
+++ b/tests/test-include-ostree-h.c
@@ -32,12 +32,13 @@ test_include_ostree_h_compiled (void)
}
/* Just ensure that we can compile with ostree.h included */
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/include-ostree-h/compiled", test_include_ostree_h_compiled);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-kargs.c b/tests/test-kargs.c
index 92441fb6..f233620c 100644
--- a/tests/test-kargs.c
+++ b/tests/test-kargs.c
@@ -22,25 +22,22 @@
#include "otutil.h"
static gboolean
-check_string_existance (OstreeKernelArgs *karg,
- const char *string_to_find)
+check_string_existance (OstreeKernelArgs *karg, const char *string_to_find)
{
- g_autofree gchar* string_with_spaces = ostree_kernel_args_to_string (karg);
- g_auto(GStrv) string_list = g_strsplit (string_with_spaces, " ", -1);
- return g_strv_contains ((const char* const*) string_list, string_to_find);
+ g_autofree gchar *string_with_spaces = ostree_kernel_args_to_string (karg);
+ g_auto (GStrv) string_list = g_strsplit (string_with_spaces, " ", -1);
+ return g_strv_contains ((const char *const *)string_list, string_to_find);
}
static gboolean
-kernel_args_entry_value_equal (gconstpointer data,
- gconstpointer value)
+kernel_args_entry_value_equal (gconstpointer data, gconstpointer value)
{
const OstreeKernelArgsEntry *e = data;
return g_strcmp0 (_ostree_kernel_args_entry_get_value (e), value) == 0;
}
static gboolean
-kernel_args_entry_key_equal (gconstpointer data,
- gconstpointer key)
+kernel_args_entry_key_equal (gconstpointer data, gconstpointer key)
{
const OstreeKernelArgsEntry *e = data;
return g_strcmp0 (_ostree_kernel_args_entry_get_key (e), key) == 0;
@@ -49,9 +46,10 @@ kernel_args_entry_key_equal (gconstpointer data,
static void
test_kargs_delete (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
gboolean ret;
- __attribute__((cleanup(ostree_kernel_args_cleanup))) OstreeKernelArgs *karg = ostree_kernel_args_new ();
+ __attribute__ ((cleanup (ostree_kernel_args_cleanup))) OstreeKernelArgs *karg
+ = ostree_kernel_args_new ();
ostree_kernel_args_append (karg, "single_key=test");
ostree_kernel_args_append (karg, "test=firstval");
@@ -96,7 +94,8 @@ test_kargs_delete (void)
g_assert (ret);
/* verify the value array is properly updated */
GPtrArray *kargs_array = _ostree_kernel_arg_get_key_array (karg);
- g_assert (!ot_ptr_array_find_with_equal_func (kargs_array, "single_key", kernel_args_entry_value_equal, NULL));
+ g_assert (!ot_ptr_array_find_with_equal_func (kargs_array, "single_key",
+ kernel_args_entry_value_equal, NULL));
g_assert (!check_string_existance (karg, "single_key"));
/* Delete specific key/value pair */
@@ -146,9 +145,10 @@ test_kargs_delete (void)
static void
test_kargs_replace (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
gboolean ret;
- __attribute__((cleanup(ostree_kernel_args_cleanup))) OstreeKernelArgs *karg = ostree_kernel_args_new ();
+ __attribute__ ((cleanup (ostree_kernel_args_cleanup))) OstreeKernelArgs *karg
+ = ostree_kernel_args_new ();
ostree_kernel_args_append (karg, "single_key");
ostree_kernel_args_append (karg, "test=firstval");
@@ -198,7 +198,8 @@ test_kargs_replace (void)
static void
test_kargs_append (void)
{
- __attribute__((cleanup(ostree_kernel_args_cleanup))) OstreeKernelArgs *append_arg = ostree_kernel_args_new ();
+ __attribute__ ((cleanup (ostree_kernel_args_cleanup))) OstreeKernelArgs *append_arg
+ = ostree_kernel_args_new ();
/* Some valid cases (key=value) pair */
ostree_kernel_args_append (append_arg, "test=valid");
ostree_kernel_args_append (append_arg, "test=secondvalid");
@@ -211,43 +212,49 @@ test_kargs_append (void)
* we have yet to find the conversion kargs to string fully "functional"
*/
GHashTable *kargs_table = _ostree_kernel_arg_get_kargs_table (append_arg);
- GLNX_HASH_TABLE_FOREACH_KV (kargs_table, const char*, key, GPtrArray*, value_array)
+ GLNX_HASH_TABLE_FOREACH_KV (kargs_table, const char *, key, GPtrArray *, value_array)
{
if (g_str_equal (key, "test"))
{
- g_assert (ot_ptr_array_find_with_equal_func (value_array, "valid", kernel_args_entry_value_equal, NULL));
- g_assert (ot_ptr_array_find_with_equal_func (value_array, "secondvalid", kernel_args_entry_value_equal, NULL));
- g_assert (ot_ptr_array_find_with_equal_func (value_array, "", kernel_args_entry_value_equal, NULL));
- g_assert (ot_ptr_array_find_with_equal_func (value_array, NULL, kernel_args_entry_value_equal, NULL));
+ g_assert (ot_ptr_array_find_with_equal_func (value_array, "valid",
+ kernel_args_entry_value_equal, NULL));
+ g_assert (ot_ptr_array_find_with_equal_func (value_array, "secondvalid",
+ kernel_args_entry_value_equal, NULL));
+ g_assert (ot_ptr_array_find_with_equal_func (value_array, "",
+ kernel_args_entry_value_equal, NULL));
+ g_assert (ot_ptr_array_find_with_equal_func (value_array, NULL,
+ kernel_args_entry_value_equal, NULL));
}
else
{
g_assert_cmpstr (key, ==, "second_test");
- g_assert (ot_ptr_array_find_with_equal_func (value_array, NULL, kernel_args_entry_value_equal, NULL));
+ g_assert (ot_ptr_array_find_with_equal_func (value_array, NULL,
+ kernel_args_entry_value_equal, NULL));
}
}
/* verify the value array is properly updated */
GPtrArray *kargs_array = _ostree_kernel_arg_get_key_array (append_arg);
- g_assert (ot_ptr_array_find_with_equal_func (kargs_array, "test", kernel_args_entry_key_equal, NULL));
- g_assert (ot_ptr_array_find_with_equal_func (kargs_array, "second_test", kernel_args_entry_key_equal, NULL));
+ g_assert (
+ ot_ptr_array_find_with_equal_func (kargs_array, "test", kernel_args_entry_key_equal, NULL));
+ g_assert (ot_ptr_array_find_with_equal_func (kargs_array, "second_test",
+ kernel_args_entry_key_equal, NULL));
/* Up till this point, we verified that the above was all correct, we then
* check ostree_kernel_args_to_string has the right result
*/
- g_autofree gchar* kargs_str = ostree_kernel_args_to_string (append_arg);
- g_auto(GStrv) kargs_list = g_strsplit(kargs_str, " ", -1);
- g_assert (g_strv_contains ((const char* const *)kargs_list, "test=valid"));
- g_assert (g_strv_contains ((const char* const *)kargs_list, "test=secondvalid"));
- g_assert (g_strv_contains ((const char* const *)kargs_list, "test="));
- g_assert (g_strv_contains ((const char* const *)kargs_list, "test"));
- g_assert (g_strv_contains ((const char* const *)kargs_list, "second_test"));
+ g_autofree gchar *kargs_str = ostree_kernel_args_to_string (append_arg);
+ g_auto (GStrv) kargs_list = g_strsplit (kargs_str, " ", -1);
+ g_assert (g_strv_contains ((const char *const *)kargs_list, "test=valid"));
+ g_assert (g_strv_contains ((const char *const *)kargs_list, "test=secondvalid"));
+ g_assert (g_strv_contains ((const char *const *)kargs_list, "test="));
+ g_assert (g_strv_contains ((const char *const *)kargs_list, "test"));
+ g_assert (g_strv_contains ((const char *const *)kargs_list, "second_test"));
g_assert_cmpint (5, ==, g_strv_length (kargs_list));
}
int
-main (int argc,
- char *argv[])
+main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
diff --git a/tests/test-keyfile-utils.c b/tests/test-keyfile-utils.c
index 49ac10fd..198e71d2 100644
--- a/tests/test-keyfile-utils.c
+++ b/tests/test-keyfile-utils.c
@@ -19,57 +19,41 @@
#include "config.h"
#include "libglnx.h"
+#include "ot-keyfile-utils.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include "ot-keyfile-utils.h"
static GKeyFile *g_keyfile;
static void
test_get_boolean_with_default (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
gboolean out = FALSE;
- g_assert (ot_keyfile_get_boolean_with_default (g_keyfile,
- "section",
- "a_boolean_true",
- FALSE,
- &out,
- &error));
+ g_assert (ot_keyfile_get_boolean_with_default (g_keyfile, "section", "a_boolean_true", FALSE,
+ &out, &error));
g_assert_true (out);
- g_assert (ot_keyfile_get_boolean_with_default (g_keyfile,
- "section",
- "a_boolean_false",
- TRUE,
- &out,
- &error));
+ g_assert (ot_keyfile_get_boolean_with_default (g_keyfile, "section", "a_boolean_false", TRUE,
+ &out, &error));
g_assert_false (out);
- g_assert (ot_keyfile_get_boolean_with_default (g_keyfile,
- "section",
- "a_not_existing_boolean",
- TRUE,
- &out,
- &error));
+ g_assert (ot_keyfile_get_boolean_with_default (g_keyfile, "section", "a_not_existing_boolean",
+ TRUE, &out, &error));
g_assert_true (out);
g_clear_error (&error);
- g_assert (ot_keyfile_get_boolean_with_default (g_keyfile,
- "a_fake_section",
- "a_boolean_true",
- FALSE,
- &out,
- &error));
+ g_assert (ot_keyfile_get_boolean_with_default (g_keyfile, "a_fake_section", "a_boolean_true",
+ FALSE, &out, &error));
}
static void
test_get_value_with_default (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
g_autofree char *out = NULL;
GLogLevelFlags always_fatal_mask;
const char *section = "section";
@@ -77,55 +61,31 @@ test_get_value_with_default (void)
/* Avoid that g_return_val_if_fail causes the test to fail. */
always_fatal_mask = g_log_set_always_fatal (0);
- g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
- NULL,
- "value_foo",
- "none",
- &out,
- &error));
+ g_assert_false (
+ ot_keyfile_get_value_with_default (g_keyfile, NULL, "value_foo", "none", &out, &error));
g_clear_pointer (&out, g_free);
- g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
- section,
- NULL,
- "none",
- &out,
- &error));
+ g_assert_false (
+ ot_keyfile_get_value_with_default (g_keyfile, section, NULL, "none", &out, &error));
g_clear_pointer (&out, g_free);
- g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
- section,
- NULL,
- "something",
- &out,
- &error));
+ g_assert_false (
+ ot_keyfile_get_value_with_default (g_keyfile, section, NULL, "something", &out, &error));
g_clear_pointer (&out, g_free);
/* Restore the old mask. */
g_log_set_always_fatal (always_fatal_mask);
- g_assert (ot_keyfile_get_value_with_default (g_keyfile,
- section,
- "value_foo",
- "none",
- &out,
- &error));
+ g_assert (
+ ot_keyfile_get_value_with_default (g_keyfile, section, "value_foo", "none", &out, &error));
g_assert_cmpstr (out, ==, "foo");
g_clear_pointer (&out, g_free);
- g_assert (ot_keyfile_get_value_with_default (g_keyfile,
- section,
- "a_not_existing_value",
- "correct",
- &out,
- &error));
+ g_assert (ot_keyfile_get_value_with_default (g_keyfile, section, "a_not_existing_value",
+ "correct", &out, &error));
g_assert_cmpstr (out, ==, "correct");
g_clear_pointer (&out, g_free);
- g_assert (ot_keyfile_get_value_with_default (g_keyfile,
- "a_fake_section",
- "a_value_true",
- "no value",
- &out,
- &error));
+ g_assert (ot_keyfile_get_value_with_default (g_keyfile, "a_fake_section", "a_value_true",
+ "no value", &out, &error));
g_assert_cmpstr (out, ==, "no value");
g_clear_pointer (&out, g_free);
}
@@ -133,63 +93,39 @@ test_get_value_with_default (void)
static void
test_get_value_with_default_group_optional (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
g_autofree char *out = NULL;
GLogLevelFlags always_fatal_mask;
const char *section = "section";
-/* Avoid that g_return_val_if_fail causes the test to fail. */
+ /* Avoid that g_return_val_if_fail causes the test to fail. */
always_fatal_mask = g_log_set_always_fatal (0);
- g_assert_false (ot_keyfile_get_value_with_default_group_optional (g_keyfile,
- NULL,
- "value_foo",
- "none",
- &out,
- &error));
+ g_assert_false (ot_keyfile_get_value_with_default_group_optional (g_keyfile, NULL, "value_foo",
+ "none", &out, &error));
g_clear_pointer (&out, g_free);
- g_assert_false (ot_keyfile_get_value_with_default_group_optional (g_keyfile,
- section,
- NULL,
- "none",
- &out,
- &error));
+ g_assert_false (ot_keyfile_get_value_with_default_group_optional (g_keyfile, section, NULL,
+ "none", &out, &error));
g_clear_pointer (&out, g_free);
- g_assert_false (ot_keyfile_get_value_with_default_group_optional (g_keyfile,
- section,
- NULL,
- "something",
- &out,
- &error));
+ g_assert_false (ot_keyfile_get_value_with_default_group_optional (g_keyfile, section, NULL,
+ "something", &out, &error));
g_clear_pointer (&out, g_free);
/* Restore the old mask. */
g_log_set_always_fatal (always_fatal_mask);
- g_assert (ot_keyfile_get_value_with_default_group_optional (g_keyfile,
- section,
- "value_foo",
- "none",
- &out,
- &error));
+ g_assert (ot_keyfile_get_value_with_default_group_optional (g_keyfile, section, "value_foo",
+ "none", &out, &error));
g_assert_cmpstr (out, ==, "foo");
g_clear_pointer (&out, g_free);
- g_assert (ot_keyfile_get_value_with_default_group_optional (g_keyfile,
- section,
- "a_not_existing_value",
- "correct",
- &out,
- &error));
+ g_assert (ot_keyfile_get_value_with_default_group_optional (
+ g_keyfile, section, "a_not_existing_value", "correct", &out, &error));
g_assert_cmpstr (out, ==, "correct");
g_clear_pointer (&out, g_free);
- g_assert (ot_keyfile_get_value_with_default_group_optional (g_keyfile,
- "an_optional_section",
- "a_value_true",
- "no value",
- &out,
- &error));
+ g_assert (ot_keyfile_get_value_with_default_group_optional (
+ g_keyfile, "an_optional_section", "a_value_true", "no value", &out, &error));
g_clear_error (&error);
g_clear_pointer (&out, g_free);
}
@@ -204,7 +140,7 @@ test_copy_group (void)
/* Avoid that g_return_val_if_fail causes the test to fail. */
always_fatal_mask = g_log_set_always_fatal (0);
- g_autoptr(GKeyFile) tmp = g_key_file_new ();
+ g_autoptr (GKeyFile) tmp = g_key_file_new ();
g_assert_false (ot_keyfile_copy_group (NULL, tmp, section));
g_assert_false (ot_keyfile_copy_group (g_keyfile, NULL, section));
@@ -215,9 +151,9 @@ test_copy_group (void)
g_assert_true (ot_keyfile_copy_group (g_keyfile, tmp, section));
- g_auto(GStrv) keys = g_key_file_get_keys (g_keyfile, section, &length, NULL);
+ g_auto (GStrv) keys = g_key_file_get_keys (g_keyfile, section, &length, NULL);
g_strfreev (g_key_file_get_keys (tmp, section, &length2, NULL));
- g_assert_cmpint(length, ==, length2);
+ g_assert_cmpint (length, ==, length2);
for (gsize ii = 0; ii < length; ii++)
{
@@ -225,7 +161,6 @@ test_copy_group (void)
g_autofree char *value2 = g_key_file_get_value (g_keyfile, section, keys[ii], NULL);
g_assert_cmpstr (value, ==, value2);
}
-
}
static void
@@ -238,7 +173,8 @@ fill_keyfile (GKeyFile *file)
g_key_file_set_value (file, "section", "value_bar", "bar");
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
int ret;
g_test_init (&argc, &argv, NULL);
@@ -247,10 +183,11 @@ int main (int argc, char **argv)
g_test_add_func ("/keyfile-utils/get-boolean-with-default", test_get_boolean_with_default);
g_test_add_func ("/keyfile-utils/get-value-with-default", test_get_value_with_default);
- g_test_add_func ("/keyfile-utils/get-value-with-default-group-optional", test_get_value_with_default_group_optional);
+ g_test_add_func ("/keyfile-utils/get-value-with-default-group-optional",
+ test_get_value_with_default_group_optional);
g_test_add_func ("/keyfile-utils/copy-group", test_copy_group);
- ret = g_test_run();
+ ret = g_test_run ();
g_key_file_free (g_keyfile);
diff --git a/tests/test-libarchive-import.c b/tests/test-libarchive-import.c
index a89fcc24..86536fc2 100644
--- a/tests/test-libarchive-import.c
+++ b/tests/test-libarchive-import.c
@@ -19,17 +19,18 @@
#include "config.h"
#include "libglnx.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include <ostree.h>
#include "ostree-libarchive-private.h"
#include <archive.h>
#include <archive_entry.h>
+#include <ostree.h>
-typedef struct {
+typedef struct
+{
OstreeRepo *repo;
int fd;
int fd_empty;
@@ -41,7 +42,7 @@ static void
test_data_init (TestData *td)
{
GError *error = NULL;
- g_autoptr(OtAutoArchiveWrite) a = archive_write_new ();
+ g_autoptr (OtAutoArchiveWrite) a = archive_write_new ();
struct archive_entry *ae;
uid_t uid = getuid ();
gid_t gid = getgid ();
@@ -50,7 +51,7 @@ test_data_init (TestData *td)
g_assert_cmpint (0, ==, chdir (td->tmpd));
td->fd = openat (AT_FDCWD, "foo.tar.gz", O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0644);
- (void) unlink ("foo.tar.gz");
+ (void)unlink ("foo.tar.gz");
g_assert_no_error (error);
g_assert (td->fd >= 0);
@@ -122,7 +123,7 @@ test_data_init (TestData *td)
td->fd_empty = openat (AT_FDCWD, "empty.tar.gz", O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0644);
g_assert (td->fd_empty >= 0);
- (void) unlink ("empty.tar.gz");
+ (void)unlink ("empty.tar.gz");
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_free (a));
a = archive_write_new ();
@@ -133,7 +134,8 @@ test_data_init (TestData *td)
g_assert_cmpint (0, ==, archive_write_open_fd (a, td->fd_empty));
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_close (a));
- { g_autoptr(GFile) repopath = g_file_new_for_path ("repo");
+ {
+ g_autoptr (GFile) repopath = g_file_new_for_path ("repo");
td->repo = ostree_repo_new (repopath);
g_assert_cmpint (0, ==, mkdir ("repo", 0755));
@@ -172,10 +174,12 @@ test_archive_setup (int fd, struct archive *a)
static void
test_libarchive_noautocreate_empty (gconstpointer data)
{
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
- OstreeRepoImportArchiveOptions opts = { 0, };
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (td->skip_all != NULL)
@@ -194,10 +198,12 @@ test_libarchive_noautocreate_empty (gconstpointer data)
static void
test_libarchive_autocreate_empty (gconstpointer data)
{
- TestData *td = (void*)data;
- g_autoptr(GError) error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
- OstreeRepoImportArchiveOptions opts = { 0, };
+ TestData *td = (void *)data;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (td->skip_all != NULL)
@@ -218,10 +224,12 @@ test_libarchive_autocreate_empty (gconstpointer data)
static void
test_libarchive_error_device_file (gconstpointer data)
{
- TestData *td = (void*)data;
- g_autoptr(GError) error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
- OstreeRepoImportArchiveOptions opts = { 0, };
+ TestData *td = (void *)data;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (td->skip_all != NULL)
@@ -244,9 +252,8 @@ skip_if_no_xattr (TestData *td)
if (setxattr (td->tmpd, "user.test-xattr-support", "yes", 4, 0) != 0)
{
int saved_errno = errno;
- g_autofree gchar *message
- = g_strdup_printf ("unable to setxattr on \"%s\": %s",
- td->tmpd, g_strerror (saved_errno));
+ g_autofree gchar *message = g_strdup_printf ("unable to setxattr on \"%s\": %s", td->tmpd,
+ g_strerror (saved_errno));
g_test_skip (message);
return TRUE;
}
@@ -255,29 +262,23 @@ skip_if_no_xattr (TestData *td)
}
static gboolean
-import_write_and_ref (OstreeRepo *repo,
- OstreeRepoImportArchiveOptions *opts,
- struct archive *a,
- const char *ref,
- OstreeRepoCommitModifier *modifier,
- GError **error)
+import_write_and_ref (OstreeRepo *repo, OstreeRepoImportArchiveOptions *opts, struct archive *a,
+ const char *ref, OstreeRepoCommitModifier *modifier, GError **error)
{
- g_autoptr(OstreeMutableTree) mtree = ostree_mutable_tree_new ();
+ g_autoptr (OstreeMutableTree) mtree = ostree_mutable_tree_new ();
if (!ostree_repo_prepare_transaction (repo, NULL, NULL, error))
return FALSE;
- if (!ostree_repo_import_archive_to_mtree (repo, opts, a, mtree, modifier,
- NULL, error))
+ if (!ostree_repo_import_archive_to_mtree (repo, opts, a, mtree, modifier, NULL, error))
return FALSE;
- g_autoptr(GFile) root = NULL;
+ g_autoptr (GFile) root = NULL;
if (!ostree_repo_write_mtree (repo, mtree, &root, NULL, error))
return FALSE;
g_autofree char *commit_checksum = NULL;
- if (!ostree_repo_write_commit (repo, NULL, "", "", NULL,
- OSTREE_REPO_FILE (root),
+ if (!ostree_repo_write_commit (repo, NULL, "", "", NULL, OSTREE_REPO_FILE (root),
&commit_checksum, NULL, error))
return FALSE;
@@ -292,10 +293,12 @@ import_write_and_ref (OstreeRepo *repo,
static void
test_libarchive_ignore_device_file (gconstpointer data)
{
- TestData *td = (void*)data;
- g_autoptr(GError) error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
- OstreeRepoImportArchiveOptions opts = { 0, };
+ TestData *td = (void *)data;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
if (skip_if_no_xattr (td))
goto out;
@@ -328,7 +331,7 @@ test_libarchive_ignore_device_file (gconstpointer data)
g_assert (error != NULL);
g_clear_error (&error);
- out:
+out:
g_assert_no_error (error);
}
@@ -360,10 +363,12 @@ check_ostree_convention (GError *error)
static void
test_libarchive_ostree_convention (gconstpointer data)
{
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
- OstreeRepoImportArchiveOptions opts = { 0, };
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
if (skip_if_no_xattr (td))
goto out;
@@ -386,21 +391,17 @@ test_libarchive_ostree_convention (gconstpointer data)
if (!check_ostree_convention (error))
goto out;
- out:
+out:
g_assert_no_error (error);
}
-static GVariant*
-xattr_cb (OstreeRepo *repo,
- const char *path,
- GFileInfo *file_info,
- gpointer user_data)
+static GVariant *
+xattr_cb (OstreeRepo *repo, const char *path, GFileInfo *file_info, gpointer user_data)
{
- g_auto(GVariantBuilder) builder;
- g_variant_builder_init (&builder, (GVariantType*)"a(ayay)");
+ g_auto (GVariantBuilder) builder;
+ g_variant_builder_init (&builder, (GVariantType *)"a(ayay)");
if (strcmp (path, "/anotherfile") == 0)
- g_variant_builder_add (&builder, "(@ay@ay)",
- g_variant_new_bytestring ("user.data"),
+ g_variant_builder_add (&builder, "(@ay@ay)", g_variant_new_bytestring ("user.data"),
g_variant_new_bytestring ("mydata"));
return g_variant_ref_sink (g_variant_builder_end (&builder));
}
@@ -408,11 +409,11 @@ xattr_cb (OstreeRepo *repo,
static void
test_libarchive_xattr_callback (gconstpointer data)
{
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
- g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
+ g_autoptr (OstreeRepoCommitModifier) modifier = NULL;
char buf[7] = { 0 };
if (skip_if_no_xattr (td))
@@ -425,8 +426,7 @@ test_libarchive_xattr_callback (gconstpointer data)
}
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
- ostree_repo_commit_modifier_set_xattr_callback (modifier, xattr_cb,
- NULL, NULL);
+ ostree_repo_commit_modifier_set_xattr_callback (modifier, xattr_cb, NULL, NULL);
test_archive_setup (td->fd, a);
@@ -450,16 +450,16 @@ test_libarchive_xattr_callback (gconstpointer data)
g_assert_cmpstr (buf, ==, "mydata");
- out:
+out:
g_assert_no_error (error);
}
static void
test_libarchive_xattr_import (gconstpointer data)
{
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
char buf[15] = { 0 };
@@ -495,20 +495,20 @@ test_libarchive_xattr_import (gconstpointer data)
x = getxattr ("import-checkout/anotherfile", "user.b_key", buf, sizeof buf - 1);
g_assert_cmpint (x, ==, 14);
- g_assert (memcmp(buf, "contains\0nuls", 14) == 0);
+ g_assert (memcmp (buf, "contains\0nuls", 14) == 0);
- out:
+out:
g_assert_no_error (error);
}
static void
test_libarchive_xattr_import_skip_xattr (gconstpointer data)
{
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
- g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
+ g_autoptr (OstreeRepoCommitModifier) modifier = NULL;
if (skip_if_no_xattr (td))
goto out;
@@ -523,8 +523,8 @@ test_libarchive_xattr_import_skip_xattr (gconstpointer data)
opts.ignore_unsupported_content = TRUE;
- modifier = ostree_repo_commit_modifier_new (
- OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS, NULL, NULL, NULL);
+ modifier = ostree_repo_commit_modifier_new (OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS, NULL,
+ NULL, NULL);
if (!import_write_and_ref (td->repo, &opts, a, "baz", modifier, &error))
goto out;
@@ -535,27 +535,27 @@ test_libarchive_xattr_import_skip_xattr (gconstpointer data)
ssize_t n_attrs = listxattr ("import-checkout/anotherfile", NULL, 0);
g_assert_cmpint (n_attrs, ==, 0);
- out:
+out:
g_assert_no_error (error);
}
-static GVariant*
-path_cb (OstreeRepo *repo,
- const char *path,
- GFileInfo *file_info,
- gpointer user_data)
+static GVariant *
+path_cb (OstreeRepo *repo, const char *path, GFileInfo *file_info, gpointer user_data)
{
if (strcmp (path, "/etc/file") == 0)
- *(gboolean*)user_data = TRUE;
+ *(gboolean *)user_data = TRUE;
return NULL;
}
static void
entry_pathname_test_helper (gconstpointer data, gboolean on)
{
- TestData *td = (void*)data; GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
- OstreeRepoImportArchiveOptions opts = { 0, };
+ TestData *td = (void *)data;
+ GError *error = NULL;
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
OstreeRepoCommitModifier *modifier = NULL;
gboolean met_etc_file = FALSE;
@@ -569,8 +569,7 @@ entry_pathname_test_helper (gconstpointer data, gboolean on)
}
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
- ostree_repo_commit_modifier_set_xattr_callback (modifier, path_cb,
- NULL, &met_etc_file);
+ ostree_repo_commit_modifier_set_xattr_callback (modifier, path_cb, NULL, &met_etc_file);
test_archive_setup (td->fd, a);
@@ -601,7 +600,7 @@ entry_pathname_test_helper (gconstpointer data, gboolean on)
}
ostree_repo_commit_modifier_unref (modifier);
- out:
+out:
g_assert_no_error (error);
}
@@ -620,12 +619,12 @@ test_libarchive_use_entry_pathname (gconstpointer data)
static void
test_libarchive_selinux (gconstpointer data)
{
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
GError *error = NULL;
- g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
+ g_autoptr (OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
glnx_unref_object OstreeSePolicy *sepol = NULL;
- g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
+ g_autoptr (OstreeRepoCommitModifier) modifier = NULL;
char buf[64] = { 0 };
if (skip_if_no_xattr (td))
@@ -678,13 +677,16 @@ test_libarchive_selinux (gconstpointer data)
buf[(sizeof buf) - 1] = '\0';
g_assert_cmpstr (buf, ==, "system_u:object_r:etc_t:s0");
- out:
+out:
g_assert_no_error (error);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- TestData td = {NULL,};
+ TestData td = {
+ NULL,
+ };
int r;
test_data_init (&td);
@@ -697,17 +699,19 @@ int main (int argc, char **argv)
g_test_add_data_func ("/libarchive/ignore-device-file", &td, test_libarchive_ignore_device_file);
g_test_add_data_func ("/libarchive/ostree-convention", &td, test_libarchive_ostree_convention);
g_test_add_data_func ("/libarchive/xattr-import", &td, test_libarchive_xattr_import);
- g_test_add_data_func ("/libarchive/xattr-import-skip-xattr", &td, test_libarchive_xattr_import_skip_xattr);
+ g_test_add_data_func ("/libarchive/xattr-import-skip-xattr", &td,
+ test_libarchive_xattr_import_skip_xattr);
g_test_add_data_func ("/libarchive/xattr-callback", &td, test_libarchive_xattr_callback);
- g_test_add_data_func ("/libarchive/no-use-entry-pathname", &td, test_libarchive_no_use_entry_pathname);
+ g_test_add_data_func ("/libarchive/no-use-entry-pathname", &td,
+ test_libarchive_no_use_entry_pathname);
g_test_add_data_func ("/libarchive/use-entry-pathname", &td, test_libarchive_use_entry_pathname);
g_test_add_data_func ("/libarchive/selinux", &td, test_libarchive_selinux);
- r = g_test_run();
+ r = g_test_run ();
g_clear_object (&td.repo);
if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL)
- (void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
+ (void)glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
g_free (td.tmpd);
return r;
}
diff --git a/tests/test-lzma.c b/tests/test-lzma.c
index c26bc8d2..5c1ce9dc 100644
--- a/tests/test-lzma.c
+++ b/tests/test-lzma.c
@@ -19,32 +19,33 @@
#include "config.h"
#include "libglnx.h"
-#include <glib.h>
-#include <stdlib.h>
-#include <gio/gio.h>
-#include <string.h>
#include "ostree-lzma-compressor.h"
#include "ostree-lzma-decompressor.h"
-#include <gio/gunixoutputstream.h>
+#include <gio/gio.h>
#include <gio/gmemoryoutputstream.h>
+#include <gio/gunixoutputstream.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
static void
helper_test_compress_decompress (const guint8 *data, gssize data_size)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(GOutputStream) out_compress = g_memory_output_stream_new_resizable ();
- g_autoptr(GOutputStream) out_decompress = NULL;
- g_autoptr(GInputStream) in_compress = g_memory_input_stream_new_from_data (data, data_size, NULL);
- g_autoptr(GInputStream) in_decompress = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GOutputStream) out_compress = g_memory_output_stream_new_resizable ();
+ g_autoptr (GOutputStream) out_decompress = NULL;
+ g_autoptr (GInputStream) in_compress
+ = g_memory_input_stream_new_from_data (data, data_size, NULL);
+ g_autoptr (GInputStream) in_decompress = NULL;
{
gssize n_bytes_written;
- g_autoptr(GInputStream) convin = NULL;
- g_autoptr(GConverter) compressor = (GConverter*)_ostree_lzma_compressor_new (NULL);
- convin = g_converter_input_stream_new ((GInputStream*) in_compress, compressor);
- n_bytes_written = g_output_stream_splice (out_compress, convin,
- G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET | G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
- NULL, &error);
+ g_autoptr (GInputStream) convin = NULL;
+ g_autoptr (GConverter) compressor = (GConverter *)_ostree_lzma_compressor_new (NULL);
+ convin = g_converter_input_stream_new ((GInputStream *)in_compress, compressor);
+ n_bytes_written = g_output_stream_splice (
+ out_compress, convin,
+ G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET | G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE, NULL, &error);
g_assert_cmpint (n_bytes_written, >, 0);
g_assert_no_error (error);
}
@@ -53,25 +54,26 @@ helper_test_compress_decompress (const guint8 *data, gssize data_size)
{
gssize n_bytes_written;
- g_autoptr(GInputStream) convin = NULL;
- g_autoptr(GConverter) decompressor = (GConverter*)_ostree_lzma_decompressor_new ();
- g_autoptr(GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out_compress));
+ g_autoptr (GInputStream) convin = NULL;
+ g_autoptr (GConverter) decompressor = (GConverter *)_ostree_lzma_decompressor_new ();
+ g_autoptr (GBytes) bytes
+ = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out_compress));
in_decompress = g_memory_input_stream_new_from_bytes (bytes);
- convin = g_converter_input_stream_new ((GInputStream*) in_decompress, decompressor);
- n_bytes_written = g_output_stream_splice (out_decompress, convin,
- G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET | G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
- NULL, &error);
+ convin = g_converter_input_stream_new ((GInputStream *)in_decompress, decompressor);
+ n_bytes_written = g_output_stream_splice (
+ out_decompress, convin,
+ G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET | G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE, NULL, &error);
g_assert_cmpint (n_bytes_written, >, 0);
g_assert_no_error (error);
}
- g_assert_cmpint (g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (out_decompress)), ==, data_size);
+ g_assert_cmpint (g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (out_decompress)),
+ ==, data_size);
{
gpointer new_data = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (out_decompress));
g_assert_cmpint (memcmp (new_data, data, data_size), ==, 0);
}
-
}
static void
@@ -79,11 +81,11 @@ test_lzma_random (void)
{
gssize i;
guint8 buffer[4096];
- g_autoptr(GRand) r = g_rand_new ();
- for (i = 0; i < sizeof(buffer); i++)
+ g_autoptr (GRand) r = g_rand_new ();
+ for (i = 0; i < sizeof (buffer); i++)
buffer[i] = g_rand_int (r);
- for (i = 2; i < (sizeof(buffer) - 1); i *= 2)
+ for (i = 2; i < (sizeof (buffer) - 1); i *= 2)
{
helper_test_compress_decompress (buffer, i - 1);
helper_test_compress_decompress (buffer, i);
@@ -97,16 +99,17 @@ test_lzma_big_buffer (void)
const guint32 buffer_size = 1 << 21;
g_autofree guint8 *buffer = g_new (guint8, buffer_size);
- memset (buffer, (int) 'a', buffer_size);
+ memset (buffer, (int)'a', buffer_size);
helper_test_compress_decompress (buffer, buffer_size);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/lzma/random-buffer", test_lzma_random);
g_test_add_func ("/lzma/big-buffer", test_lzma_big_buffer);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-mock-gio.c b/tests/test-mock-gio.c
index 719dc6cd..94682f2c 100644
--- a/tests/test-mock-gio.c
+++ b/tests/test-mock-gio.c
@@ -24,8 +24,8 @@
#include "config.h"
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <libglnx.h>
#include "test-mock-gio.h"
@@ -60,7 +60,7 @@ struct _OstreeMockVolumeMonitor
GVolumeMonitor parent_instance;
GList *mounts; /* (element-type OstreeMockMount) */
- GList *volumes; /* (element-type OstreeMockVolume) */
+ GList *volumes; /* (element-type OstreeMockVolume) */
};
G_DEFINE_TYPE (OstreeMockVolumeMonitor, ostree_mock_volume_monitor, G_TYPE_VOLUME_MONITOR)
@@ -69,14 +69,14 @@ static GList *
ostree_mock_volume_monitor_get_mounts (GVolumeMonitor *monitor)
{
OstreeMockVolumeMonitor *self = OSTREE_MOCK_VOLUME_MONITOR (monitor);
- return g_list_copy_deep (self->mounts, (GCopyFunc) g_object_ref, NULL);
+ return g_list_copy_deep (self->mounts, (GCopyFunc)g_object_ref, NULL);
}
static GList *
ostree_mock_volume_monitor_get_volumes (GVolumeMonitor *monitor)
{
OstreeMockVolumeMonitor *self = OSTREE_MOCK_VOLUME_MONITOR (monitor);
- return g_list_copy_deep (self->volumes, (GCopyFunc) g_object_ref, NULL);
+ return g_list_copy_deep (self->volumes, (GCopyFunc)g_object_ref, NULL);
}
static void
@@ -128,14 +128,13 @@ ostree_mock_volume_monitor_class_init (OstreeMockVolumeMonitorClass *klass)
* Since: 2017.8
*/
GVolumeMonitor *
-ostree_mock_volume_monitor_new (GList *mounts,
- GList *volumes)
+ostree_mock_volume_monitor_new (GList *mounts, GList *volumes)
{
- g_autoptr(OstreeMockVolumeMonitor) monitor = NULL;
+ g_autoptr (OstreeMockVolumeMonitor) monitor = NULL;
monitor = g_object_new (OSTREE_TYPE_MOCK_VOLUME_MONITOR, NULL);
- monitor->mounts = g_list_copy_deep (mounts, (GCopyFunc) g_object_ref, NULL);
- monitor->volumes = g_list_copy_deep (volumes, (GCopyFunc) g_object_ref, NULL);
+ monitor->mounts = g_list_copy_deep (mounts, (GCopyFunc)g_object_ref, NULL);
+ monitor->volumes = g_list_copy_deep (volumes, (GCopyFunc)g_object_ref, NULL);
return (GVolumeMonitor *)g_steal_pointer (&monitor);
}
@@ -147,8 +146,8 @@ struct _OstreeMockVolume
GObject parent_instance;
gchar *name;
- GDrive *drive; /* (owned) (nullable) */
- GMount *mount; /* (owned) (nullable) */
+ GDrive *drive; /* (owned) (nullable) */
+ GMount *mount; /* (owned) (nullable) */
};
static void ostree_mock_volume_iface_init (GVolumeIface *iface);
@@ -231,11 +230,9 @@ ostree_mock_volume_iface_init (GVolumeIface *iface)
* Since: 2017.8
*/
OstreeMockVolume *
-ostree_mock_volume_new (const gchar *name,
- GDrive *drive,
- GMount *mount)
+ostree_mock_volume_new (const gchar *name, GDrive *drive, GMount *mount)
{
- g_autoptr(OstreeMockVolume) volume = NULL;
+ g_autoptr (OstreeMockVolume) volume = NULL;
volume = g_object_new (OSTREE_TYPE_MOCK_VOLUME, NULL);
volume->name = g_strdup (name);
@@ -302,7 +299,7 @@ ostree_mock_drive_iface_init (GDriveIface *iface)
OstreeMockDrive *
ostree_mock_drive_new (gboolean is_removable)
{
- g_autoptr(OstreeMockDrive) drive = NULL;
+ g_autoptr (OstreeMockDrive) drive = NULL;
drive = g_object_new (OSTREE_TYPE_MOCK_DRIVE, NULL);
drive->is_removable = is_removable;
@@ -316,8 +313,8 @@ struct _OstreeMockMount
{
GObject parent_instance;
- gchar *name; /* (owned) */
- GFile *root; /* (owned) */
+ gchar *name; /* (owned) */
+ GFile *root; /* (owned) */
};
static void ostree_mock_mount_iface_init (GMountIface *iface);
@@ -387,10 +384,9 @@ ostree_mock_mount_iface_init (GMountIface *iface)
* Since: 2017.8
*/
OstreeMockMount *
-ostree_mock_mount_new (const gchar *name,
- GFile *root)
+ostree_mock_mount_new (const gchar *name, GFile *root)
{
- g_autoptr(OstreeMockMount) mount = NULL;
+ g_autoptr (OstreeMockMount) mount = NULL;
mount = g_object_new (OSTREE_TYPE_MOCK_MOUNT, NULL);
mount->name = g_strdup (name);
diff --git a/tests/test-mock-gio.h b/tests/test-mock-gio.h
index 2cc38f15..fae260ab 100644
--- a/tests/test-mock-gio.h
+++ b/tests/test-mock-gio.h
@@ -23,8 +23,8 @@
#pragma once
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <libglnx.h>
#include "ostree-types.h"
@@ -35,24 +35,36 @@ G_BEGIN_DECLS
/* Manually expanded version of the following, omitting autoptr support (for GLib < 2.44):
G_GNUC_INTERNAL
-G_DECLARE_FINAL_TYPE (OstreeMockVolumeMonitor, ostree_mock_volume_monitor, OSTREE, MOCK_VOLUME_MONITOR, GVolumeMonitor) */
+G_DECLARE_FINAL_TYPE (OstreeMockVolumeMonitor, ostree_mock_volume_monitor, OSTREE,
+MOCK_VOLUME_MONITOR, GVolumeMonitor) */
G_GNUC_INTERNAL
GType ostree_mock_volume_monitor_get_type (void);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _OstreeMockVolumeMonitor OstreeMockVolumeMonitor;
-typedef struct { GVolumeMonitorClass parent_class; } OstreeMockVolumeMonitorClass;
-
-static inline OstreeMockVolumeMonitor *OSTREE_MOCK_VOLUME_MONITOR (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_volume_monitor_get_type (), OstreeMockVolumeMonitor); }
-static inline gboolean OSTREE_IS_MOCK_VOLUME_MONITOR (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_volume_monitor_get_type ()); }
+typedef struct
+{
+ GVolumeMonitorClass parent_class;
+} OstreeMockVolumeMonitorClass;
+
+static inline OstreeMockVolumeMonitor *
+OSTREE_MOCK_VOLUME_MONITOR (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_volume_monitor_get_type (),
+ OstreeMockVolumeMonitor);
+}
+static inline gboolean
+OSTREE_IS_MOCK_VOLUME_MONITOR (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_volume_monitor_get_type ());
+}
G_GNUC_END_IGNORE_DEPRECATIONS
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeMockVolumeMonitor, g_object_unref)
G_GNUC_INTERNAL
-GVolumeMonitor *ostree_mock_volume_monitor_new (GList *mounts,
- GList *volumes);
+GVolumeMonitor *ostree_mock_volume_monitor_new (GList *mounts, GList *volumes);
#define OSTREE_TYPE_MOCK_VOLUME (ostree_mock_volume_get_type ())
@@ -65,18 +77,27 @@ GType ostree_mock_volume_get_type (void);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _OstreeMockVolume OstreeMockVolume;
-typedef struct { GObjectClass parent_class; } OstreeMockVolumeClass;
-
-static inline OstreeMockVolume *OSTREE_MOCK_VOLUME (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_volume_get_type (), OstreeMockVolume); }
-static inline gboolean OSTREE_IS_MOCK_VOLUME (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_volume_get_type ()); }
+typedef struct
+{
+ GObjectClass parent_class;
+} OstreeMockVolumeClass;
+
+static inline OstreeMockVolume *
+OSTREE_MOCK_VOLUME (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_volume_get_type (), OstreeMockVolume);
+}
+static inline gboolean
+OSTREE_IS_MOCK_VOLUME (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_volume_get_type ());
+}
G_GNUC_END_IGNORE_DEPRECATIONS
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeMockVolume, g_object_unref)
G_GNUC_INTERNAL
-OstreeMockVolume *ostree_mock_volume_new (const gchar *name,
- GDrive *drive,
- GMount *mount);
+OstreeMockVolume *ostree_mock_volume_new (const gchar *name, GDrive *drive, GMount *mount);
#define OSTREE_TYPE_MOCK_DRIVE (ostree_mock_drive_get_type ())
@@ -89,10 +110,21 @@ GType ostree_mock_drive_get_type (void);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _OstreeMockDrive OstreeMockDrive;
-typedef struct { GObjectClass parent_class; } OstreeMockDriveClass;
-
-static inline OstreeMockDrive *OSTREE_MOCK_DRIVE (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_drive_get_type (), OstreeMockDrive); }
-static inline gboolean OSTREE_IS_MOCK_DRIVE (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_drive_get_type ()); }
+typedef struct
+{
+ GObjectClass parent_class;
+} OstreeMockDriveClass;
+
+static inline OstreeMockDrive *
+OSTREE_MOCK_DRIVE (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_drive_get_type (), OstreeMockDrive);
+}
+static inline gboolean
+OSTREE_IS_MOCK_DRIVE (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_drive_get_type ());
+}
G_GNUC_END_IGNORE_DEPRECATIONS
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeMockDrive, g_object_unref)
@@ -111,16 +143,26 @@ GType ostree_mock_mount_get_type (void);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct _OstreeMockMount OstreeMockMount;
-typedef struct { GObjectClass parent_class; } OstreeMockMountClass;
-
-static inline OstreeMockMount *OSTREE_MOCK_MOUNT (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_mount_get_type (), OstreeMockMount); }
-static inline gboolean OSTREE_IS_MOCK_MOUNT (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_mount_get_type ()); }
+typedef struct
+{
+ GObjectClass parent_class;
+} OstreeMockMountClass;
+
+static inline OstreeMockMount *
+OSTREE_MOCK_MOUNT (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_mock_mount_get_type (), OstreeMockMount);
+}
+static inline gboolean
+OSTREE_IS_MOCK_MOUNT (gpointer ptr)
+{
+ return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_mock_mount_get_type ());
+}
G_GNUC_END_IGNORE_DEPRECATIONS
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeMockMount, g_object_unref)
G_GNUC_INTERNAL
-OstreeMockMount *ostree_mock_mount_new (const gchar *name,
- GFile *root);
+OstreeMockMount *ostree_mock_mount_new (const gchar *name, GFile *root);
G_END_DECLS
diff --git a/tests/test-mutable-tree.c b/tests/test-mutable-tree.c
index e5a6b040..4ef35930 100644
--- a/tests/test-mutable-tree.c
+++ b/tests/test-mutable-tree.c
@@ -20,16 +20,16 @@
#include "config.h"
#include "libglnx.h"
#include "ostree-mutable-tree.h"
+#include "ot-unix-utils.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include "ot-unix-utils.h"
static void
test_metadata_checksum (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
const char *checksum = "12345678901234567890123456789012";
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
@@ -45,20 +45,16 @@ test_metadata_checksum (void)
g_assert (ostree_mutable_tree_ensure_dir (tree, "subdir", &subdir, &error));
g_assert_nonnull (subdir);
- ostree_mutable_tree_set_contents_checksum (
- subdir, "11111111111111111111111111111111");
- ostree_mutable_tree_set_metadata_checksum (
- subdir, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- ostree_mutable_tree_set_contents_checksum (
- tree, "abcdefabcdefabcdefabcdefabcdefab");
+ ostree_mutable_tree_set_contents_checksum (subdir, "11111111111111111111111111111111");
+ ostree_mutable_tree_set_metadata_checksum (subdir, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+ ostree_mutable_tree_set_contents_checksum (tree, "abcdefabcdefabcdefabcdefabcdefab");
g_assert_cmpstr (ostree_mutable_tree_get_contents_checksum (tree), ==,
- "abcdefabcdefabcdefabcdefabcdefab");
- ostree_mutable_tree_set_metadata_checksum (
- subdir, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+ "abcdefabcdefabcdefabcdefabcdefab");
+ ostree_mutable_tree_set_metadata_checksum (subdir, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
g_assert_null (ostree_mutable_tree_get_contents_checksum (tree));
g_assert_cmpstr (ostree_mutable_tree_get_contents_checksum (subdir), ==,
- "11111111111111111111111111111111");
+ "11111111111111111111111111111111");
}
static void
@@ -66,16 +62,14 @@ test_mutable_tree_walk (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
- g_autoptr(GPtrArray) split_path = NULL;
+ g_autoptr (GPtrArray) split_path = NULL;
GError *error = NULL;
const char *pathname = "a/b/c/d/e/f/g/i";
const char *checksum = "01234567890123456789012345678901";
g_assert (ot_util_path_split_validate (pathname, &split_path, &error));
- g_assert (ostree_mutable_tree_ensure_parent_dirs (tree, split_path,
- checksum, &parent,
- &error));
+ g_assert (ostree_mutable_tree_ensure_parent_dirs (tree, split_path, checksum, &parent, &error));
{
glnx_unref_object OstreeMutableTree *subdir = NULL;
g_assert (ostree_mutable_tree_walk (tree, split_path, 0, &subdir, &error));
@@ -106,8 +100,8 @@ test_ensure_parent_dirs (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
- g_autoptr(GPtrArray) split_path = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GPtrArray) split_path = NULL;
+ g_autoptr (GError) error = NULL;
const char *pathname = "/foo/bar/baz";
const char *checksum = "01234567890123456789012345678901";
g_autofree char *source_checksum = NULL;
@@ -117,15 +111,12 @@ test_ensure_parent_dirs (void)
g_assert (ot_util_path_split_validate (pathname, &split_path, &error));
- g_assert (ostree_mutable_tree_ensure_parent_dirs (tree, split_path,
- checksum, &parent,
- &error));
+ g_assert (ostree_mutable_tree_ensure_parent_dirs (tree, split_path, checksum, &parent, &error));
- g_assert (ostree_mutable_tree_lookup (tree, "foo", &source_checksum,
- &source_subdir, &error));
+ g_assert (ostree_mutable_tree_lookup (tree, "foo", &source_checksum, &source_subdir, &error));
- g_assert_false (ostree_mutable_tree_lookup (tree, "bar", &source_checksum2,
- &source_subdir2, &error));
+ g_assert_false (
+ ostree_mutable_tree_lookup (tree, "bar", &source_checksum2, &source_subdir2, &error));
g_clear_error (&error);
}
@@ -134,7 +125,7 @@ test_ensure_dir (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
const char *dirname = "foo";
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
@@ -153,7 +144,7 @@ static void
test_replace_file (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
const char *checksum2 = "ABCDEF01234567890123456789012345";
@@ -195,7 +186,8 @@ test_contents_checksum (void)
g_assert_null (ostree_mutable_tree_get_contents_checksum (tree));
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mutable-tree/metadata-checksum", test_metadata_checksum);
@@ -204,5 +196,5 @@ int main (int argc, char **argv)
g_test_add_func ("/mutable-tree/walk", test_mutable_tree_walk);
g_test_add_func ("/mutable-tree/ensure-dir", test_ensure_dir);
g_test_add_func ("/mutable-tree/replace-file", test_replace_file);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-ot-opt-utils.c b/tests/test-ot-opt-utils.c
index 45de154d..3a700f4d 100644
--- a/tests/test-ot-opt-utils.c
+++ b/tests/test-ot-opt-utils.c
@@ -18,13 +18,13 @@
*/
#include "config.h"
+#include "libglnx.h"
#include "ostree-mutable-tree.h"
+#include "ot-opt-utils.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include "ot-opt-utils.h"
-#include "libglnx.h"
static GString *printerr_str = NULL;
@@ -39,8 +39,8 @@ util_usage_error_printerr (const gchar *string)
static void
test_ot_util_usage_error (void)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(GOptionContext) context = g_option_context_new ("[TEST]");
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("[TEST]");
GPrintFunc old_printerr = g_set_printerr_handler (util_usage_error_printerr);
ot_util_usage_error (context, "find_me", &error);
@@ -54,9 +54,10 @@ test_ot_util_usage_error (void)
printerr_str = NULL;
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/ot-opt-utils/ot-util-usage-error", test_ot_util_usage_error);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-ot-tool-util.c b/tests/test-ot-tool-util.c
index 6eb3520e..f189b3c6 100644
--- a/tests/test-ot-tool-util.c
+++ b/tests/test-ot-tool-util.c
@@ -20,11 +20,11 @@
#include "config.h"
#include "libglnx.h"
#include "ostree-mutable-tree.h"
+#include "ot-tool-util.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include "ot-tool-util.h"
/*
@@ -42,7 +42,7 @@ ot_parse_keyvalue (const char *keyvalue,
static void
test_ot_parse_boolean (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
gboolean out = FALSE;
g_assert_true (ot_parse_boolean ("yes", &out, &error));
g_assert_true (out);
@@ -79,20 +79,17 @@ test_ot_parse_boolean (void)
static void
test_ot_parse_keyvalue (void)
{
- g_autoptr(GError) error = NULL;
- char *keyvalue[] = {"foo=bar", "a=", "b=1231231"};
- char *key[] = {"foo", "a", "b"};
- char *value[] = {"bar", "", "1231231"};
+ g_autoptr (GError) error = NULL;
+ char *keyvalue[] = { "foo=bar", "a=", "b=1231231" };
+ char *key[] = { "foo", "a", "b" };
+ char *value[] = { "bar", "", "1231231" };
guint i;
for (i = 0; i < G_N_ELEMENTS (keyvalue); i++)
{
g_autofree char *out_key = NULL;
g_autofree char *out_value = NULL;
- g_assert_true (ot_parse_keyvalue (keyvalue[i],
- &out_key,
- &out_value,
- &error));
+ g_assert_true (ot_parse_keyvalue (keyvalue[i], &out_key, &out_value, &error));
g_assert_cmpstr (out_key, ==, key[i]);
g_assert_cmpstr (out_value, ==, value[i]);
}
@@ -100,19 +97,17 @@ test_ot_parse_keyvalue (void)
{
g_autofree char *out_key = NULL;
g_autofree char *out_value = NULL;
- g_assert_false (ot_parse_keyvalue ("blabla",
- &out_key,
- &out_value,
- &error));
+ g_assert_false (ot_parse_keyvalue ("blabla", &out_key, &out_value, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_clear_error (&error);
}
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/ot-tool-util/parse-boolean", test_ot_parse_boolean);
g_test_add_func ("/ot-tool-util/parse-keyvalue", test_ot_parse_keyvalue);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-ot-unix-utils.c b/tests/test-ot-unix-utils.c
index 3f16b55d..853e877f 100644
--- a/tests/test-ot-unix-utils.c
+++ b/tests/test-ot-unix-utils.c
@@ -26,14 +26,14 @@
static void
test_ot_util_path_split_validate (void)
{
- const char *paths[] = {"foo/bar", "test", "foo/bar:", "a/b/c/d/e/f/g/h/i/l/m/n/o/p", NULL};
- int n_components[] = {2, 1, 2, 14, 0};
+ const char *paths[] = { "foo/bar", "test", "foo/bar:", "a/b/c/d/e/f/g/h/i/l/m/n/o/p", NULL };
+ int n_components[] = { 2, 1, 2, 14, 0 };
int i;
for (i = 0; paths[i]; i++)
{
GError *error = NULL;
- g_autoptr(GPtrArray) components = NULL;
- if (! ot_util_path_split_validate (paths[i], &components, &error))
+ g_autoptr (GPtrArray) components = NULL;
+ if (!ot_util_path_split_validate (paths[i], &components, &error))
{
int j;
g_assert_cmpint (components->len, ==, n_components[i]);
@@ -49,7 +49,7 @@ test_ot_util_path_split_validate (void)
static void
test_ot_util_filename_validate (void)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
/* Check for valid inputs. */
g_assert (ot_util_filename_validate ("valid", &error));
@@ -74,10 +74,11 @@ test_ot_util_filename_validate (void)
g_clear_error (&error);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/ot_util_path_split_validate", test_ot_util_path_split_validate);
g_test_add_func ("/ot_util_filename_validate", test_ot_util_filename_validate);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-pull-c.c b/tests/test-pull-c.c
index 037a1789..605c6363 100644
--- a/tests/test-pull-c.c
+++ b/tests/test-pull-c.c
@@ -19,14 +19,15 @@
#include "config.h"
#include "libglnx.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
#include "libostreetest.h"
-typedef struct {
+typedef struct
+{
OstreeRepo *repo;
} TestData;
@@ -52,18 +53,20 @@ test_data_init (TestData *td)
repo_url = g_strconcat (http_address, "/ostree/gnomerepo", NULL);
- { g_autoptr(GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
- g_autoptr(GVariant) opts = NULL;
+ {
+ g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariant) opts = NULL;
- g_variant_builder_add (builder, "{s@v}", "gpg-verify", g_variant_new_variant (g_variant_new_boolean (FALSE)));
+ g_variant_builder_add (builder, "{s@v}", "gpg-verify",
+ g_variant_new_variant (g_variant_new_boolean (FALSE)));
opts = g_variant_ref_sink (g_variant_builder_end (builder));
- if (!ostree_repo_remote_change (td->repo, NULL, OSTREE_REPO_REMOTE_CHANGE_ADD,
- "origin", repo_url, opts, NULL, error))
+ if (!ostree_repo_remote_change (td->repo, NULL, OSTREE_REPO_REMOTE_CHANGE_ADD, "origin",
+ repo_url, opts, NULL, error))
goto out;
}
- out:
+out:
g_assert_no_error (local_error);
}
@@ -72,17 +75,17 @@ test_pull_multi_nochange (gconstpointer data)
{
GError *local_error = NULL;
GError **error = &local_error;
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
char *refs[] = { "main", NULL };
- if (!ostree_repo_pull (td->repo, "origin", (char**)&refs, 0, NULL, NULL, error))
+ if (!ostree_repo_pull (td->repo, "origin", (char **)&refs, 0, NULL, NULL, error))
goto out;
- if (!ostree_repo_pull (td->repo, "origin", (char**)&refs, 0, NULL, NULL, error))
+ if (!ostree_repo_pull (td->repo, "origin", (char **)&refs, 0, NULL, NULL, error))
goto out;
- if (!ostree_repo_pull (td->repo, "origin", (char**)&refs, 0, NULL, NULL, error))
+ if (!ostree_repo_pull (td->repo, "origin", (char **)&refs, 0, NULL, NULL, error))
goto out;
- out:
+out:
g_assert_no_error (local_error);
}
@@ -92,32 +95,35 @@ test_pull_multi_error_then_ok (gconstpointer data)
GError *local_error = NULL;
GError **error = &local_error;
- TestData *td = (void*)data;
+ TestData *td = (void *)data;
char *ok_refs[] = { "main", NULL };
char *bad_refs[] = { "nosuchbranch", NULL };
for (guint i = 0; i < 3; i++)
{
- g_autoptr(GError) tmp_error = NULL;
- if (!ostree_repo_pull (td->repo, "origin", (char**)&ok_refs, 0, NULL, NULL, error))
+ g_autoptr (GError) tmp_error = NULL;
+ if (!ostree_repo_pull (td->repo, "origin", (char **)&ok_refs, 0, NULL, NULL, error))
goto out;
- if (ostree_repo_pull (td->repo, "origin", (char**)&bad_refs, 0, NULL, NULL, &tmp_error))
+ if (ostree_repo_pull (td->repo, "origin", (char **)&bad_refs, 0, NULL, NULL, &tmp_error))
g_assert_not_reached ();
g_clear_error (&tmp_error);
- if (ostree_repo_pull (td->repo, "origin", (char**)&bad_refs, 0, NULL, NULL, &tmp_error))
+ if (ostree_repo_pull (td->repo, "origin", (char **)&bad_refs, 0, NULL, NULL, &tmp_error))
g_assert_not_reached ();
g_clear_error (&tmp_error);
- if (!ostree_repo_pull (td->repo, "origin", (char**)&ok_refs, 0, NULL, NULL, error))
+ if (!ostree_repo_pull (td->repo, "origin", (char **)&ok_refs, 0, NULL, NULL, error))
goto out;
}
- out:
+out:
g_assert_no_error (local_error);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- TestData td = {NULL,};
+ TestData td = {
+ NULL,
+ };
int r;
test_data_init (&td);
@@ -127,7 +133,7 @@ int main (int argc, char **argv)
g_test_add_data_func ("/test-pull-c/multi-nochange", &td, test_pull_multi_nochange);
g_test_add_data_func ("/test-pull-c/multi-ok-error-repeat", &td, test_pull_multi_error_then_ok);
- r = g_test_run();
+ r = g_test_run ();
g_clear_object (&td.repo);
return r;
diff --git a/tests/test-repo-finder-avahi.c b/tests/test-repo-finder-avahi.c
index 932c80b1..a187b2f0 100644
--- a/tests/test-repo-finder-avahi.c
+++ b/tests/test-repo-finder-avahi.c
@@ -23,15 +23,15 @@
#include "config.h"
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <locale.h>
#include <string.h>
#include "ostree-autocleanups.h"
-#include "ostree-repo-finder.h"
-#include "ostree-repo-finder-avahi.h"
#include "ostree-repo-finder-avahi-private.h"
+#include "ostree-repo-finder-avahi.h"
+#include "ostree-repo-finder.h"
/* FIXME: Upstream this */
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AvahiStringList, avahi_string_list_free)
@@ -40,8 +40,8 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (AvahiStringList, avahi_string_list_free)
static void
test_repo_finder_avahi_init (void)
{
- g_autoptr(OstreeRepoFinderAvahi) finder = NULL;
- g_autoptr(GMainContext) context = NULL;
+ g_autoptr (OstreeRepoFinderAvahi) finder = NULL;
+ g_autoptr (GMainContext) context = NULL;
/* Default main context. */
finder = ostree_repo_finder_avahi_new (NULL);
@@ -58,36 +58,34 @@ static void
test_repo_finder_avahi_txt_records_parse (void)
{
struct
- {
- const guint8 *txt;
- gsize txt_len;
- const gchar *expected_key; /* (nullable) to indicate parse failure */
- const guint8 *expected_value; /* (nullable) to allow for valueless keys */
- gsize expected_value_len;
- }
- vectors[] =
- {
- { (const guint8 *) "", 0, NULL, NULL, 0 },
- { (const guint8 *) "\x00", 1, NULL, NULL, 0 },
- { (const guint8 *) "\xff", 1, NULL, NULL, 0 },
- { (const guint8 *) "k\x00", 2, NULL, NULL, 0 },
- { (const guint8 *) "k\xff", 2, NULL, NULL, 0 },
- { (const guint8 *) "=", 1, NULL, NULL, 0 },
- { (const guint8 *) "=value", 6, NULL, NULL, 0 },
- { (const guint8 *) "k=v", 3, "k", (const guint8 *) "v", 1 },
- { (const guint8 *) "key=value", 9, "key", (const guint8 *) "value", 5 },
- { (const guint8 *) "k=v=", 4, "k", (const guint8 *) "v=", 2 },
- { (const guint8 *) "k=", 2, "k", (const guint8 *) "", 0 },
- { (const guint8 *) "k", 1, "k", NULL, 0 },
- { (const guint8 *) "k==", 3, "k", (const guint8 *) "=", 1 },
- { (const guint8 *) "k=\x00\x01\x02", 5, "k", (const guint8 *) "\x00\x01\x02", 3 },
- };
+ {
+ const guint8 *txt;
+ gsize txt_len;
+ const gchar *expected_key; /* (nullable) to indicate parse failure */
+ const guint8 *expected_value; /* (nullable) to allow for valueless keys */
+ gsize expected_value_len;
+ } vectors[] = {
+ { (const guint8 *)"", 0, NULL, NULL, 0 },
+ { (const guint8 *)"\x00", 1, NULL, NULL, 0 },
+ { (const guint8 *)"\xff", 1, NULL, NULL, 0 },
+ { (const guint8 *)"k\x00", 2, NULL, NULL, 0 },
+ { (const guint8 *)"k\xff", 2, NULL, NULL, 0 },
+ { (const guint8 *)"=", 1, NULL, NULL, 0 },
+ { (const guint8 *)"=value", 6, NULL, NULL, 0 },
+ { (const guint8 *)"k=v", 3, "k", (const guint8 *)"v", 1 },
+ { (const guint8 *)"key=value", 9, "key", (const guint8 *)"value", 5 },
+ { (const guint8 *)"k=v=", 4, "k", (const guint8 *)"v=", 2 },
+ { (const guint8 *)"k=", 2, "k", (const guint8 *)"", 0 },
+ { (const guint8 *)"k", 1, "k", NULL, 0 },
+ { (const guint8 *)"k==", 3, "k", (const guint8 *)"=", 1 },
+ { (const guint8 *)"k=\x00\x01\x02", 5, "k", (const guint8 *)"\x00\x01\x02", 3 },
+ };
gsize i;
for (i = 0; i < G_N_ELEMENTS (vectors); i++)
{
- g_autoptr(AvahiStringList) string_list = NULL;
- g_autoptr(GHashTable) attributes = NULL;
+ g_autoptr (AvahiStringList) string_list = NULL;
+ g_autoptr (GHashTable) attributes = NULL;
g_test_message ("Vector %" G_GSIZE_FORMAT, i);
@@ -98,18 +96,17 @@ test_repo_finder_avahi_txt_records_parse (void)
if (vectors[i].expected_key != NULL)
{
GBytes *value;
- g_autoptr(GBytes) expected_value = NULL;
+ g_autoptr (GBytes) expected_value = NULL;
- g_assert_true (g_hash_table_lookup_extended (attributes,
- vectors[i].expected_key,
- NULL,
- (gpointer *) &value));
+ g_assert_true (g_hash_table_lookup_extended (attributes, vectors[i].expected_key, NULL,
+ (gpointer *)&value));
g_assert_cmpuint (g_hash_table_size (attributes), ==, 1);
if (vectors[i].expected_value != NULL)
{
g_assert_nonnull (value);
- expected_value = g_bytes_new_static (vectors[i].expected_value, vectors[i].expected_value_len);
+ expected_value
+ = g_bytes_new_static (vectors[i].expected_value, vectors[i].expected_value_len);
g_assert_true (g_bytes_equal (value, expected_value));
}
else
@@ -129,10 +126,10 @@ test_repo_finder_avahi_txt_records_parse (void)
static void
test_repo_finder_avahi_txt_records_duplicates (void)
{
- g_autoptr(AvahiStringList) string_list = NULL;
- g_autoptr(GHashTable) attributes = NULL;
+ g_autoptr (AvahiStringList) string_list = NULL;
+ g_autoptr (GHashTable) attributes = NULL;
GBytes *value;
- g_autoptr(GBytes) expected_value = NULL;
+ g_autoptr (GBytes) expected_value = NULL;
/* Reverse the list before using it, as they are built in reverse order.
* (See the #AvahiStringList documentation.) */
@@ -153,17 +150,14 @@ test_repo_finder_avahi_txt_records_duplicates (void)
static void
test_repo_finder_avahi_txt_records_case_sensitivity (void)
{
- g_autoptr(AvahiStringList) string_list = NULL;
- g_autoptr(GHashTable) attributes = NULL;
+ g_autoptr (AvahiStringList) string_list = NULL;
+ g_autoptr (GHashTable) attributes = NULL;
GBytes *value1, *value2;
- g_autoptr(GBytes) expected_value1 = NULL, expected_value2 = NULL;
+ g_autoptr (GBytes) expected_value1 = NULL, expected_value2 = NULL;
/* Reverse the list before using it, as they are built in reverse order.
* (See the #AvahiStringList documentation.) */
- string_list = avahi_string_list_new ("k=value1",
- "K=value2",
- "KeY2=v",
- NULL);
+ string_list = avahi_string_list_new ("k=value1", "K=value2", "KeY2=v", NULL);
string_list = avahi_string_list_reverse (string_list);
attributes = _ostree_txt_records_parse (string_list);
@@ -189,14 +183,12 @@ test_repo_finder_avahi_txt_records_case_sensitivity (void)
static void
test_repo_finder_avahi_txt_records_empty_and_missing (void)
{
- g_autoptr(AvahiStringList) string_list = NULL;
- g_autoptr(GHashTable) attributes = NULL;
+ g_autoptr (AvahiStringList) string_list = NULL;
+ g_autoptr (GHashTable) attributes = NULL;
GBytes *value1, *value2;
- g_autoptr(GBytes) expected_value1 = NULL;
+ g_autoptr (GBytes) expected_value1 = NULL;
- string_list = avahi_string_list_new ("empty=",
- "missing",
- NULL);
+ string_list = avahi_string_list_new ("empty=", "missing", NULL);
attributes = _ostree_txt_records_parse (string_list);
g_assert_cmpuint (g_hash_table_size (attributes), ==, 2);
@@ -206,22 +198,27 @@ test_repo_finder_avahi_txt_records_empty_and_missing (void)
expected_value1 = g_bytes_new_static ("", 0);
g_assert_true (g_bytes_equal (value1, expected_value1));
- g_assert_true (g_hash_table_lookup_extended (attributes, "missing", NULL, (gpointer *) &value2));
+ g_assert_true (g_hash_table_lookup_extended (attributes, "missing", NULL, (gpointer *)&value2));
g_assert_null (value2);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/repo-finder-avahi/init", test_repo_finder_avahi_init);
- g_test_add_func ("/repo-finder-avahi/txt-records/parse", test_repo_finder_avahi_txt_records_parse);
- g_test_add_func ("/repo-finder-avahi/txt-records/duplicates", test_repo_finder_avahi_txt_records_duplicates);
- g_test_add_func ("/repo-finder-avahi/txt-records/case-sensitivity", test_repo_finder_avahi_txt_records_case_sensitivity);
- g_test_add_func ("/repo-finder-avahi/txt-records/empty-and-missing", test_repo_finder_avahi_txt_records_empty_and_missing);
+ g_test_add_func ("/repo-finder-avahi/txt-records/parse",
+ test_repo_finder_avahi_txt_records_parse);
+ g_test_add_func ("/repo-finder-avahi/txt-records/duplicates",
+ test_repo_finder_avahi_txt_records_duplicates);
+ g_test_add_func ("/repo-finder-avahi/txt-records/case-sensitivity",
+ test_repo_finder_avahi_txt_records_case_sensitivity);
+ g_test_add_func ("/repo-finder-avahi/txt-records/empty-and-missing",
+ test_repo_finder_avahi_txt_records_empty_and_missing);
/* FIXME: Add tests for service processing, probably by splitting the
* code in OstreeRepoFinderAvahi around found_services. */
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-repo-finder-config.c b/tests/test-repo-finder-config.c
index 30f1b206..4b08b2eb 100644
--- a/tests/test-repo-finder-config.c
+++ b/tests/test-repo-finder-config.c
@@ -23,30 +23,29 @@
#include "config.h"
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <libglnx.h>
#include <locale.h>
#include <string.h>
#include "libostreetest.h"
#include "ostree-autocleanups.h"
-#include "ostree-repo-finder.h"
#include "ostree-repo-finder-config.h"
+#include "ostree-repo-finder.h"
/* Test fixture. Creates a temporary directory. */
typedef struct
{
- OstreeRepo *parent_repo; /* owned */
- GLnxTmpDir tmpdir; /* owned */
- GFile *working_dir; /* owned */
+ OstreeRepo *parent_repo; /* owned */
+ GLnxTmpDir tmpdir; /* owned */
+ GFile *working_dir; /* owned */
} Fixture;
static void
-setup (Fixture *fixture,
- gconstpointer test_data)
+setup (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
(void)glnx_mkdtemp ("test-repo-finder-config-XXXXXX", 0700, &fixture->tmpdir, &error);
g_assert_no_error (error);
@@ -63,8 +62,7 @@ setup (Fixture *fixture,
}
static void
-teardown (Fixture *fixture,
- gconstpointer test_data)
+teardown (Fixture *fixture, gconstpointer test_data)
{
/* Recursively remove the temporary directory. */
(void)glnx_tmpdir_delete (&fixture->tmpdir, NULL, NULL);
@@ -83,16 +81,14 @@ teardown (Fixture *fixture,
static void
test_repo_finder_config_init (void)
{
- g_autoptr(OstreeRepoFinderConfig) finder = NULL;
+ g_autoptr (OstreeRepoFinderConfig) finder = NULL;
/* Default everything. */
finder = ostree_repo_finder_config_new ();
}
static void
-result_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+result_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
GAsyncResult **result_out = user_data;
*result_out = g_object_ref (result);
@@ -101,31 +97,29 @@ result_cb (GObject *source_object,
/* Test that no remotes are found if there are no config files in the refs
* directory. */
static void
-test_repo_finder_config_no_configs (Fixture *fixture,
- gconstpointer test_data)
+test_repo_finder_config_no_configs (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(OstreeRepoFinderConfig) finder = NULL;
- g_autoptr(GMainContext) context = NULL;
- g_autoptr(GAsyncResult) result = NULL;
- g_autoptr(GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
- g_autoptr(GError) error = NULL;
+ g_autoptr (OstreeRepoFinderConfig) finder = NULL;
+ g_autoptr (GMainContext) context = NULL;
+ g_autoptr (GAsyncResult) result = NULL;
+ g_autoptr (GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
+ g_autoptr (GError) error = NULL;
const OstreeCollectionRef ref1 = { "org.example.Os", "exampleos/x86_64/standard" };
const OstreeCollectionRef ref2 = { "org.example.Os", "exampleos/x86_64/buildmain/standard" };
- const OstreeCollectionRef * const refs[] = { &ref1, &ref2, NULL };
+ const OstreeCollectionRef *const refs[] = { &ref1, &ref2, NULL };
context = g_main_context_new ();
g_main_context_push_thread_default (context);
finder = ostree_repo_finder_config_new ();
- ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs,
- fixture->parent_repo, NULL, result_cb, &result);
+ ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs, fixture->parent_repo, NULL,
+ result_cb, &result);
while (result == NULL)
g_main_context_iteration (context, TRUE);
- results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder),
- result, &error);
+ results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder), result, &error);
g_assert_no_error (error);
g_assert_nonnull (results);
g_assert_cmpuint (results->len, ==, 0);
@@ -136,36 +130,30 @@ test_repo_finder_config_no_configs (Fixture *fixture,
/* Add configuration for a remote named @remote_name, at @remote_uri, with a
* remote collection ID of @collection_id, to the given @repo. */
static void
-assert_create_remote_config (OstreeRepo *repo,
- const gchar *remote_name,
- const gchar *remote_uri,
+assert_create_remote_config (OstreeRepo *repo, const gchar *remote_name, const gchar *remote_uri,
const gchar *collection_id)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(GVariant) options = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GVariant) options = NULL;
if (collection_id != NULL)
- options = g_variant_new_parsed ("@a{sv} { 'collection-id': <%s> }",
- collection_id);
+ options = g_variant_new_parsed ("@a{sv} { 'collection-id': <%s> }", collection_id);
ostree_repo_remote_add (repo, remote_name, remote_uri, options, NULL, &error);
g_assert_no_error (error);
}
-static gchar *assert_create_remote (Fixture *fixture,
- const gchar *collection_id,
+static gchar *assert_create_remote (Fixture *fixture, const gchar *collection_id,
...) G_GNUC_NULL_TERMINATED;
/* Create a new repository in a temporary directory with its collection ID set
* to @collection_id, and containing the refs given in @... (which must be
* %NULL-terminated). Return the `file://` URI of the new repository. */
static gchar *
-assert_create_remote (Fixture *fixture,
- const gchar *collection_id,
- ...)
+assert_create_remote (Fixture *fixture, const gchar *collection_id, ...)
{
va_list args;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
const gchar *repo_name = (collection_id != NULL) ? collection_id : "no-collection";
glnx_shutil_mkdir_p_at (fixture->tmpdir.fd, repo_name, 0700, NULL, &error);
@@ -174,8 +162,8 @@ assert_create_remote (Fixture *fixture,
glnx_shutil_mkdir_p_at (fixture->tmpdir.fd, "empty", 0700, NULL, &error);
g_assert_no_error (error);
- g_autoptr(GFile) repo_path = g_file_get_child (fixture->working_dir, repo_name);
- g_autoptr(OstreeRepo) repo = ostree_repo_new (repo_path);
+ g_autoptr (GFile) repo_path = g_file_get_child (fixture->working_dir, repo_name);
+ g_autoptr (OstreeRepo) repo = ostree_repo_new (repo_path);
ostree_repo_set_collection_id (repo, collection_id, &error);
g_assert_no_error (error);
ostree_repo_create (repo, OSTREE_REPO_MODE_ARCHIVE, NULL, &error);
@@ -184,24 +172,22 @@ assert_create_remote (Fixture *fixture,
/* Set up the refs from @.... */
va_start (args, collection_id);
- for (const gchar *ref_name = va_arg (args, const gchar *);
- ref_name != NULL;
+ for (const gchar *ref_name = va_arg (args, const gchar *); ref_name != NULL;
ref_name = va_arg (args, const gchar *))
{
- OstreeCollectionRef collection_ref = { (gchar *) collection_id, (gchar *) ref_name };
+ OstreeCollectionRef collection_ref = { (gchar *)collection_id, (gchar *)ref_name };
g_autofree gchar *checksum = NULL;
- g_autoptr(OstreeMutableTree) mtree = NULL;
- g_autoptr(OstreeRepoFile) repo_file = NULL;
+ g_autoptr (OstreeMutableTree) mtree = NULL;
+ g_autoptr (OstreeRepoFile) repo_file = NULL;
mtree = ostree_mutable_tree_new ();
ostree_repo_write_dfd_to_mtree (repo, fixture->tmpdir.fd, "empty", mtree, NULL, NULL, &error);
g_assert_no_error (error);
- ostree_repo_write_mtree (repo, mtree, (GFile **) &repo_file, NULL, &error);
+ ostree_repo_write_mtree (repo, mtree, (GFile **)&repo_file, NULL, &error);
g_assert_no_error (error);
- ostree_repo_write_commit (repo, NULL /* no parent */, ref_name, ref_name,
- NULL /* no metadata */, repo_file, &checksum,
- NULL, &error);
+ ostree_repo_write_commit (repo, NULL /* no parent */, ref_name, ref_name,
+ NULL /* no metadata */, repo_file, &checksum, NULL, &error);
g_assert_no_error (error);
if (collection_id != NULL)
@@ -214,7 +200,7 @@ assert_create_remote (Fixture *fixture,
va_end (args);
/* Update the summary. */
- ostree_repo_regenerate_summary (repo, NULL /* no metadata */, NULL, &error);
+ ostree_repo_regenerate_summary (repo, NULL /* no metadata */, NULL, &error);
g_assert_no_error (error);
return g_file_get_uri (repo_path);
@@ -223,54 +209,52 @@ assert_create_remote (Fixture *fixture,
/* Test resolving the refs against a collection of config files, which contain
* valid, invalid or duplicate repo information. */
static void
-test_repo_finder_config_mixed_configs (Fixture *fixture,
- gconstpointer test_data)
+test_repo_finder_config_mixed_configs (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(OstreeRepoFinderConfig) finder = NULL;
- g_autoptr(GMainContext) context = NULL;
- g_autoptr(GAsyncResult) async_result = NULL;
- g_autoptr(GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
- g_autoptr(GError) error = NULL;
+ g_autoptr (OstreeRepoFinderConfig) finder = NULL;
+ g_autoptr (GMainContext) context = NULL;
+ g_autoptr (GAsyncResult) async_result = NULL;
+ g_autoptr (GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
+ g_autoptr (GError) error = NULL;
gsize i;
const OstreeCollectionRef ref0 = { "org.example.Collection0", "exampleos/x86_64/ref0" };
const OstreeCollectionRef ref1 = { "org.example.Collection0", "exampleos/x86_64/ref1" };
const OstreeCollectionRef ref2 = { "org.example.Collection1", "exampleos/x86_64/ref1" };
const OstreeCollectionRef ref3 = { "org.example.Collection1", "exampleos/x86_64/ref2" };
const OstreeCollectionRef ref4 = { "org.example.Collection2", "exampleos/x86_64/ref3" };
- const OstreeCollectionRef * const refs[] = { &ref0, &ref1, &ref2, &ref3, &ref4, NULL };
+ const OstreeCollectionRef *const refs[] = { &ref0, &ref1, &ref2, &ref3, &ref4, NULL };
context = g_main_context_new ();
g_main_context_push_thread_default (context);
/* Put together various ref configuration files. */
- g_autofree gchar *collection0_uri = assert_create_remote (fixture, "org.example.Collection0",
- "exampleos/x86_64/ref0",
- "exampleos/x86_64/ref1",
- NULL);
- g_autofree gchar *collection1_uri = assert_create_remote (fixture, "org.example.Collection1",
- "exampleos/x86_64/ref2",
- NULL);
- g_autofree gchar *no_collection_uri = assert_create_remote (fixture, NULL,
- "exampleos/x86_64/ref3",
- NULL);
-
- assert_create_remote_config (fixture->parent_repo, "remote0", collection0_uri, "org.example.Collection0");
- assert_create_remote_config (fixture->parent_repo, "remote1", collection1_uri, "org.example.Collection1");
- assert_create_remote_config (fixture->parent_repo, "remote0-copy", collection0_uri, "org.example.Collection0");
- assert_create_remote_config (fixture->parent_repo, "remote1-bad-copy", collection1_uri, "org.example.NotCollection1");
+ g_autofree gchar *collection0_uri = assert_create_remote (
+ fixture, "org.example.Collection0", "exampleos/x86_64/ref0", "exampleos/x86_64/ref1", NULL);
+ g_autofree gchar *collection1_uri
+ = assert_create_remote (fixture, "org.example.Collection1", "exampleos/x86_64/ref2", NULL);
+ g_autofree gchar *no_collection_uri
+ = assert_create_remote (fixture, NULL, "exampleos/x86_64/ref3", NULL);
+
+ assert_create_remote_config (fixture->parent_repo, "remote0", collection0_uri,
+ "org.example.Collection0");
+ assert_create_remote_config (fixture->parent_repo, "remote1", collection1_uri,
+ "org.example.Collection1");
+ assert_create_remote_config (fixture->parent_repo, "remote0-copy", collection0_uri,
+ "org.example.Collection0");
+ assert_create_remote_config (fixture->parent_repo, "remote1-bad-copy", collection1_uri,
+ "org.example.NotCollection1");
assert_create_remote_config (fixture->parent_repo, "remote2", no_collection_uri, NULL);
finder = ostree_repo_finder_config_new ();
/* Resolve the refs. */
- ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs,
- fixture->parent_repo, NULL, result_cb, &async_result);
+ ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs, fixture->parent_repo, NULL,
+ result_cb, &async_result);
while (async_result == NULL)
g_main_context_iteration (context, TRUE);
- results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder),
- async_result, &error);
+ results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder), async_result, &error);
g_assert_no_error (error);
g_assert_nonnull (results);
g_assert_cmpuint (results->len, ==, 3);
@@ -281,8 +265,8 @@ test_repo_finder_config_mixed_configs (Fixture *fixture,
{
const OstreeRepoFinderResult *result = g_ptr_array_index (results, i);
- if (g_strcmp0 (ostree_remote_get_name (result->remote), "remote0") == 0 ||
- g_strcmp0 (ostree_remote_get_name (result->remote), "remote0-copy") == 0)
+ if (g_strcmp0 (ostree_remote_get_name (result->remote), "remote0") == 0
+ || g_strcmp0 (ostree_remote_get_name (result->remote), "remote0-copy") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 2);
g_assert_true (g_hash_table_contains (result->ref_to_checksum, &ref0));
@@ -306,58 +290,57 @@ test_repo_finder_config_mixed_configs (Fixture *fixture,
/* Test that using ostree_repo_find_remotes_async() works too.*/
static void
-test_repo_finder_config_find_remotes (Fixture *fixture,
- gconstpointer test_data)
+test_repo_finder_config_find_remotes (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GMainContext) context = NULL;
- g_autoptr(GAsyncResult) result = NULL;
- g_auto(OstreeRepoFinderResultv) results = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GMainContext) context = NULL;
+ g_autoptr (GAsyncResult) result = NULL;
+ g_auto (OstreeRepoFinderResultv) results = NULL;
+ g_autoptr (GError) error = NULL;
gsize i;
const OstreeCollectionRef ref0 = { "org.example.Collection0", "exampleos/x86_64/ref0" };
const OstreeCollectionRef ref1 = { "org.example.Collection0", "exampleos/x86_64/ref1" };
const OstreeCollectionRef ref2 = { "org.example.Collection1", "exampleos/x86_64/ref1" };
const OstreeCollectionRef ref3 = { "org.example.Collection1", "exampleos/x86_64/ref2" };
const OstreeCollectionRef ref4 = { "org.example.Collection2", "exampleos/x86_64/ref3" };
- const OstreeCollectionRef * const refs[] = { &ref0, &ref1, &ref2, &ref3, &ref4, NULL };
- OstreeRepoFinder *finders[2] = {NULL, };
+ const OstreeCollectionRef *const refs[] = { &ref0, &ref1, &ref2, &ref3, &ref4, NULL };
+ OstreeRepoFinder *finders[2] = {
+ NULL,
+ };
context = g_main_context_new ();
g_main_context_push_thread_default (context);
/* Put together various ref configuration files. */
- g_autofree gchar *collection0_uri = assert_create_remote (fixture, "org.example.Collection0",
- "exampleos/x86_64/ref0",
- "exampleos/x86_64/ref1",
- NULL);
- g_autofree gchar *collection1_uri = assert_create_remote (fixture, "org.example.Collection1",
- "exampleos/x86_64/ref2",
- NULL);
- g_autofree gchar *no_collection_uri = assert_create_remote (fixture, NULL,
- "exampleos/x86_64/ref3",
- NULL);
-
- assert_create_remote_config (fixture->parent_repo, "remote0", collection0_uri, "org.example.Collection0");
- assert_create_remote_config (fixture->parent_repo, "remote1", collection1_uri, "org.example.Collection1");
- assert_create_remote_config (fixture->parent_repo, "remote0-copy", collection0_uri, "org.example.Collection0");
- assert_create_remote_config (fixture->parent_repo, "remote1-bad-copy", collection1_uri, "org.example.NotCollection1");
+ g_autofree gchar *collection0_uri = assert_create_remote (
+ fixture, "org.example.Collection0", "exampleos/x86_64/ref0", "exampleos/x86_64/ref1", NULL);
+ g_autofree gchar *collection1_uri
+ = assert_create_remote (fixture, "org.example.Collection1", "exampleos/x86_64/ref2", NULL);
+ g_autofree gchar *no_collection_uri
+ = assert_create_remote (fixture, NULL, "exampleos/x86_64/ref3", NULL);
+
+ assert_create_remote_config (fixture->parent_repo, "remote0", collection0_uri,
+ "org.example.Collection0");
+ assert_create_remote_config (fixture->parent_repo, "remote1", collection1_uri,
+ "org.example.Collection1");
+ assert_create_remote_config (fixture->parent_repo, "remote0-copy", collection0_uri,
+ "org.example.Collection0");
+ assert_create_remote_config (fixture->parent_repo, "remote1-bad-copy", collection1_uri,
+ "org.example.NotCollection1");
assert_create_remote_config (fixture->parent_repo, "remote2", no_collection_uri, NULL);
finders[0] = OSTREE_REPO_FINDER (ostree_repo_finder_config_new ());
/* Resolve the refs. */
- ostree_repo_find_remotes_async (fixture->parent_repo, refs,
- NULL, finders,
- NULL, NULL, result_cb, &result);
+ ostree_repo_find_remotes_async (fixture->parent_repo, refs, NULL, finders, NULL, NULL, result_cb,
+ &result);
while (result == NULL)
g_main_context_iteration (context, TRUE);
- results = ostree_repo_find_remotes_finish (fixture->parent_repo,
- result, &error);
+ results = ostree_repo_find_remotes_finish (fixture->parent_repo, result, &error);
g_assert_no_error (error);
g_assert_nonnull (results);
- g_assert_cmpuint (g_strv_length ((char **) results), ==, 3);
+ g_assert_cmpuint (g_strv_length ((char **)results), ==, 3);
/* Check that the results are correct: the invalid refs should have been
* ignored, and the valid results canonicalised and deduplicated. */
@@ -366,8 +349,8 @@ test_repo_finder_config_find_remotes (Fixture *fixture,
const char *ref0_checksum, *ref1_checksum, *ref2_checksum, *ref3_checksum;
guint64 *ref0_timestamp, *ref1_timestamp, *ref2_timestamp, *ref3_timestamp;
- if (g_strcmp0 (ostree_remote_get_name (results[i]->remote), "remote0") == 0 ||
- g_strcmp0 (ostree_remote_get_name (results[i]->remote), "remote0-copy") == 0)
+ if (g_strcmp0 (ostree_remote_get_name (results[i]->remote), "remote0") == 0
+ || g_strcmp0 (ostree_remote_get_name (results[i]->remote), "remote0-copy") == 0)
{
g_assert_cmpuint (g_hash_table_size (results[i]->ref_to_checksum), ==, 5);
@@ -427,7 +410,8 @@ test_repo_finder_config_find_remotes (Fixture *fixture,
g_main_context_pop_thread_default (context);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
@@ -440,5 +424,5 @@ int main (int argc, char **argv)
g_test_add ("/repo-finder-config/find-remotes", Fixture, NULL, setup,
test_repo_finder_config_find_remotes, teardown);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-repo-finder-mount.c b/tests/test-repo-finder-mount.c
index 13797030..0bbcd844 100644
--- a/tests/test-repo-finder-mount.c
+++ b/tests/test-repo-finder-mount.c
@@ -23,16 +23,16 @@
#include "config.h"
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <libglnx.h>
#include <locale.h>
#include "libostreetest.h"
#include "ostree-autocleanups.h"
#include "ostree-remote-private.h"
-#include "ostree-repo-finder.h"
#include "ostree-repo-finder-mount.h"
+#include "ostree-repo-finder.h"
#include "ostree-types.h"
#include "test-mock-gio.h"
@@ -40,15 +40,14 @@
typedef struct
{
OstreeRepo *parent_repo;
- GLnxTmpDir tmpdir; /* owned */
+ GLnxTmpDir tmpdir; /* owned */
GFile *working_dir; /* Points at tmpdir */
} Fixture;
static void
-setup (Fixture *fixture,
- gconstpointer test_data)
+setup (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
(void)glnx_mkdtemp ("test-repo-finder-mount-XXXXXX", 0700, &fixture->tmpdir, &error);
g_assert_no_error (error);
@@ -69,8 +68,7 @@ setup (Fixture *fixture,
}
static void
-teardown (Fixture *fixture,
- gconstpointer test_data)
+teardown (Fixture *fixture, gconstpointer test_data)
{
/* Recursively remove the temporary directory. */
(void)glnx_tmpdir_delete (&fixture->tmpdir, NULL, NULL);
@@ -89,8 +87,8 @@ teardown (Fixture *fixture,
static void
test_repo_finder_mount_init (void)
{
- g_autoptr(OstreeRepoFinderMount) finder = NULL;
- g_autoptr(GVolumeMonitor) monitor = NULL;
+ g_autoptr (OstreeRepoFinderMount) finder = NULL;
+ g_autoptr (GVolumeMonitor) monitor = NULL;
/* Default #GVolumeMonitor. */
finder = ostree_repo_finder_mount_new (NULL);
@@ -103,9 +101,7 @@ test_repo_finder_mount_init (void)
}
static void
-result_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+result_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
GAsyncResult **result_out = user_data;
*result_out = g_object_ref (result);
@@ -113,20 +109,20 @@ result_cb (GObject *source_object,
/* Test that no remotes are found if the #GVolumeMonitor returns no mounts. */
static void
-test_repo_finder_mount_no_mounts (Fixture *fixture,
- gconstpointer test_data)
+test_repo_finder_mount_no_mounts (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(OstreeRepoFinderMount) finder = NULL;
- g_autoptr(GVolumeMonitor) monitor = NULL;
- g_autoptr(GMainContext) context = NULL;
- g_autoptr(GAsyncResult) result = NULL;
- g_autoptr(GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
- g_autoptr(GError) error = NULL;
+ g_autoptr (OstreeRepoFinderMount) finder = NULL;
+ g_autoptr (GVolumeMonitor) monitor = NULL;
+ g_autoptr (GMainContext) context = NULL;
+ g_autoptr (GAsyncResult) result = NULL;
+ g_autoptr (GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
+ g_autoptr (GError) error = NULL;
const OstreeCollectionRef ref1 = { "org.example.Collection1", "exampleos/x86_64/standard" };
- const OstreeCollectionRef ref2 = { "org.example.Collection1", "exampleos/x86_64/buildmain/standard" };
+ const OstreeCollectionRef ref2
+ = { "org.example.Collection1", "exampleos/x86_64/buildmain/standard" };
const OstreeCollectionRef ref3 = { "org.example.Collection2", "exampleos/x86_64/standard" };
const OstreeCollectionRef ref4 = { "org.example.Collection2", "exampleos/arm64/standard" };
- const OstreeCollectionRef * const refs[] = { &ref1, &ref2, &ref3, &ref4, NULL };
+ const OstreeCollectionRef *const refs[] = { &ref1, &ref2, &ref3, &ref4, NULL };
context = g_main_context_new ();
g_main_context_push_thread_default (context);
@@ -134,15 +130,13 @@ test_repo_finder_mount_no_mounts (Fixture *fixture,
monitor = ostree_mock_volume_monitor_new (NULL, NULL);
finder = ostree_repo_finder_mount_new (monitor);
- ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs,
- fixture->parent_repo,
- NULL, result_cb, &result);
+ ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs, fixture->parent_repo, NULL,
+ result_cb, &result);
while (result == NULL)
g_main_context_iteration (context, TRUE);
- results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder),
- result, &error);
+ results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder), result, &error);
g_assert_no_error (error);
g_assert_nonnull (results);
g_assert_cmpuint (results->len, ==, 0);
@@ -152,13 +146,11 @@ test_repo_finder_mount_no_mounts (Fixture *fixture,
/* Create a .ostree/repos.d directory under the given @mount_root, or abort. */
static gboolean
-assert_create_repos_dir (Fixture *fixture,
- const gchar *mount_root_name,
- int *out_repos_dfd,
- GMount **out_mount)
+assert_create_repos_dir (Fixture *fixture, const gchar *mount_root_name, int *out_repos_dfd,
+ GMount **out_mount)
{
glnx_autofd int repos_dfd = -1;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
g_autofree gchar *path = g_build_filename (mount_root_name, ".ostree", "repos.d", NULL);
glnx_shutil_mkdir_p_at_open (fixture->tmpdir.fd, path, 0700, &repos_dfd, NULL, &error);
@@ -167,7 +159,7 @@ assert_create_repos_dir (Fixture *fixture,
g_assert_no_error (error);
*out_repos_dfd = g_steal_fd (&repos_dfd);
- g_autoptr(GFile) mount_root = g_file_get_child (fixture->working_dir, mount_root_name);
+ g_autoptr (GFile) mount_root = g_file_get_child (fixture->working_dir, mount_root_name);
*out_mount = G_MOUNT (ostree_mock_mount_new (mount_root_name, mount_root));
return TRUE;
@@ -178,13 +170,11 @@ assert_create_repos_dir (Fixture *fixture,
* #OstreeCollectionRef in @... is followed by a gchar** return address for the
* checksum committed for that ref. Return the new repository. */
static OstreeRepo *
-assert_create_remote_va (Fixture *fixture,
- GFile *repo_dir,
- va_list args)
+assert_create_remote_va (Fixture *fixture, GFile *repo_dir, va_list args)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_new (repo_dir);
+ g_autoptr (OstreeRepo) repo = ostree_repo_new (repo_dir);
ostree_repo_create (repo, OSTREE_REPO_MODE_ARCHIVE, NULL, &error);
g_assert_no_error (error);
@@ -192,24 +182,22 @@ assert_create_remote_va (Fixture *fixture,
g_assert_no_error (error);
/* Set up the refs from @.... */
- for (const OstreeCollectionRef *ref = va_arg (args, const OstreeCollectionRef *);
- ref != NULL;
+ for (const OstreeCollectionRef *ref = va_arg (args, const OstreeCollectionRef *); ref != NULL;
ref = va_arg (args, const OstreeCollectionRef *))
{
g_autofree gchar *checksum = NULL;
- g_autoptr(OstreeMutableTree) mtree = NULL;
- g_autoptr(OstreeRepoFile) repo_file = NULL;
+ g_autoptr (OstreeMutableTree) mtree = NULL;
+ g_autoptr (OstreeRepoFile) repo_file = NULL;
gchar **out_checksum = va_arg (args, gchar **);
mtree = ostree_mutable_tree_new ();
ostree_repo_write_dfd_to_mtree (repo, fixture->tmpdir.fd, "empty", mtree, NULL, NULL, &error);
g_assert_no_error (error);
- ostree_repo_write_mtree (repo, mtree, (GFile **) &repo_file, NULL, &error);
+ ostree_repo_write_mtree (repo, mtree, (GFile **)&repo_file, NULL, &error);
g_assert_no_error (error);
- ostree_repo_write_commit (repo, NULL /* no parent */, ref->ref_name, ref->ref_name,
- NULL /* no metadata */, repo_file, &checksum,
- NULL, &error);
+ ostree_repo_write_commit (repo, NULL /* no parent */, ref->ref_name, ref->ref_name,
+ NULL /* no metadata */, repo_file, &checksum, NULL, &error);
g_assert_no_error (error);
if (ref->collection_id != NULL)
@@ -223,34 +211,26 @@ assert_create_remote_va (Fixture *fixture,
}
/* Update the summary. */
- ostree_repo_regenerate_summary (repo, NULL /* no metadata */, NULL, &error);
+ ostree_repo_regenerate_summary (repo, NULL /* no metadata */, NULL, &error);
g_assert_no_error (error);
return g_steal_pointer (&repo);
}
-static OstreeRepo *
-assert_create_repo_dir (Fixture *fixture,
- int repos_dfd,
- GMount *repos_mount,
- const char *repo_name,
- gchar **out_uri,
- ...) G_GNUC_NULL_TERMINATED;
+static OstreeRepo *assert_create_repo_dir (Fixture *fixture, int repos_dfd, GMount *repos_mount,
+ const char *repo_name, gchar **out_uri,
+ ...) G_GNUC_NULL_TERMINATED;
/* Create a @repo_name directory under the given @repos_dfd, or abort. Create a
* new repository in it with the refs given in @..., as per
* assert_create_remote_va(). Return the URI of the repository. */
static OstreeRepo *
-assert_create_repo_dir (Fixture *fixture,
- int repos_dfd,
- GMount *repos_mount,
- const char *repo_name,
- gchar **out_uri,
- ...)
+assert_create_repo_dir (Fixture *fixture, int repos_dfd, GMount *repos_mount, const char *repo_name,
+ gchar **out_uri, ...)
{
glnx_autofd int ref_dfd = -1;
- g_autoptr(OstreeRepo) repo = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
+ g_autoptr (GError) error = NULL;
va_list args;
glnx_shutil_mkdir_p_at_open (repos_dfd, repo_name, 0700, &ref_dfd, NULL, &error);
@@ -258,9 +238,9 @@ assert_create_repo_dir (Fixture *fixture,
g_clear_error (&error);
g_assert_no_error (error);
- g_autoptr(GFile) mount_root = g_mount_get_root (repos_mount);
- g_autoptr(GFile) repos_dir = g_file_get_child (mount_root, ".ostree/repos.d");
- g_autoptr(GFile) repo_dir = g_file_get_child (repos_dir, repo_name);
+ g_autoptr (GFile) mount_root = g_mount_get_root (repos_mount);
+ g_autoptr (GFile) repos_dir = g_file_get_child (mount_root, ".ostree/repos.d");
+ g_autoptr (GFile) repo_dir = g_file_get_child (repos_dir, repo_name);
va_start (args, out_uri);
repo = assert_create_remote_va (fixture, repo_dir, args);
@@ -274,13 +254,11 @@ assert_create_repo_dir (Fixture *fixture,
/* Create a @repo_name symlink under the given @repos_dfd, pointing to
* @symlink_target_path, or abort. */
static void
-assert_create_repo_symlink (int repos_dfd,
- const char *repo_name,
- const char *symlink_target_path)
+assert_create_repo_symlink (int repos_dfd, const char *repo_name, const char *symlink_target_path)
{
if (TEMP_FAILURE_RETRY (symlinkat (symlink_target_path, repos_dfd, repo_name)) != 0)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
glnx_throw_errno_prefix (&error, "symlinkat");
g_assert_no_error (error);
}
@@ -289,17 +267,14 @@ assert_create_repo_symlink (int repos_dfd,
/* Add configuration for a remote named @remote_name, at @remote_uri, with a
* remote collection ID of @collection_id, to the given @repo. */
static void
-assert_create_remote_config (OstreeRepo *repo,
- const gchar *remote_name,
- const gchar *remote_uri,
+assert_create_remote_config (OstreeRepo *repo, const gchar *remote_name, const gchar *remote_uri,
const gchar *collection_id)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(GVariant) options = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GVariant) options = NULL;
if (collection_id != NULL)
- options = g_variant_new_parsed ("@a{sv} { 'collection-id': <%s> }",
- collection_id);
+ options = g_variant_new_parsed ("@a{sv} { 'collection-id': <%s> }", collection_id);
ostree_repo_remote_add (repo, remote_name, remote_uri, options, NULL, &error);
g_assert_no_error (error);
@@ -309,39 +284,41 @@ assert_create_remote_config (OstreeRepo *repo,
* are mounted, some of which are removable, some of which contain valid or
* invalid repo information on the file system, etc. */
static void
-test_repo_finder_mount_mixed_mounts (Fixture *fixture,
- gconstpointer test_data)
+test_repo_finder_mount_mixed_mounts (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(OstreeRepoFinderMount) finder = NULL;
- g_autoptr(GVolumeMonitor) monitor = NULL;
- g_autoptr(GMainContext) context = NULL;
- g_autoptr(GAsyncResult) async_result = NULL;
- g_autoptr(GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
- g_autoptr(GError) error = NULL;
- g_autoptr(GList) mounts = NULL; /* (element-type OstreeMockMount) */
- g_autoptr(GMount) non_removable_mount = NULL;
- g_autoptr(GMount) no_repos_mount = NULL;
- g_autoptr(GMount) repo1_mount = NULL;
- g_autoptr(GMount) repo2_mount = NULL;
- g_autoptr(GFile) non_removable_root = NULL;
+ g_autoptr (OstreeRepoFinderMount) finder = NULL;
+ g_autoptr (GVolumeMonitor) monitor = NULL;
+ g_autoptr (GMainContext) context = NULL;
+ g_autoptr (GAsyncResult) async_result = NULL;
+ g_autoptr (GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GList) mounts = NULL; /* (element-type OstreeMockMount) */
+ g_autoptr (GMount) non_removable_mount = NULL;
+ g_autoptr (GMount) no_repos_mount = NULL;
+ g_autoptr (GMount) repo1_mount = NULL;
+ g_autoptr (GMount) repo2_mount = NULL;
+ g_autoptr (GFile) non_removable_root = NULL;
glnx_autofd int no_repos_repos = -1;
glnx_autofd int repo1_repos = -1;
glnx_autofd int repo2_repos = -1;
- g_autoptr(OstreeRepo) repo1_repo_a = NULL, repo1_repo_b = NULL;
- g_autoptr(OstreeRepo) repo2_repo_a = NULL;
+ g_autoptr (OstreeRepo) repo1_repo_a = NULL, repo1_repo_b = NULL;
+ g_autoptr (OstreeRepo) repo2_repo_a = NULL;
g_autofree gchar *repo1_repo_a_uri = NULL, *repo1_repo_b_uri = NULL;
g_autofree gchar *repo2_repo_a_uri = NULL;
- g_autofree gchar *repo1_ref0_checksum = NULL, *repo1_ref1_checksum = NULL, *repo1_ref2_checksum = NULL;
- g_autofree gchar *repo2_ref0_checksum = NULL, *repo2_ref1_checksum = NULL, *repo2_ref2_checksum = NULL;
+ g_autofree gchar *repo1_ref0_checksum = NULL, *repo1_ref1_checksum = NULL,
+ *repo1_ref2_checksum = NULL;
+ g_autofree gchar *repo2_ref0_checksum = NULL, *repo2_ref1_checksum = NULL,
+ *repo2_ref2_checksum = NULL;
g_autofree gchar *repo1_ref5_checksum = NULL, *repo2_ref3_checksum = NULL;
gsize i;
const OstreeCollectionRef ref0 = { "org.example.Collection1", "exampleos/x86_64/ref0" };
const OstreeCollectionRef ref1 = { "org.example.Collection1", "exampleos/x86_64/ref1" };
const OstreeCollectionRef ref2 = { "org.example.Collection1", "exampleos/x86_64/ref2" };
const OstreeCollectionRef ref3 = { "org.example.Collection1", "exampleos/x86_64/ref3" };
- const OstreeCollectionRef ref4 = { "org.example.UnconfiguredCollection", "exampleos/x86_64/ref4" };
+ const OstreeCollectionRef ref4
+ = { "org.example.UnconfiguredCollection", "exampleos/x86_64/ref4" };
const OstreeCollectionRef ref5 = { "org.example.Collection3", "exampleos/x86_64/ref0" };
- const OstreeCollectionRef * const refs[] = { &ref0, &ref1, &ref2, &ref3, &ref4, &ref5, NULL };
+ const OstreeCollectionRef *const refs[] = { &ref0, &ref1, &ref2, &ref3, &ref4, &ref5, NULL };
context = g_main_context_new ();
g_main_context_push_thread_default (context);
@@ -356,23 +333,18 @@ test_repo_finder_mount_mixed_mounts (Fixture *fixture,
assert_create_repos_dir (fixture, "no-repos-mount", &no_repos_repos, &no_repos_mount);
assert_create_repos_dir (fixture, "repo1-mount", &repo1_repos, &repo1_mount);
- repo1_repo_a = assert_create_repo_dir (fixture, repo1_repos, repo1_mount, "repo1-repo-a", &repo1_repo_a_uri,
- refs[0], &repo1_ref0_checksum,
- refs[2], &repo1_ref2_checksum,
- refs[5], &repo1_ref5_checksum,
- NULL);
- repo1_repo_b = assert_create_repo_dir (fixture, repo1_repos, repo1_mount, "repo1-repo-b", &repo1_repo_b_uri,
- refs[1], &repo1_ref1_checksum,
- NULL);
+ repo1_repo_a = assert_create_repo_dir (fixture, repo1_repos, repo1_mount, "repo1-repo-a",
+ &repo1_repo_a_uri, refs[0], &repo1_ref0_checksum, refs[2],
+ &repo1_ref2_checksum, refs[5], &repo1_ref5_checksum, NULL);
+ repo1_repo_b = assert_create_repo_dir (fixture, repo1_repos, repo1_mount, "repo1-repo-b",
+ &repo1_repo_b_uri, refs[1], &repo1_ref1_checksum, NULL);
assert_create_repo_symlink (repo1_repos, "repo1-repo-a-alias", "repo1-repo-a");
assert_create_repos_dir (fixture, "repo2-mount", &repo2_repos, &repo2_mount);
- repo2_repo_a = assert_create_repo_dir (fixture, repo2_repos, repo2_mount, "repo2-repo-a", &repo2_repo_a_uri,
- refs[0], &repo2_ref0_checksum,
- refs[1], &repo2_ref1_checksum,
- refs[2], &repo2_ref2_checksum,
- refs[3], &repo2_ref3_checksum,
- NULL);
+ repo2_repo_a = assert_create_repo_dir (fixture, repo2_repos, repo2_mount, "repo2-repo-a",
+ &repo2_repo_a_uri, refs[0], &repo2_ref0_checksum, refs[1],
+ &repo2_ref1_checksum, refs[2], &repo2_ref2_checksum,
+ refs[3], &repo2_ref3_checksum, NULL);
assert_create_repo_symlink (repo2_repos, "repo2-repo-a-alias", "repo2-repo-a");
assert_create_repo_symlink (repo2_repos, "dangling-symlink", "repo2-repo-b");
assert_create_repo_symlink (repo2_repos, "root", "/");
@@ -385,21 +357,22 @@ test_repo_finder_mount_mixed_mounts (Fixture *fixture,
monitor = ostree_mock_volume_monitor_new (mounts, NULL);
finder = ostree_repo_finder_mount_new (monitor);
- assert_create_remote_config (fixture->parent_repo, "remote1", "https://nope1", "org.example.Collection1");
- assert_create_remote_config (fixture->parent_repo, "remote2", "https://nope2", "org.example.Collection2");
+ assert_create_remote_config (fixture->parent_repo, "remote1", "https://nope1",
+ "org.example.Collection1");
+ assert_create_remote_config (fixture->parent_repo, "remote2", "https://nope2",
+ "org.example.Collection2");
/* don’t configure org.example.UnconfiguredCollection */
- assert_create_remote_config (fixture->parent_repo, "remote3", "https://nope3", "org.example.Collection3");
+ assert_create_remote_config (fixture->parent_repo, "remote3", "https://nope3",
+ "org.example.Collection3");
/* Resolve the refs. */
- ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs,
- fixture->parent_repo,
- NULL, result_cb, &async_result);
+ ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs, fixture->parent_repo, NULL,
+ result_cb, &async_result);
while (async_result == NULL)
g_main_context_iteration (context, TRUE);
- results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder),
- async_result, &error);
+ results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder), async_result, &error);
g_assert_no_error (error);
g_assert_nonnull (results);
g_assert_cmpuint (results->len, ==, 4);
@@ -416,38 +389,46 @@ test_repo_finder_mount_mixed_mounts (Fixture *fixture,
g_assert_no_error (error);
keyring = result->remote->keyring;
- if (g_strcmp0 (uri, repo1_repo_a_uri) == 0 &&
- g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
+ if (g_strcmp0 (uri, repo1_repo_a_uri) == 0
+ && g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 2);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[0]), ==, repo1_ref0_checksum);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[2]), ==, repo1_ref2_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[0]), ==,
+ repo1_ref0_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[2]), ==,
+ repo1_ref2_checksum);
}
- else if (g_strcmp0 (uri, repo1_repo_a_uri) == 0 &&
- g_strcmp0 (keyring, "remote3.trustedkeys.gpg") == 0)
+ else if (g_strcmp0 (uri, repo1_repo_a_uri) == 0
+ && g_strcmp0 (keyring, "remote3.trustedkeys.gpg") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 1);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[5]), ==, repo1_ref5_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[5]), ==,
+ repo1_ref5_checksum);
}
- else if (g_strcmp0 (uri, repo1_repo_b_uri) == 0 &&
- g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
+ else if (g_strcmp0 (uri, repo1_repo_b_uri) == 0
+ && g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 1);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[1]), ==, repo1_ref1_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[1]), ==,
+ repo1_ref1_checksum);
}
- else if (g_strcmp0 (uri, repo2_repo_a_uri) == 0 &&
- g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
+ else if (g_strcmp0 (uri, repo2_repo_a_uri) == 0
+ && g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 4);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[0]), ==, repo2_ref0_checksum);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[1]), ==, repo2_ref1_checksum);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[2]), ==, repo2_ref2_checksum);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[3]), ==, repo2_ref3_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[0]), ==,
+ repo2_ref0_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[1]), ==,
+ repo2_ref1_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[2]), ==,
+ repo2_ref2_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, refs[3]), ==,
+ repo2_ref3_checksum);
}
else
{
- g_error ("Unknown result ‘%s’ with keyring ‘%s’",
- result->remote->name, result->remote->keyring);
+ g_error ("Unknown result ‘%s’ with keyring ‘%s’", result->remote->name,
+ result->remote->keyring);
}
}
@@ -458,25 +439,24 @@ test_repo_finder_mount_mixed_mounts (Fixture *fixture,
* in the default repository paths ostree/repo and .ostree/repo, to check that
* those paths are read */
static void
-test_repo_finder_mount_well_known (Fixture *fixture,
- gconstpointer test_data)
+test_repo_finder_mount_well_known (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(OstreeRepoFinderMount) finder = NULL;
- g_autoptr(GVolumeMonitor) monitor = NULL;
- g_autoptr(GMainContext) context = NULL;
- g_autoptr(GAsyncResult) async_result = NULL;
- g_autoptr(GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
- g_autoptr(GError) error = NULL;
- g_autoptr(GList) mounts = NULL; /* (element-type OstreeMockMount) */
- g_autoptr(GMount) mount = NULL;
+ g_autoptr (OstreeRepoFinderMount) finder = NULL;
+ g_autoptr (GVolumeMonitor) monitor = NULL;
+ g_autoptr (GMainContext) context = NULL;
+ g_autoptr (GAsyncResult) async_result = NULL;
+ g_autoptr (GPtrArray) results = NULL; /* (element-type OstreeRepoFinderResult) */
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GList) mounts = NULL; /* (element-type OstreeMockMount) */
+ g_autoptr (GMount) mount = NULL;
glnx_autofd int repos = -1;
- g_autoptr(OstreeRepo) repo_a = NULL, repo_b = NULL;
+ g_autoptr (OstreeRepo) repo_a = NULL, repo_b = NULL;
g_autofree gchar *repo_a_uri = NULL, *repo_b_uri = NULL;
g_autofree gchar *ref_a_checksum = NULL, *ref_b_checksum = NULL;
gsize i;
const OstreeCollectionRef ref_a = { "org.example.Collection1", "refA" };
const OstreeCollectionRef ref_b = { "org.example.Collection2", "refB" };
- const OstreeCollectionRef * const refs[] = { &ref_a, &ref_b, NULL };
+ const OstreeCollectionRef *const refs[] = { &ref_a, &ref_b, NULL };
context = g_main_context_new ();
g_main_context_push_thread_default (context);
@@ -486,12 +466,10 @@ test_repo_finder_mount_well_known (Fixture *fixture,
* file system from /tmp, so it’s an example of a symlink pointing outside
* its mount point. */
assert_create_repos_dir (fixture, "mount", &repos, &mount);
- repo_a = assert_create_repo_dir (fixture, repos, mount, "../../ostree/repo", &repo_a_uri,
- &ref_a, &ref_a_checksum,
- NULL);
- repo_b = assert_create_repo_dir (fixture, repos, mount, "../../.ostree/repo", &repo_b_uri,
- &ref_b, &ref_b_checksum,
- NULL);
+ repo_a = assert_create_repo_dir (fixture, repos, mount, "../../ostree/repo", &repo_a_uri, &ref_a,
+ &ref_a_checksum, NULL);
+ repo_b = assert_create_repo_dir (fixture, repos, mount, "../../.ostree/repo", &repo_b_uri, &ref_b,
+ &ref_b_checksum, NULL);
assert_create_repo_symlink (repos, "repo-a-alias", "../../ostree/repo");
mounts = g_list_prepend (mounts, mount);
@@ -499,19 +477,19 @@ test_repo_finder_mount_well_known (Fixture *fixture,
monitor = ostree_mock_volume_monitor_new (mounts, NULL);
finder = ostree_repo_finder_mount_new (monitor);
- assert_create_remote_config (fixture->parent_repo, "remote1", "https://nope1", "org.example.Collection1");
- assert_create_remote_config (fixture->parent_repo, "remote2", "https://nope2", "org.example.Collection2");
+ assert_create_remote_config (fixture->parent_repo, "remote1", "https://nope1",
+ "org.example.Collection1");
+ assert_create_remote_config (fixture->parent_repo, "remote2", "https://nope2",
+ "org.example.Collection2");
/* Resolve the refs. */
- ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs,
- fixture->parent_repo,
- NULL, result_cb, &async_result);
+ ostree_repo_finder_resolve_async (OSTREE_REPO_FINDER (finder), refs, fixture->parent_repo, NULL,
+ result_cb, &async_result);
while (async_result == NULL)
g_main_context_iteration (context, TRUE);
- results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder),
- async_result, &error);
+ results = ostree_repo_finder_resolve_finish (OSTREE_REPO_FINDER (finder), async_result, &error);
g_assert_no_error (error);
g_assert_nonnull (results);
g_assert_cmpuint (results->len, ==, 2);
@@ -528,22 +506,23 @@ test_repo_finder_mount_well_known (Fixture *fixture,
g_assert_no_error (error);
keyring = result->remote->keyring;
- if (g_strcmp0 (uri, repo_a_uri) == 0 &&
- g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
+ if (g_strcmp0 (uri, repo_a_uri) == 0 && g_strcmp0 (keyring, "remote1.trustedkeys.gpg") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 1);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, &ref_a), ==, ref_a_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, &ref_a), ==,
+ ref_a_checksum);
}
- else if (g_strcmp0 (uri, repo_b_uri) == 0 &&
- g_strcmp0 (keyring, "remote2.trustedkeys.gpg") == 0)
+ else if (g_strcmp0 (uri, repo_b_uri) == 0
+ && g_strcmp0 (keyring, "remote2.trustedkeys.gpg") == 0)
{
g_assert_cmpuint (g_hash_table_size (result->ref_to_checksum), ==, 1);
- g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, &ref_b), ==, ref_b_checksum);
+ g_assert_cmpstr (g_hash_table_lookup (result->ref_to_checksum, &ref_b), ==,
+ ref_b_checksum);
}
else
{
- g_test_message ("Unknown result ‘%s’ with keyring ‘%s’.",
- result->remote->name, result->remote->keyring);
+ g_test_message ("Unknown result ‘%s’ with keyring ‘%s’.", result->remote->name,
+ result->remote->keyring);
g_assert_not_reached ();
}
}
@@ -551,7 +530,8 @@ test_repo_finder_mount_well_known (Fixture *fixture,
g_main_context_pop_thread_default (context);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
@@ -560,12 +540,13 @@ int main (int argc, char **argv)
g_test_add ("/repo-finder-mount/no-mounts", Fixture, NULL, setup,
test_repo_finder_mount_no_mounts, teardown);
#ifndef OSTREE_DISABLE_GPGME
- /*`ostree_repo_resolve_keyring_for_collection()` fail the tests if no GPG support is compiled in. */
+ /*`ostree_repo_resolve_keyring_for_collection()` fail the tests if no GPG support is compiled in.
+ */
g_test_add ("/repo-finder-mount/mixed-mounts", Fixture, NULL, setup,
test_repo_finder_mount_mixed_mounts, teardown);
g_test_add ("/repo-finder-mount/well-known", Fixture, NULL, setup,
test_repo_finder_mount_well_known, teardown);
#endif /* OSTREE_DISABLE_GPGME */
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-repo.c b/tests/test-repo.c
index b8365ea9..1bc4cb81 100644
--- a/tests/test-repo.c
+++ b/tests/test-repo.c
@@ -23,8 +23,8 @@
#include "config.h"
#include <gio/gio.h>
-#include <glib.h>
#include <glib-object.h>
+#include <glib.h>
#include <libglnx.h>
#include <locale.h>
@@ -34,16 +34,15 @@
/* Test fixture. Creates a temporary directory. */
typedef struct
{
- GLnxTmpDir tmpdir; /* (owned) */
+ GLnxTmpDir tmpdir; /* (owned) */
} Fixture;
static void
-setup (Fixture *fixture,
- gconstpointer test_data)
+setup (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
- (void) glnx_mkdtemp ("test-repo-XXXXXX", 0700, &fixture->tmpdir, &error);
+ (void)glnx_mkdtemp ("test-repo-XXXXXX", 0700, &fixture->tmpdir, &error);
g_assert_no_error (error);
g_test_message ("Using temporary directory: %s", fixture->tmpdir.path);
@@ -53,49 +52,41 @@ setup (Fixture *fixture,
* set the locking timeout to 0 so lock failures don't block.
*/
static void
-lock_setup (Fixture *fixture,
- gconstpointer test_data)
+lock_setup (Fixture *fixture, gconstpointer test_data)
{
setup (fixture, test_data);
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = ostree_repo_create_at (
+ fixture->tmpdir.fd, ".", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
/* Set the lock timeout to 0 so failures don't block the test */
- g_autoptr(GKeyFile) config = ostree_repo_copy_config (repo);
+ g_autoptr (GKeyFile) config = ostree_repo_copy_config (repo);
g_key_file_set_integer (config, "core", "lock-timeout-secs", 0);
ostree_repo_write_config (repo, config, &error);
g_assert_no_error (error);
}
static void
-teardown (Fixture *fixture,
- gconstpointer test_data)
+teardown (Fixture *fixture, gconstpointer test_data)
{
/* Recursively remove the temporary directory. */
- (void) glnx_tmpdir_delete (&fixture->tmpdir, NULL, NULL);
+ (void)glnx_tmpdir_delete (&fixture->tmpdir, NULL, NULL);
}
/* Test that the hash values for two #OstreeRepo instances pointing at the same
* repository are equal. We can’t test anything else, since hash collisions are
* always a possibility. */
static void
-test_repo_hash (Fixture *fixture,
- gconstpointer test_data)
+test_repo_hash (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo1 = ostree_repo_create_at (fixture->tmpdir.fd, ".",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo1 = ostree_repo_create_at (
+ fixture->tmpdir.fd, ".", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepo) repo2 = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (OstreeRepo) repo2 = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
g_assert_cmpuint (ostree_repo_hash (repo1), ==, ostree_repo_hash (repo2));
@@ -103,13 +94,12 @@ test_repo_hash (Fixture *fixture,
/* Test that trying to hash a closed repo results in an assertion failure. */
static void
-test_repo_hash_closed (Fixture *fixture,
- gconstpointer test_data)
+test_repo_hash_closed (Fixture *fixture, gconstpointer test_data)
{
if (g_test_subprocess ())
{
- g_autoptr(GFile) repo_path = g_file_new_for_path (fixture->tmpdir.path);
- g_autoptr(OstreeRepo) repo = ostree_repo_new (repo_path);
+ g_autoptr (GFile) repo_path = g_file_new_for_path (fixture->tmpdir.path);
+ g_autoptr (OstreeRepo) repo = ostree_repo_new (repo_path);
ostree_repo_hash (repo);
@@ -123,10 +113,9 @@ test_repo_hash_closed (Fixture *fixture,
/* Test that various repositories test equal (or not) with each other. */
static void
-test_repo_equal (Fixture *fixture,
- gconstpointer test_data)
+test_repo_equal (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
/* Create a few separate repos and some #OstreeRepo objects for them. */
glnx_ensure_dir (fixture->tmpdir.fd, "repo1", 0755, &error);
@@ -134,24 +123,20 @@ test_repo_equal (Fixture *fixture,
glnx_ensure_dir (fixture->tmpdir.fd, "repo2", 0755, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepo) repo1 = ostree_repo_create_at (fixture->tmpdir.fd, "repo1",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (OstreeRepo) repo1 = ostree_repo_create_at (
+ fixture->tmpdir.fd, "repo1", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepo) repo1_alias = ostree_repo_open_at (fixture->tmpdir.fd, "repo1",
- NULL, &error);
+ g_autoptr (OstreeRepo) repo1_alias
+ = ostree_repo_open_at (fixture->tmpdir.fd, "repo1", NULL, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepo) repo2 = ostree_repo_create_at (fixture->tmpdir.fd, "repo2",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (OstreeRepo) repo2 = ostree_repo_create_at (
+ fixture->tmpdir.fd, "repo2", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
- g_autoptr(GFile) closed_repo_path = g_file_new_for_path (fixture->tmpdir.path);
- g_autoptr(OstreeRepo) closed_repo = ostree_repo_new (closed_repo_path);
+ g_autoptr (GFile) closed_repo_path = g_file_new_for_path (fixture->tmpdir.path);
+ g_autoptr (OstreeRepo) closed_repo = ostree_repo_new (closed_repo_path);
/* Test various equalities. */
g_assert_true (ostree_repo_equal (repo1, repo1));
@@ -173,30 +158,26 @@ test_repo_equal (Fixture *fixture,
}
static void
-test_repo_get_min_free_space (Fixture *fixture,
- gconstpointer test_data)
+test_repo_get_min_free_space (Fixture *fixture, gconstpointer test_data)
{
g_autoptr (GKeyFile) config = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
guint64 bytes = 0;
typedef struct
- {
- const char *val;
- gboolean should_succeed;
- } min_free_space_value;
+ {
+ const char *val;
+ gboolean should_succeed;
+ } min_free_space_value;
- g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (OstreeRepo) repo = ostree_repo_create_at (
+ fixture->tmpdir.fd, ".", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
- min_free_space_value values_to_test[] = {
- {"500MB", TRUE },
- { "0MB", TRUE },
- { "17179869185GB", FALSE }, /* Overflow parameter: bytes > G_MAXUINT64 */
- { NULL, FALSE }
- };
+ min_free_space_value values_to_test[]
+ = { { "500MB", TRUE },
+ { "0MB", TRUE },
+ { "17179869185GB", FALSE }, /* Overflow parameter: bytes > G_MAXUINT64 */
+ { NULL, FALSE } };
config = ostree_repo_copy_config (repo);
@@ -219,89 +200,94 @@ test_repo_get_min_free_space (Fixture *fixture,
}
static void
-test_write_regfile_api (Fixture *fixture,
- gconstpointer test_data)
+test_write_regfile_api (Fixture *fixture, gconstpointer test_data)
{
g_autoptr (GKeyFile) config = NULL;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (OstreeRepo) repo = ostree_repo_create_at (
+ fixture->tmpdir.fd, ".", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
- g_auto(GVariantBuilder) xattrs_builder;
- g_variant_builder_init (&xattrs_builder, (GVariantType*)"a(ayay)");
- g_variant_builder_add (&xattrs_builder, "(^ay^ay)", "security.selinux", "system_u:object_r:etc_t:s0");
- g_autoptr(GVariant) xattrs = g_variant_ref_sink (g_variant_builder_end (&xattrs_builder));
+ g_auto (GVariantBuilder) xattrs_builder;
+ g_variant_builder_init (&xattrs_builder, (GVariantType *)"a(ayay)");
+ g_variant_builder_add (&xattrs_builder, "(^ay^ay)", "security.selinux",
+ "system_u:object_r:etc_t:s0");
+ g_autoptr (GVariant) xattrs = g_variant_ref_sink (g_variant_builder_end (&xattrs_builder));
// Current contents of /etc/networks in Fedora
static const char contents[] = "default 0.0.0.0\nloopback 127.0.0.0\nlink-local 169.254.0.0\n";
// First with no xattrs
- g_autofree char *checksum = ostree_repo_write_regfile_inline (repo, NULL, 0, 0, S_IFREG | 0644, NULL, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
+ g_autofree char *checksum = ostree_repo_write_regfile_inline (
+ repo, NULL, 0, 0, S_IFREG | 0644, NULL, (const guint8 *)contents, sizeof (contents) - 1, NULL,
+ &error);
g_assert_no_error (error);
- g_assert_cmpstr (checksum, ==, "8aaa9dc13a0c5839fe4a277756798c609c53fac6fa2290314ecfef9041065873");
+ g_assert_cmpstr (checksum, ==,
+ "8aaa9dc13a0c5839fe4a277756798c609c53fac6fa2290314ecfef9041065873");
g_clear_pointer (&checksum, g_free);
// Invalid checksum
- checksum = ostree_repo_write_regfile_inline (repo, "3272139f889f6a7007b3d64adc74be9e2979bf6bbe663d1512e5bd43f4de24a1",
- 0, 0, S_IFREG | 0644, NULL, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
+ checksum = ostree_repo_write_regfile_inline (
+ repo, "3272139f889f6a7007b3d64adc74be9e2979bf6bbe663d1512e5bd43f4de24a1", 0, 0,
+ S_IFREG | 0644, NULL, (const guint8 *)contents, sizeof (contents) - 1, NULL, &error);
g_assert (checksum == NULL);
g_assert (error != NULL);
g_clear_error (&error);
// Now with xattrs
g_clear_pointer (&checksum, g_free);
- checksum = ostree_repo_write_regfile_inline (repo, NULL, 0, 0, S_IFREG | 0644, xattrs, (const guint8*)contents, sizeof (contents)-1, NULL, &error);
+ checksum = ostree_repo_write_regfile_inline (repo, NULL, 0, 0, S_IFREG | 0644, xattrs,
+ (const guint8 *)contents, sizeof (contents) - 1,
+ NULL, &error);
g_assert_no_error (error);
- g_assert_cmpstr (checksum, ==, "4f600d252338f93279c51c964915cb2c26f0d09082164c54890d1a3c78cdeb1e");
+ g_assert_cmpstr (checksum, ==,
+ "4f600d252338f93279c51c964915cb2c26f0d09082164c54890d1a3c78cdeb1e");
g_clear_pointer (&checksum, g_free);
// Test symlinks
g_clear_pointer (&xattrs, g_variant_unref);
- g_variant_builder_init (&xattrs_builder, (GVariantType*)"a(ayay)");
- g_variant_builder_add (&xattrs_builder, "(^ay^ay)", "security.selinux", "system_u:object_r:bin_t:s0");
+ g_variant_builder_init (&xattrs_builder, (GVariantType *)"a(ayay)");
+ g_variant_builder_add (&xattrs_builder, "(^ay^ay)", "security.selinux",
+ "system_u:object_r:bin_t:s0");
xattrs = g_variant_ref_sink (g_variant_builder_end (&xattrs_builder));
g_clear_pointer (&checksum, g_free);
checksum = ostree_repo_write_symlink (repo, NULL, 0, 0, xattrs, "bash", NULL, &error);
g_assert_no_error (error);
- g_assert_cmpstr (checksum, ==, "23a2e97d21d960ac7a4e39a8721b1baff7b213e00e5e5641334f50506012fcff");
+ g_assert_cmpstr (checksum, ==,
+ "23a2e97d21d960ac7a4e39a8721b1baff7b213e00e5e5641334f50506012fcff");
}
/* Just a sanity check of the C autolocking API */
static void
-test_repo_autolock (Fixture *fixture,
- gconstpointer test_data)
+test_repo_autolock (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".",
- OSTREE_REPO_MODE_ARCHIVE,
- NULL,
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = ostree_repo_create_at (
+ fixture->tmpdir.fd, ".", OSTREE_REPO_MODE_ARCHIVE, NULL, NULL, &error);
g_assert_no_error (error);
{
- g_autoptr(OstreeRepoAutoLock) lock = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_EXCLUSIVE, NULL, &error);
+ g_autoptr (OstreeRepoAutoLock) lock
+ = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_EXCLUSIVE, NULL, &error);
g_assert_no_error (error);
}
- g_autoptr(OstreeRepoAutoLock) lock1 = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
+ g_autoptr (OstreeRepoAutoLock) lock1
+ = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepoAutoLock) lock2 = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
+ g_autoptr (OstreeRepoAutoLock) lock2
+ = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
g_assert_no_error (error);
}
/* Locking from single thread with a single OstreeRepo */
static void
-test_repo_lock_single (Fixture *fixture,
- gconstpointer test_data)
+test_repo_lock_single (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
/* Single thread on a single repo can freely recurse in any state */
@@ -321,14 +307,12 @@ test_repo_lock_single (Fixture *fixture,
/* Unlocking without having ever locked */
static void
-test_repo_lock_unlock_never_locked (Fixture *fixture,
- gconstpointer test_data)
+test_repo_lock_unlock_never_locked (Fixture *fixture, gconstpointer test_data)
{
if (g_test_subprocess ())
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
ostree_repo_lock_pop (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
@@ -343,14 +327,12 @@ test_repo_lock_unlock_never_locked (Fixture *fixture,
/* Unlocking after already unlocked */
static void
-test_repo_lock_double_unlock (Fixture *fixture,
- gconstpointer test_data)
+test_repo_lock_double_unlock (Fixture *fixture, gconstpointer test_data)
{
if (g_test_subprocess ())
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
ostree_repo_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
@@ -369,14 +351,12 @@ test_repo_lock_double_unlock (Fixture *fixture,
/* Unlocking the wrong type */
static void
-test_repo_lock_unlock_wrong_type (Fixture *fixture,
- gconstpointer test_data)
+test_repo_lock_unlock_wrong_type (Fixture *fixture, gconstpointer test_data)
{
if (g_test_subprocess ())
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
ostree_repo_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
@@ -388,22 +368,20 @@ test_repo_lock_unlock_wrong_type (Fixture *fixture,
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*ERROR*Repo exclusive lock pop requested, but none have been taken\n");
+ g_test_trap_assert_stderr (
+ "*ERROR*Repo exclusive lock pop requested, but none have been taken\n");
}
/* Locking with single thread and multiple OstreeRepos */
static void
-test_repo_lock_multi_repo (Fixture *fixture,
- gconstpointer test_data)
+test_repo_lock_multi_repo (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
/* Open two OstreeRepo instances */
- g_autoptr(OstreeRepo) repo1 = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (OstreeRepo) repo1 = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepo) repo2 = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (OstreeRepo) repo2 = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
/* Single thread with multiple OstreeRepo's conflict */
@@ -437,7 +415,8 @@ test_repo_lock_multi_repo (Fixture *fixture,
}
/* Locking from multiple threads with a single OstreeRepo */
-typedef struct {
+typedef struct
+{
OstreeRepo *repo;
guint step;
} LockThreadData;
@@ -446,7 +425,7 @@ static gpointer
lock_thread1 (gpointer thread_data)
{
LockThreadData *data = thread_data;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
/* Step 0: Take an exclusive lock */
g_assert_cmpuint (data->step, ==, 0);
@@ -481,7 +460,7 @@ static gpointer
lock_thread2 (gpointer thread_data)
{
LockThreadData *data = thread_data;
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
/* Step 1: Wait for the other thread to acquire a lock and then take a
* shared lock.
@@ -505,18 +484,15 @@ lock_thread2 (gpointer thread_data)
}
static void
-test_repo_lock_multi_thread (Fixture *fixture,
- gconstpointer test_data)
+test_repo_lock_multi_thread (Fixture *fixture, gconstpointer test_data)
{
- g_autoptr(GError) error = NULL;
- g_autoptr(OstreeRepo) repo1 = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (GError) error = NULL;
+ g_autoptr (OstreeRepo) repo1 = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
- g_autoptr(OstreeRepo) repo2 = ostree_repo_open_at (fixture->tmpdir.fd, ".",
- NULL, &error);
+ g_autoptr (OstreeRepo) repo2 = ostree_repo_open_at (fixture->tmpdir.fd, ".", NULL, &error);
g_assert_no_error (error);
- LockThreadData thread_data = {repo1, 0};
+ LockThreadData thread_data = { repo1, 0 };
GThread *thread1 = g_thread_new ("lock-thread-1", lock_thread1, &thread_data);
GThread *thread2 = g_thread_new ("lock-thread-2", lock_thread2, &thread_data);
@@ -566,36 +542,29 @@ test_repo_lock_multi_thread (Fixture *fixture,
}
int
-main (int argc,
- char **argv)
+main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
- g_test_add ("/repo/hash", Fixture, NULL, setup,
- test_repo_hash, teardown);
- g_test_add ("/repo/hash/closed", Fixture, NULL, setup,
- test_repo_hash_closed, teardown);
- g_test_add ("/repo/equal", Fixture, NULL, setup,
- test_repo_equal, teardown);
- g_test_add ("/repo/get_min_free_space", Fixture, NULL, setup,
- test_repo_get_min_free_space, teardown);
- g_test_add ("/repo/write_regfile_api", Fixture, NULL, setup,
- test_write_regfile_api, teardown);
- g_test_add ("/repo/autolock", Fixture, NULL, setup,
- test_repo_autolock, teardown);
- g_test_add ("/repo/lock/single", Fixture, NULL, lock_setup,
- test_repo_lock_single, teardown);
+ g_test_add ("/repo/hash", Fixture, NULL, setup, test_repo_hash, teardown);
+ g_test_add ("/repo/hash/closed", Fixture, NULL, setup, test_repo_hash_closed, teardown);
+ g_test_add ("/repo/equal", Fixture, NULL, setup, test_repo_equal, teardown);
+ g_test_add ("/repo/get_min_free_space", Fixture, NULL, setup, test_repo_get_min_free_space,
+ teardown);
+ g_test_add ("/repo/write_regfile_api", Fixture, NULL, setup, test_write_regfile_api, teardown);
+ g_test_add ("/repo/autolock", Fixture, NULL, setup, test_repo_autolock, teardown);
+ g_test_add ("/repo/lock/single", Fixture, NULL, lock_setup, test_repo_lock_single, teardown);
g_test_add ("/repo/lock/unlock-never-locked", Fixture, NULL, lock_setup,
test_repo_lock_unlock_never_locked, teardown);
- g_test_add ("/repo/lock/double-unlock", Fixture, NULL, lock_setup,
- test_repo_lock_double_unlock, teardown);
+ g_test_add ("/repo/lock/double-unlock", Fixture, NULL, lock_setup, test_repo_lock_double_unlock,
+ teardown);
g_test_add ("/repo/lock/unlock-wrong-type", Fixture, NULL, lock_setup,
test_repo_lock_unlock_wrong_type, teardown);
- g_test_add ("/repo/lock/multi-repo", Fixture, NULL, lock_setup,
- test_repo_lock_multi_repo, teardown);
- g_test_add ("/repo/lock/multi-thread", Fixture, NULL, lock_setup,
- test_repo_lock_multi_thread, teardown);
+ g_test_add ("/repo/lock/multi-repo", Fixture, NULL, lock_setup, test_repo_lock_multi_repo,
+ teardown);
+ g_test_add ("/repo/lock/multi-thread", Fixture, NULL, lock_setup, test_repo_lock_multi_thread,
+ teardown);
return g_test_run ();
}
diff --git a/tests/test-rfc2616-dates.c b/tests/test-rfc2616-dates.c
index 55807f16..a47bca81 100644
--- a/tests/test-rfc2616-dates.c
+++ b/tests/test-rfc2616-dates.c
@@ -30,58 +30,57 @@ static void
test_ostree_parse_rfc2616_date_time (void)
{
#if GLIB_CHECK_VERSION(2, 62, 0)
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
const struct
- {
- const char *rfc2616;
- const char *expected_iso8601; /* (nullable) if parsing is expected to fail */
- }
- tests[] =
- {
- { "Wed, 21 Oct 2015 07:28:00 GMT", "2015-10-21T07:28:00Z" },
- { "Wed, 21 Oct 2015 07:28:00", NULL }, /* too short */
- { "Wed, 21 Oct 2015 07:28:00 CEST", NULL }, /* too long; not GMT */
- { "Cat, 21 Oct 2015 07:28:00 GMT", NULL }, /* invalid day */
- { "Wed 21 Oct 2015 07:28:00 GMT", NULL }, /* no comma */
- { "Wed,21 Oct 2015 07:28:00 GMT ", NULL }, /* missing space */
- { "Wed, xx Oct 2015 07:28:00 GMT", NULL }, /* no day-of-month */
- { "Wed, 011Oct 2015 07:28:00 GMT", NULL }, /* overlong day-of-month */
- { "Wed, 00 Oct 2015 07:28:00 GMT", NULL }, /* day-of-month underflow */
- { "Wed, 32 Oct 2015 07:28:00 GMT", NULL }, /* day-of-month overflow */
- { "Wed, 21,Oct 2015 07:28:00 GMT", NULL }, /* missing space */
- { "Wed, 21 Cat 2015 07:28:00 GMT", NULL }, /* invalid month */
- { "Wed, 21 Oct,2015 07:28:00 GMT", NULL }, /* missing space */
- { "Wed, 21 Oct xxxx 07:28:00 GMT", NULL }, /* no year */
- { "Wed, 21 Oct 0201507:28:00 GMT", NULL }, /* overlong year */
- { "Wed, 21 Oct 0000 07:28:00 GMT", NULL }, /* year underflow */
- { "Wed, 21 Oct 10000 07:28:00 GM", NULL }, /* year overflow */
- { "Wed, 21 Oct 2015,07:28:00 GMT", NULL }, /* missing space */
- { "Wed, 21 Oct 2015 07 28:00 GMT", NULL }, /* missing colon */
- { "Wed, 21 Oct 2015 007:28:00 GM", NULL }, /* overlong hour */
- { "Wed, 21 Oct 2015 xx:28:00 GMT", NULL }, /* missing hour */
- { "Wed, 21 Oct 2015 -1:28:00 GMT", NULL }, /* hour underflow */
- { "Wed, 21 Oct 2015 24:28:00 GMT", NULL }, /* hour overflow */
- { "Wed, 21 Oct 2015 07:28 00 GMT", NULL }, /* missing colon */
- { "Wed, 21 Oct 2015 07:028:00 GM", NULL }, /* overlong minute */
- { "Wed, 21 Oct 2015 07:xx:00 GMT", NULL }, /* missing minute */
- { "Wed, 21 Oct 2015 07:-1:00 GMT", NULL }, /* minute underflow */
- { "Wed, 21 Oct 2015 07:60:00 GMT", NULL }, /* minute overflow */
- { "Wed, 21 Oct 2015 07:28:00CEST", NULL }, /* missing space */
- { "Wed, 21 Oct 2015 07:28:000 GM", NULL }, /* overlong second */
- { "Wed, 21 Oct 2015 07:28:xx GMT", NULL }, /* missing second */
- { "Wed, 21 Oct 2015 07:28:-1 GMT", NULL }, /* seconds underflow */
- { "Wed, 21 Oct 2015 07:28:61 GMT", NULL }, /* seconds overflow */
- { "Wed, 21 Oct 2015 07:28:00 UTC", NULL }, /* invalid timezone (only GMT is allowed) */
- { "Thu, 01 Jan 1970 00:00:00 GMT", "1970-01-01T00:00:00Z" }, /* extreme but valid date */
- { "Mon, 31 Dec 9999 23:59:59 GMT", "9999-12-31T23:59:59Z" }, /* extreme but valid date */
- };
+ {
+ const char *rfc2616;
+ const char *expected_iso8601; /* (nullable) if parsing is expected to fail */
+ } tests[] = {
+ { "Wed, 21 Oct 2015 07:28:00 GMT", "2015-10-21T07:28:00Z" },
+ { "Wed, 21 Oct 2015 07:28:00", NULL }, /* too short */
+ { "Wed, 21 Oct 2015 07:28:00 CEST", NULL }, /* too long; not GMT */
+ { "Cat, 21 Oct 2015 07:28:00 GMT", NULL }, /* invalid day */
+ { "Wed 21 Oct 2015 07:28:00 GMT", NULL }, /* no comma */
+ { "Wed,21 Oct 2015 07:28:00 GMT ", NULL }, /* missing space */
+ { "Wed, xx Oct 2015 07:28:00 GMT", NULL }, /* no day-of-month */
+ { "Wed, 011Oct 2015 07:28:00 GMT", NULL }, /* overlong day-of-month */
+ { "Wed, 00 Oct 2015 07:28:00 GMT", NULL }, /* day-of-month underflow */
+ { "Wed, 32 Oct 2015 07:28:00 GMT", NULL }, /* day-of-month overflow */
+ { "Wed, 21,Oct 2015 07:28:00 GMT", NULL }, /* missing space */
+ { "Wed, 21 Cat 2015 07:28:00 GMT", NULL }, /* invalid month */
+ { "Wed, 21 Oct,2015 07:28:00 GMT", NULL }, /* missing space */
+ { "Wed, 21 Oct xxxx 07:28:00 GMT", NULL }, /* no year */
+ { "Wed, 21 Oct 0201507:28:00 GMT", NULL }, /* overlong year */
+ { "Wed, 21 Oct 0000 07:28:00 GMT", NULL }, /* year underflow */
+ { "Wed, 21 Oct 10000 07:28:00 GM", NULL }, /* year overflow */
+ { "Wed, 21 Oct 2015,07:28:00 GMT", NULL }, /* missing space */
+ { "Wed, 21 Oct 2015 07 28:00 GMT", NULL }, /* missing colon */
+ { "Wed, 21 Oct 2015 007:28:00 GM", NULL }, /* overlong hour */
+ { "Wed, 21 Oct 2015 xx:28:00 GMT", NULL }, /* missing hour */
+ { "Wed, 21 Oct 2015 -1:28:00 GMT", NULL }, /* hour underflow */
+ { "Wed, 21 Oct 2015 24:28:00 GMT", NULL }, /* hour overflow */
+ { "Wed, 21 Oct 2015 07:28 00 GMT", NULL }, /* missing colon */
+ { "Wed, 21 Oct 2015 07:028:00 GM", NULL }, /* overlong minute */
+ { "Wed, 21 Oct 2015 07:xx:00 GMT", NULL }, /* missing minute */
+ { "Wed, 21 Oct 2015 07:-1:00 GMT", NULL }, /* minute underflow */
+ { "Wed, 21 Oct 2015 07:60:00 GMT", NULL }, /* minute overflow */
+ { "Wed, 21 Oct 2015 07:28:00CEST", NULL }, /* missing space */
+ { "Wed, 21 Oct 2015 07:28:000 GM", NULL }, /* overlong second */
+ { "Wed, 21 Oct 2015 07:28:xx GMT", NULL }, /* missing second */
+ { "Wed, 21 Oct 2015 07:28:-1 GMT", NULL }, /* seconds underflow */
+ { "Wed, 21 Oct 2015 07:28:61 GMT", NULL }, /* seconds overflow */
+ { "Wed, 21 Oct 2015 07:28:00 UTC", NULL }, /* invalid timezone (only GMT is allowed) */
+ { "Thu, 01 Jan 1970 00:00:00 GMT", "1970-01-01T00:00:00Z" }, /* extreme but valid date */
+ { "Mon, 31 Dec 9999 23:59:59 GMT", "9999-12-31T23:59:59Z" }, /* extreme but valid date */
+ };
for (gsize i = 0; i < G_N_ELEMENTS (tests); i++)
{
g_test_message ("Test %" G_GSIZE_FORMAT ": %s", i, tests[i].rfc2616);
/* Parse once with a trailing nul */
- g_autoptr(GDateTime) dt1 = _ostree_parse_rfc2616_date_time (tests[i].rfc2616, strlen (tests[i].rfc2616));
+ g_autoptr (GDateTime) dt1
+ = _ostree_parse_rfc2616_date_time (tests[i].rfc2616, strlen (tests[i].rfc2616));
if (tests[i].expected_iso8601 == NULL)
g_assert_null (dt1);
else
@@ -94,7 +93,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* And parse again with no trailing nul */
g_autofree char *rfc2616_no_nul = g_malloc (strlen (tests[i].rfc2616));
memcpy (rfc2616_no_nul, tests[i].rfc2616, strlen (tests[i].rfc2616));
- g_autoptr(GDateTime) dt2 = _ostree_parse_rfc2616_date_time (rfc2616_no_nul, strlen (tests[i].rfc2616));
+ g_autoptr (GDateTime) dt2
+ = _ostree_parse_rfc2616_date_time (rfc2616_no_nul, strlen (tests[i].rfc2616));
if (tests[i].expected_iso8601 == NULL)
g_assert_null (dt2);
else
@@ -104,7 +104,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_assert_cmpstr (iso8601, ==, tests[i].expected_iso8601);
}
}
-G_GNUC_END_IGNORE_DEPRECATIONS
+ G_GNUC_END_IGNORE_DEPRECATIONS
#else
/* GLib 2.62 is needed for g_date_time_format_iso8601(). */
g_test_skip ("RFC 2616 date parsing test needs GLib ≥ 2.62.0");
@@ -112,8 +112,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
int
-main (int argc,
- char **argv)
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/ostree_parse_rfc2616_date_time", test_ostree_parse_rfc2616_date_time);
diff --git a/tests/test-rollsum-cli.c b/tests/test-rollsum-cli.c
index 2cf730d3..f906e991 100644
--- a/tests/test-rollsum-cli.c
+++ b/tests/test-rollsum-cli.c
@@ -26,7 +26,7 @@
int
main (int argc, char **argv)
{
- g_autoptr(GError) local_error = NULL;
+ g_autoptr (GError) local_error = NULL;
GError **error = &local_error;
GBytes *from_bytes = NULL;
GBytes *to_bytes = NULL;
@@ -57,12 +57,10 @@ main (int argc, char **argv)
matches = _ostree_compute_rollsum_matches (from_bytes, to_bytes);
- g_printerr ("rollsum crcs=%u bufs=%u total=%u matchsize=%llu\n",
- matches->crcmatches,
- matches->bufmatches,
- matches->total, (unsigned long long)matches->match_size);
+ g_printerr ("rollsum crcs=%u bufs=%u total=%u matchsize=%llu\n", matches->crcmatches,
+ matches->bufmatches, matches->total, (unsigned long long)matches->match_size);
- out:
+out:
if (local_error)
{
g_printerr ("%s\n", local_error->message);
diff --git a/tests/test-rollsum.c b/tests/test-rollsum.c
index 57f7aa06..a454e626 100644
--- a/tests/test-rollsum.c
+++ b/tests/test-rollsum.c
@@ -19,22 +19,23 @@
#include "config.h"
-#include "libglnx.h"
#include "bsdiff/bsdiff.h"
#include "bsdiff/bspatch.h"
+#include "bupsplit.h"
+#include "libglnx.h"
+#include "ostree-rollsum.h"
+#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
-#include <gio/gio.h>
#include <string.h>
-#include "ostree-rollsum.h"
-#include "bupsplit.h"
static void
-test_rollsum_helper (const unsigned char *a, gsize size_a, const unsigned char *b, gsize size_b, gboolean expected_match)
+test_rollsum_helper (const unsigned char *a, gsize size_a, const unsigned char *b, gsize size_b,
+ gboolean expected_match)
{
gsize i;
- g_autoptr(GBytes) bytes_a = g_bytes_new_static (a, size_a);
- g_autoptr(GBytes) bytes_b = g_bytes_new_static (b, size_b);
+ g_autoptr (GBytes) bytes_a = g_bytes_new_static (a, size_a);
+ g_autoptr (GBytes) bytes_b = g_bytes_new_static (b, size_b);
OstreeRollsumMatches *matches;
GPtrArray *matchlist;
guint64 sum_matched = 0;
@@ -75,16 +76,34 @@ test_rollsum (void)
int len;
g_autofree unsigned char *a = g_malloc (MAX_BUFFER_SIZE);
g_autofree unsigned char *b = g_malloc (MAX_BUFFER_SIZE);
- g_autoptr(GRand) rand = g_rand_new ();
+ g_autoptr (GRand) rand = g_rand_new ();
/* These two buffers produce the same crc32. */
- const unsigned char conflicting_a[] = {0x35, 0x9b, 0x94, 0x5a, 0xa0, 0x5a, 0x34, 0xdc, 0x5c, 0x3, 0x46, 0xe, 0x34, 0x53, 0x85, 0x73, 0x64, 0xcc, 0x47, 0x10, 0x23, 0x8e, 0x7e, 0x6a, 0xca, 0xda, 0x7c, 0x12, 0x8a, 0x59, 0x7f, 0x7f, 0x4d, 0x1, 0xd8, 0xcc, 0x81, 0xcf, 0x2c, 0x7f, 0x10, 0xc2, 0xb4, 0x40, 0x1f, 0x2a, 0x0, 0x37, 0x85, 0xde, 0xfe, 0xa5, 0xc, 0x7c, 0xa1, 0x8, 0xd6, 0x75, 0xfd, 0x2, 0xcf, 0x2d, 0x53, 0x1b, 0x8a, 0x6b, 0x35, 0xad, 0xa, 0x8f, 0xad, 0x2d, 0x91, 0x87, 0x2b, 0x97, 0xcf, 0x1d, 0x7c, 0x61, 0xc4, 0xb2, 0x5e, 0xc3, 0xba, 0x5d, 0x2f, 0x3a, 0xeb, 0x41, 0x61, 0x4c, 0xa2, 0x34, 0xd, 0x43, 0xce, 0x10, 0xa3, 0x47, 0x4, 0xa0, 0x39, 0x77, 0xc2, 0xe8, 0x36, 0x1d, 0x87, 0xd1, 0x8f, 0x4d, 0x13, 0xa1, 0x34, 0xc3, 0x2c, 0xee, 0x1a, 0x10, 0x79, 0xb7, 0x97, 0x29, 0xe8, 0xf0, 0x5, 0xfc, 0xe6, 0x14, 0x87, 0x9c, 0x8f, 0x97, 0x23, 0xac, 0x1, 0xf2, 0xee, 0x69, 0xb2, 0xe5};
-
- const unsigned char conflicting_b[] = {0xb2, 0x54, 0x81, 0x7d, 0x31, 0x83, 0xc7, 0xc, 0xcf, 0x7d, 0x90, 0x1c, 0x6b, 0xf6, 0x4e, 0xff, 0x49, 0xd1, 0xb6, 0xc, 0x9e, 0x85, 0xe3, 0x2d, 0xdb, 0x94, 0x8e, 0x1a, 0x17, 0x3f, 0x63, 0x59, 0xf9, 0x4b, 0x5f, 0x47, 0x97, 0x9c, 0x1c, 0xd7, 0x24, 0xd9, 0x42, 0x6, 0x1e, 0xf, 0x98, 0x10, 0xb4, 0xc, 0x50, 0xcb, 0xc5, 0x62, 0x53, 0x1, 0xd1, 0x5f, 0x16, 0x97, 0xaa, 0xd7, 0x57, 0x5e, 0xf2, 0xde, 0xae, 0x53, 0x58, 0x6, 0xb7, 0x9b, 0x8d, 0x2b, 0xd6, 0xb4, 0x55, 0x29, 0x3b, 0x27, 0x70, 0xd5, 0xf3, 0x8d, 0xdc, 0xad, 0x68, 0x63, 0xa5, 0x72, 0xce, 0x6b, 0x9, 0x2b, 0x60, 0x1b, 0x99, 0xd7, 0x86};
+ const unsigned char conflicting_a[]
+ = { 0x35, 0x9b, 0x94, 0x5a, 0xa0, 0x5a, 0x34, 0xdc, 0x5c, 0x3, 0x46, 0xe, 0x34, 0x53, 0x85,
+ 0x73, 0x64, 0xcc, 0x47, 0x10, 0x23, 0x8e, 0x7e, 0x6a, 0xca, 0xda, 0x7c, 0x12, 0x8a, 0x59,
+ 0x7f, 0x7f, 0x4d, 0x1, 0xd8, 0xcc, 0x81, 0xcf, 0x2c, 0x7f, 0x10, 0xc2, 0xb4, 0x40, 0x1f,
+ 0x2a, 0x0, 0x37, 0x85, 0xde, 0xfe, 0xa5, 0xc, 0x7c, 0xa1, 0x8, 0xd6, 0x75, 0xfd, 0x2,
+ 0xcf, 0x2d, 0x53, 0x1b, 0x8a, 0x6b, 0x35, 0xad, 0xa, 0x8f, 0xad, 0x2d, 0x91, 0x87, 0x2b,
+ 0x97, 0xcf, 0x1d, 0x7c, 0x61, 0xc4, 0xb2, 0x5e, 0xc3, 0xba, 0x5d, 0x2f, 0x3a, 0xeb, 0x41,
+ 0x61, 0x4c, 0xa2, 0x34, 0xd, 0x43, 0xce, 0x10, 0xa3, 0x47, 0x4, 0xa0, 0x39, 0x77, 0xc2,
+ 0xe8, 0x36, 0x1d, 0x87, 0xd1, 0x8f, 0x4d, 0x13, 0xa1, 0x34, 0xc3, 0x2c, 0xee, 0x1a, 0x10,
+ 0x79, 0xb7, 0x97, 0x29, 0xe8, 0xf0, 0x5, 0xfc, 0xe6, 0x14, 0x87, 0x9c, 0x8f, 0x97, 0x23,
+ 0xac, 0x1, 0xf2, 0xee, 0x69, 0xb2, 0xe5 };
+
+ const unsigned char conflicting_b[]
+ = { 0xb2, 0x54, 0x81, 0x7d, 0x31, 0x83, 0xc7, 0xc, 0xcf, 0x7d, 0x90, 0x1c, 0x6b, 0xf6, 0x4e,
+ 0xff, 0x49, 0xd1, 0xb6, 0xc, 0x9e, 0x85, 0xe3, 0x2d, 0xdb, 0x94, 0x8e, 0x1a, 0x17, 0x3f,
+ 0x63, 0x59, 0xf9, 0x4b, 0x5f, 0x47, 0x97, 0x9c, 0x1c, 0xd7, 0x24, 0xd9, 0x42, 0x6, 0x1e,
+ 0xf, 0x98, 0x10, 0xb4, 0xc, 0x50, 0xcb, 0xc5, 0x62, 0x53, 0x1, 0xd1, 0x5f, 0x16, 0x97,
+ 0xaa, 0xd7, 0x57, 0x5e, 0xf2, 0xde, 0xae, 0x53, 0x58, 0x6, 0xb7, 0x9b, 0x8d, 0x2b, 0xd6,
+ 0xb4, 0x55, 0x29, 0x3b, 0x27, 0x70, 0xd5, 0xf3, 0x8d, 0xdc, 0xad, 0x68, 0x63, 0xa5, 0x72,
+ 0xce, 0x6b, 0x9, 0x2b, 0x60, 0x1b, 0x99, 0xd7, 0x86 };
+
+ test_rollsum_helper (conflicting_a, sizeof conflicting_a, conflicting_b, sizeof conflicting_b,
+ FALSE);
- test_rollsum_helper (conflicting_a, sizeof conflicting_a, conflicting_b, sizeof conflicting_b, FALSE);
-
- for (i = 0; i < MAX_BUFFER_SIZE; i++)
+ for (i = 0; i < MAX_BUFFER_SIZE; i++)
{
a[i] = g_rand_int (rand);
b[i] = a[i];
@@ -139,32 +158,33 @@ test_rollsum (void)
#define BUP_SELFTEST_SIZE 100000
static void
-test_bupsplit_sum(void)
+test_bupsplit_sum (void)
{
- g_autofree uint8_t *buf = g_malloc (BUP_SELFTEST_SIZE);
- uint32_t sum1a, sum1b, sum2a, sum2b, sum3a, sum3b;
- unsigned count;
-
- for (count = 0; count < BUP_SELFTEST_SIZE; count++)
- buf[count] = g_random_int_range (0, 256);
-
- sum1a = bupsplit_sum(buf, 0, BUP_SELFTEST_SIZE);
- sum1b = bupsplit_sum(buf, 1, BUP_SELFTEST_SIZE);
- sum2a = bupsplit_sum(buf, BUP_SELFTEST_SIZE - BUP_WINDOWSIZE*5/2,
- BUP_SELFTEST_SIZE - BUP_WINDOWSIZE);
- sum2b = bupsplit_sum(buf, 0, BUP_SELFTEST_SIZE - BUP_WINDOWSIZE);
- sum3a = bupsplit_sum(buf, 0, BUP_WINDOWSIZE+3);
- sum3b = bupsplit_sum(buf, 3, BUP_WINDOWSIZE+3);
-
- g_assert_cmpint (sum1a, ==, sum1b);
- g_assert_cmpint (sum2a, ==, sum2b);
- g_assert_cmpint (sum3a, ==, sum3b);
+ g_autofree uint8_t *buf = g_malloc (BUP_SELFTEST_SIZE);
+ uint32_t sum1a, sum1b, sum2a, sum2b, sum3a, sum3b;
+ unsigned count;
+
+ for (count = 0; count < BUP_SELFTEST_SIZE; count++)
+ buf[count] = g_random_int_range (0, 256);
+
+ sum1a = bupsplit_sum (buf, 0, BUP_SELFTEST_SIZE);
+ sum1b = bupsplit_sum (buf, 1, BUP_SELFTEST_SIZE);
+ sum2a = bupsplit_sum (buf, BUP_SELFTEST_SIZE - BUP_WINDOWSIZE * 5 / 2,
+ BUP_SELFTEST_SIZE - BUP_WINDOWSIZE);
+ sum2b = bupsplit_sum (buf, 0, BUP_SELFTEST_SIZE - BUP_WINDOWSIZE);
+ sum3a = bupsplit_sum (buf, 0, BUP_WINDOWSIZE + 3);
+ sum3b = bupsplit_sum (buf, 3, BUP_WINDOWSIZE + 3);
+
+ g_assert_cmpint (sum1a, ==, sum1b);
+ g_assert_cmpint (sum2a, ==, sum2b);
+ g_assert_cmpint (sum3a, ==, sum3b);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/rollsum", test_rollsum);
g_test_add_func ("/bupsum", test_bupsplit_sum);
- return g_test_run();
+ return g_test_run ();
}
diff --git a/tests/test-sysroot-c.c b/tests/test-sysroot-c.c
index 82b4b1bf..34e86162 100644
--- a/tests/test-sysroot-c.c
+++ b/tests/test-sysroot-c.c
@@ -19,8 +19,8 @@
#include "config.h"
-#include <stdlib.h>
#include <gio/gio.h>
+#include <stdlib.h>
#include <string.h>
#include "libglnx.h"
@@ -40,8 +40,8 @@ run_sync (const char *cmdline, GError **error)
static void
test_sysroot_reload (gconstpointer data)
{
- OstreeSysroot *sysroot = (void*)data;
- g_autoptr(GError) error = NULL;
+ OstreeSysroot *sysroot = (void *)data;
+ g_autoptr (GError) error = NULL;
gboolean changed;
if (!ostree_sysroot_load (sysroot, NULL, &error))
@@ -51,10 +51,14 @@ test_sysroot_reload (gconstpointer data)
goto out;
g_assert (!changed);
- if (!run_sync ("ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmain/x86_64-runtime", &error))
+ if (!run_sync ("ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo "
+ "testos/buildmain/x86_64-runtime",
+ &error))
goto out;
- if (!run_sync ("ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmain/x86_64-runtime", &error))
+ if (!run_sync ("ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet "
+ "--os=testos testos:testos/buildmain/x86_64-runtime",
+ &error))
goto out;
if (!ostree_sysroot_load_if_changed (sysroot, &changed, NULL, &error))
@@ -65,14 +69,15 @@ test_sysroot_reload (gconstpointer data)
goto out;
g_assert (!changed);
- out:
+out:
if (error)
g_error ("%s", error->message);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- g_autoptr(GError) error = NULL;
+ g_autoptr (GError) error = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;
g_test_init (&argc, &argv, NULL);
@@ -83,8 +88,8 @@ int main (int argc, char **argv)
g_test_add_data_func ("/sysroot-reload", sysroot, test_sysroot_reload);
- return g_test_run();
- out:
+ return g_test_run ();
+out:
if (error)
g_error ("%s", error->message);
return 1;
diff --git a/tests/test-varint.c b/tests/test-varint.c
index 3fea805e..9c42f64e 100644
--- a/tests/test-varint.c
+++ b/tests/test-varint.c
@@ -24,20 +24,21 @@
#include "ostree-varint.h"
static void
-check_one_roundtrip (guint64 val)
+check_one_roundtrip (guint64 val)
{
- g_autoptr(GString) buf = g_string_new (NULL);
+ g_autoptr (GString) buf = g_string_new (NULL);
guint64 newval;
gsize bytes_read;
_ostree_write_varuint64 (buf, val);
if (g_test_verbose ())
{
- g_autoptr(GVariant) v = g_variant_new_from_data (G_VARIANT_TYPE ("ay"), buf->str, buf->len, TRUE, NULL, NULL);
+ g_autoptr (GVariant) v
+ = g_variant_new_from_data (G_VARIANT_TYPE ("ay"), buf->str, buf->len, TRUE, NULL, NULL);
g_autofree char *data = g_variant_print (v, FALSE);
g_test_message ("%" G_GUINT64_FORMAT " -> %s", val, data);
}
- g_assert (_ostree_read_varuint64 ((guint8*)buf->str, buf->len, &newval, &bytes_read));
+ g_assert (_ostree_read_varuint64 ((guint8 *)buf->str, buf->len, &newval, &bytes_read));
g_assert_cmpint (bytes_read, <=, 10);
g_assert_cmpint (val, ==, newval);
}
@@ -45,9 +46,17 @@ check_one_roundtrip (guint64 val)
static void
test_roundtrips (void)
{
- const guint64 test_inputs[] = { 0, 1, 0x6F, 0xA0, 0xFF, 0xF0F0, 0xCAFE,
- 0xCAFEBABE, G_MAXUINT64, G_MAXUINT64-1,
- G_MAXUINT64 / 2};
+ const guint64 test_inputs[] = { 0,
+ 1,
+ 0x6F,
+ 0xA0,
+ 0xFF,
+ 0xF0F0,
+ 0xCAFE,
+ 0xCAFEBABE,
+ G_MAXUINT64,
+ G_MAXUINT64 - 1,
+ G_MAXUINT64 / 2 };
guint i;
for (i = 0; i < G_N_ELEMENTS (test_inputs); i++)