New upstream version 2016.15

This commit is contained in:
Simon McVittie committed 2016-12-13 13:00:20 +00:00
commit 0ee312bf3e
141 files changed
+1045 -940

No files matched your search

+4 -1
View File
@@ -86,13 +86,16 @@ if test -n "${OT_TESTS_DEBUG:-}"; then
set -x
fi
# This is substituted by the build for installed tests
BUILT_WITH_ASAN=""
if test -n "${OT_TESTS_VALGRIND:-}"; then
CMD_PREFIX="env G_SLICE=always-malloc OSTREE_SUPPRESS_SYNCFS=1 valgrind -q --error-exitcode=1 --leak-check=full --num-callers=30 --suppressions=${test_srcdir}/glib.supp --suppressions=${test_srcdir}/ostree.supp"
else
# In some cases the LD_PRELOAD may cause obscure problems,
# e.g. right now it breaks for me with -fsanitize=address, so
# let's allow users to skip it.
if test -z "${OT_SKIP_READDIR_RAND:-}"; then
if test -z "${OT_SKIP_READDIR_RAND:-}" && test -z "${BUILT_WITH_ASAN:-}"; then
CMD_PREFIX="env LD_PRELOAD=${test_builddir}/libreaddir-rand.so"
else
CMD_PREFIX=""
+10 -1
View File
@@ -35,7 +35,7 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
echo "1..13"
echo "1..14"
# Try both syntaxes
repo_init
@@ -249,3 +249,12 @@ assert_file_has_content baz/cow "further modified file for static deltas"
assert_not_has_file baz/saucer
echo "ok static delta 2"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false --set=unconfigured-state="Access to ExampleOS requires ONE BILLION DOLLARS." origin-subscription file://$(pwd)/ostree-srv/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull origin-subscription main 2>err.txt; then
assert_not_reached "pull unexpectedly succeeded?"
fi
assert_file_has_content err.txt "ONE BILLION DOLLARS"
echo "ok unconfigured"
-1
View File
@@ -73,7 +73,6 @@ test_raw_file_to_archive_z2_stream (gconstpointer data)
&commit_checksum,
&error);
g_assert_no_error (error);
reachable = ostree_repo_traverse_new_reachable ();
ostree_repo_traverse_commit (repo,
commit_checksum,
-1,
+3 -1
View File
@@ -89,7 +89,9 @@ test_bsdiff (void)
g_output_stream_close (out, NULL, NULL);
/* Now generate NEW_GENERATED from OLD and OUT. */
in = g_memory_input_stream_new_from_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;
bspatch_stream.opaque = in;
+11 -31
View File
@@ -31,37 +31,9 @@ static GKeyFile *g_keyfile;
static void
test_get_boolean_with_default (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean out = FALSE;
GLogLevelFlags always_fatal_mask;
/* 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_boolean_with_default (NULL,
"section",
"a_boolean_true",
FALSE,
&out,
&error));
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
NULL,
"a_boolean_true",
FALSE,
&out,
&error));
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
"section",
NULL,
FALSE,
&out,
&error));
/* Restore the old mask. */
g_log_set_always_fatal (always_fatal_mask);
g_assert (ot_keyfile_get_boolean_with_default (g_keyfile,
"section",
"a_boolean_true",
@@ -86,6 +58,7 @@ test_get_boolean_with_default (void)
&error));
g_assert_true (out);
g_clear_error (&error);
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
"a_fake_section",
"a_boolean_true",
@@ -97,8 +70,8 @@ test_get_boolean_with_default (void)
static void
test_get_value_with_default (void)
{
GError *error = NULL;
char *out = NULL;
g_autoptr(GError) error = NULL;
g_autofree char *out = NULL;
GLogLevelFlags always_fatal_mask;
const char *section = "section";
@@ -112,18 +85,21 @@ test_get_value_with_default (void)
"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_clear_pointer (&out, g_free);
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);
@@ -135,6 +111,7 @@ test_get_value_with_default (void)
&out,
&error));
g_assert_cmpstr (out, ==, "foo");
g_clear_pointer (&out, g_free);
g_assert (ot_keyfile_get_value_with_default (g_keyfile,
section,
@@ -143,6 +120,7 @@ test_get_value_with_default (void)
&out,
&error));
g_assert_cmpstr (out, ==, "correct");
g_clear_pointer (&out, g_free);
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
"a_fake_section",
@@ -150,6 +128,8 @@ test_get_value_with_default (void)
"no value",
&out,
&error));
g_clear_error (&error);
g_clear_pointer (&out, g_free);
}
static void
+16 -16
View File
@@ -26,6 +26,7 @@
#include <string.h>
#include <ostree.h>
#include "ostree-libarchive-private.h"
#include <archive.h>
#include <archive_entry.h>
@@ -40,7 +41,7 @@ static void
test_data_init (TestData *td)
{
GError *error = NULL;
struct archive *a = archive_write_new ();
ot_cleanup_write_archive struct archive *a = archive_write_new ();
struct archive_entry *ae;
uid_t uid = getuid ();
gid_t gid = getgid ();
@@ -115,12 +116,12 @@ test_data_init (TestData *td)
archive_entry_free (ae);
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_close (a));
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_free (a));
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");
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_free (a));
a = archive_write_new ();
g_assert (a);
@@ -128,7 +129,6 @@ test_data_init (TestData *td)
g_assert_cmpint (0, ==, archive_write_add_filter_gzip (a));
g_assert_cmpint (0, ==, archive_write_open_fd (a, td->fd_empty));
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_close (a));
g_assert_cmpint (ARCHIVE_OK, ==, archive_write_free (a));
{ g_autoptr(GFile) repopath = g_file_new_for_path ("repo");
td->repo = ostree_repo_new (repopath);
@@ -165,7 +165,7 @@ test_libarchive_noautocreate_empty (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
@@ -180,8 +180,8 @@ static void
test_libarchive_autocreate_empty (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
g_autoptr(GError) error = NULL;
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
@@ -198,8 +198,8 @@ static void
test_libarchive_error_device_file (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
g_autoptr(GError) error = NULL;
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
@@ -207,6 +207,7 @@ test_libarchive_error_device_file (gconstpointer data)
(void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error);
g_assert (error != NULL);
g_clear_error (&error);
}
static gboolean
@@ -268,8 +269,8 @@ static void
test_libarchive_ignore_device_file (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
g_autoptr(GError) error = NULL;
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
if (skip_if_no_xattr (td))
@@ -331,7 +332,7 @@ test_libarchive_ostree_convention (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
if (skip_if_no_xattr (td))
@@ -373,7 +374,7 @@ test_libarchive_xattr_callback (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
OstreeRepoCommitModifier *modifier = NULL;
char buf[7] = { 0 };
@@ -428,7 +429,7 @@ static void
entry_pathname_test_helper (gconstpointer data, gboolean on)
{
TestData *td = (void*)data; GError *error = NULL;
struct archive *a = archive_read_new ();
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
OstreeRepoCommitModifier *modifier = NULL;
gboolean met_etc_file = FALSE;
@@ -468,7 +469,6 @@ entry_pathname_test_helper (gconstpointer data, gboolean on)
goto out;
}
archive_read_free (a);
ostree_repo_commit_modifier_unref (modifier);
out:
g_assert_no_error (error);
@@ -491,7 +491,7 @@ test_libarchive_selinux (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
ot_cleanup_read_archive struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
glnx_unref_object OstreeSePolicy *sepol = NULL;
OstreeRepoCommitModifier *modifier = NULL;
@@ -536,7 +536,6 @@ test_libarchive_selinux (gconstpointer data)
g_assert_cmpstr (buf, ==, "system_u:object_r:etc_t:s0");
out:
archive_read_free (a);
if (modifier)
ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
@@ -563,6 +562,7 @@ int main (int argc, char **argv)
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);
g_free (td.tmpd);
+4 -3
View File
@@ -32,7 +32,7 @@
static void
helper_test_compress_decompress (const guint8 *data, gssize data_size)
{
GError *error = 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);
@@ -55,9 +55,10 @@ 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(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 (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,
+6 -4
View File
@@ -84,7 +84,7 @@ 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;
GError *error = NULL;
g_autoptr(GError) error = NULL;
const char *pathname = "/foo/bar/baz";
const char *checksum = "01234567890123456789012345678901";
g_autofree char *source_checksum = NULL;
@@ -103,6 +103,7 @@ test_ensure_parent_dirs (void)
g_assert_false (ostree_mutable_tree_lookup (tree, "bar", &source_checksum2,
&source_subdir2, &error));
g_clear_error (&error);
}
static void
@@ -110,7 +111,7 @@ test_ensure_dir (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
const char *dirname = "foo";
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
@@ -122,13 +123,14 @@ test_ensure_dir (void)
g_assert (ostree_mutable_tree_replace_file (tree, filename, checksum, &error));
g_assert_false (ostree_mutable_tree_ensure_dir (tree, filename, &parent, &error));
g_clear_error (&error);
}
static void
test_replace_file (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
GError *error = NULL;
g_autoptr(GError) error = NULL;
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
const char *checksum2 = "ABCDEF01234567890123456789012345";
@@ -157,7 +159,7 @@ test_contents_checksum (void)
const char *subdir_checksum = "ABCD0123456789012345678901234567";
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *subdir = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
g_assert_null (ostree_mutable_tree_get_contents_checksum (tree));
ostree_mutable_tree_set_contents_checksum (tree, checksum);
+4 -3
View File
@@ -25,6 +25,7 @@
#include <gio/gio.h>
#include <string.h>
#include "ot-opt-utils.h"
#include "libglnx.h"
static GString *printerr_str = NULL;
@@ -39,19 +40,19 @@ util_usage_error_printerr (const gchar *string)
static void
test_ot_util_usage_error (void)
{
GError *error = NULL;
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);
g_assert_nonnull (strstr (printerr_str->str, "[TEST]"));
g_assert_nonnull (strstr (error->message, "find_me"));
g_clear_error (&error);
g_set_printerr_handler (old_printerr);
g_string_free (printerr_str, TRUE);
printerr_str = NULL;
g_option_context_free (context);
}
int main (int argc, char **argv)
+5 -2
View File
@@ -43,7 +43,7 @@ ot_parse_keyvalue (const char *keyvalue,
static void
test_ot_parse_boolean (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean out = FALSE;
g_assert_true (ot_parse_boolean ("yes", &out, &error));
g_assert_true (out);
@@ -70,15 +70,17 @@ test_ot_parse_boolean (void)
out = TRUE;
g_assert_true (ot_parse_boolean ("none", &out, &error));
g_assert_false (out);
g_clear_error (&error);
g_assert_false (ot_parse_boolean ("FOO", &out, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_clear_error (&error);
}
static void
test_ot_parse_keyvalue (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
char *keyvalue[] = {"foo=bar", "a=", "b=1231231"};
char *key[] = {"foo", "a", "b"};
char *value[] = {"bar", "", "1231231"};
@@ -104,6 +106,7 @@ test_ot_parse_keyvalue (void)
&out_value,
&error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_clear_error (&error);
}
}
+10 -3
View File
@@ -50,22 +50,29 @@ test_ot_util_path_split_validate (void)
static void
test_ot_util_filename_validate (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
/* Check for valid inputs. */
g_assert (ot_util_filename_validate ("valid", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("valid_file_name", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("file.name", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("foo..", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("..bar", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("baz:", &error));
g_assert_no_error (error);
/* Check for invalid inputs. */
g_assert_false (ot_util_filename_validate ("not/valid/file/name", &error));
error = NULL;
g_clear_error (&error);
g_assert_false (ot_util_filename_validate (".", &error));
error = NULL;
g_clear_error (&error);
g_assert_false (ot_util_filename_validate ("..", &error));
g_clear_error (&error);
}
int main (int argc, char **argv)
+1
View File
@@ -127,6 +127,7 @@ int main (int argc, char **argv)
g_test_add_data_func ("/test-pull-c/multi-ok-error-repeat", &td, test_pull_multi_error_then_ok);
r = g_test_run();
g_clear_object (&td.repo);
return r;
}
+2 -2
View File
@@ -74,8 +74,8 @@ test_rollsum (void)
#define MAX_BUFFER_SIZE 1000000
gsize i;
int len;
unsigned char *a = malloc (MAX_BUFFER_SIZE);
unsigned char *b = malloc (MAX_BUFFER_SIZE);
g_autofree unsigned char *a = malloc (MAX_BUFFER_SIZE);
g_autofree unsigned char *b = malloc (MAX_BUFFER_SIZE);
g_autoptr(GRand) rand = g_rand_new ();
/* These two buffers produce the same crc32. */
+1 -1
View File
@@ -27,7 +27,7 @@
static void
check_one_roundtrip (guint64 val)
{
GString *buf = g_string_new (NULL);
g_autoptr(GString) buf = g_string_new (NULL);
guint64 newval;
gsize bytes_read;