Imported Upstream version 2016.6

This commit is contained in:
Simon McVittie committed 2016-06-26 12:12:26 +01:00
1 parent a7b5654e44
commit 24762929e2
115 files changed
+4857 -2074

No files matched your search

+59 -9
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..53"
echo "1..57"
$OSTREE checkout test2 checkout-test2
echo "ok checkout"
@@ -103,6 +103,12 @@ $OSTREE commit -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
echo "ok commit no parent"
cd ${test_tmpdir}
empty_rev=$($OSTREE commit -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
omitted_rev=$($OSTREE commit -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
assert_streq $empty_rev $omitted_rev
echo "ok commit no subject"
cd ${test_tmpdir}
$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
@@ -179,13 +185,31 @@ cd ${test_tmpdir}/checkout-test2-4
$OSTREE commit -b test2 -s "no xattrs" --no-xattrs
echo "ok commit with no xattrs"
# NB: The + is optional, but we need to make sure we support it
cd ${test_tmpdir}
cat > test-statoverride.txt <<EOF
+2048 /a/nested/3
+1048 /a/nested/2
2048 /a/nested/3
EOF
cd ${test_tmpdir}/checkout-test2-4
$OSTREE commit -b test2 -s "with statoverride" --statoverride=../test-statoverride.txt
echo "ok commit statoverridde"
$OSTREE commit -b test2-override -s "with statoverride" --statoverride=../test-statoverride.txt
cd ${test_tmpdir}
$OSTREE checkout test2-override checkout-test2-override
test -g checkout-test2-override/a/nested/2
test -u checkout-test2-override/a/nested/3
echo "ok commit statoverride"
cd ${test_tmpdir}
cat > test-skiplist.txt <<EOF
/a/nested/3
EOF
cd ${test_tmpdir}/checkout-test2-4
assert_has_file a/nested/3
$OSTREE commit -b test2-skiplist -s "with skiplist" --skip-list=../test-skiplist.txt
cd ${test_tmpdir}
$OSTREE checkout test2-skiplist checkout-test2-skiplist
assert_not_has_file checkout-test2-skiplist/a/nested/3
echo "ok commit skiplist"
cd ${test_tmpdir}
$OSTREE prune
@@ -254,7 +278,7 @@ echo "ok prune"
cd ${test_tmpdir}
rm repo3 -rf
${CMD_PREFIX} ostree --repo=repo3 init --mode=archive-z2
${CMD_PREFIX} ostree --repo=repo3 init --mode=archive
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
rm repo3/refs/remotes -rf
mkdir repo3/refs/remotes
@@ -362,9 +386,9 @@ else
$OSTREE checkout test2 test2-checkout
fi
stat '--format=%Y' test2-checkout/baz/cow > cow-mtime
assert_file_has_content cow-mtime 0
assert_file_has_content cow-mtime 1
stat '--format=%Y' test2-checkout/baz/deeper > deeper-mtime
assert_file_has_content deeper-mtime 0
assert_file_has_content deeper-mtime 1
echo "ok content mtime"
cd ${test_tmpdir}
@@ -381,7 +405,7 @@ echo "ok commit of fifo was rejected"
cd ${test_tmpdir}
rm repo2 -rf
mkdir repo2
${CMD_PREFIX} ostree --repo=repo2 init --mode=archive-z2
${CMD_PREFIX} ostree --repo=repo2 init --mode=archive
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
rm -rf test2-checkout
${CMD_PREFIX} ostree --repo=repo2 checkout -U --disable-cache test2 test2-checkout
@@ -397,6 +421,28 @@ assert_file_has_content test2-checkout/baz/cow moo
assert_has_dir repo2/uncompressed-objects-cache
echo "ok disable cache checkout"
cd ${test_tmpdir}
rm checkout-test2 -rf
$OSTREE checkout test2 checkout-test2
date > checkout-test2/date.txt
rm repo/tmp/* -rf
export TEST_BOOTID=3072029c-8b10-60d1-d31b-8422eeff9b42
if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${TEST_BOOTID} \
$OSTREE commit -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then
assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT"
fi
assert_file_has_content err.txt OSTREE_REPO_TEST_ERROR_PRE_COMMIT
found_staging=0
for d in $(find repo/tmp/ -maxdepth 1 -type d); do
bn=$(basename $d)
if test ${bn##staging-} != ${bn}; then
assert_str_match "${bn}" "^staging-${TEST_BOOTID}-"
found_staging=1
fi
done
assert_streq "${found_staging}" 1
echo "ok test error pre commit/bootid"
# Whiteouts
cd ${test_tmpdir}
mkdir -p overlay/baz/
@@ -468,5 +514,9 @@ cd ..
if cmp timestamp-{orig,new}.txt; then
assert_not_reached "failed to update mtime on repo"
fi
echo "ok mtime updated"
cd ${test_tmpdir}
$OSTREE init --mode=bare --repo=repo-extensions
assert_has_dir repo-extensions/extensions
echo "ok extensions dir"
+535
View File
@@ -0,0 +1,535 @@
# This GLib suppressions file is known to be used at least by:
#
# - rpm-software-management/libhif
#
# Please use the upstream verison in libhif for changes.
{
gobject_init_1
Memcheck:Leak
...
fun:gobject_init
}
{
g_type_register_static_1
Memcheck:Leak
...
fun:g_type_register_static
}
{
g_type_register_fundamental
Memcheck:Leak
...
fun:g_type_register_fundamental
}
{
g_type_init_with_debug_flags
Memcheck:Leak
...
fun:g_type_init_with_debug_flags
}
{
g_type_class_ref_1
Memcheck:Leak
...
fun:type_iface_vtable_base_init_Wm
...
fun:g_type_class_ref
}
{
g_type_class_ref_2
Memcheck:Leak
...
fun:type_class_init_Wm
...
fun:g_type_class_ref
}
{
g_type_add_interface_static
Memcheck:Leak
...
fun:g_type_add_interface_static
}
{
g_param_spec_internal
Memcheck:Leak
...
fun:g_type_class_ref
fun:g_type_create_instance
fun:g_param_spec_internal
}
{
g_param_spec_enum
Memcheck:Leak
...
fun:g_type_class_ref
fun:g_param_spec_enum
}
{
g_param_spec_flags
Memcheck:Leak
...
fun:g_type_class_ref
fun:g_param_spec_flags
}
{
g_quark_from_static_string
Memcheck:Leak
...
fun:g_quark_from_static_string
}
{
g_quark_from_string
Memcheck:Leak
...
fun:g_quark_from_string
}
{
g_value_register_transform_func
Memcheck:Leak
...
fun:g_value_register_transform_func
}
{
test_run_seed
Memcheck:Leak
...
fun:g_rand_new_with_seed_array
fun:test_run_seed
...
fun:g_test_run_suite
}
{
g_test_init
Memcheck:Leak
...
fun:g_rand_new_with_seed_array
...
fun:g_test_init
}
{
g_intern_static_string
Memcheck:Leak
...
fun:g_intern_static_string
}
{
g_main_context_push_thread_default
Memcheck:Leak
...
fun:g_queue_new
fun:g_main_context_push_thread_default
}
{
g_main_context_push_thread_default_inlined
Memcheck:Leak
...
fun:g_slice_alloc0
fun:g_main_context_push_thread_default
}
{
g_dbus_error_register_error
Memcheck:Leak
...
fun:g_dbus_error_register_error
}
{
g_param_spec_pool_insert
Memcheck:Leak
...
fun:g_param_spec_pool_insert
}
{
g_main_context_default
Memcheck:Leak
...
fun:g_main_context_default
}
{
g_main_context_check
Memcheck:Leak
...
fun:g_ptr_array_add
fun:g_main_context_check
}
{
g_test_run_suite
Memcheck:Leak
...
fun:g_slist_copy
fun:g_test_run_suite_internal
fun:g_test_run_suite
}
{
g_dbus_interface_info_cache_build
Memcheck:Leak
...
fun:g_dbus_interface_info_cache_build
}
{
g_cancellable_push_current
Memcheck:Leak
...
fun:thread_memory_from_self
...
fun:g_cancellable_push_current
}
{
_g_io_module_get_default
Memcheck:Leak
...
fun:g_io_module_new
fun:g_io_modules_scan_all_in_directory_with_scope
fun:_g_io_modules_ensure_loaded
fun:_g_io_module_get_default
}
{
g_io_scheduler_push_job
Memcheck:Leak
...
fun:init_scheduler
fun:g_once_impl
fun:g_io_scheduler_push_job
}
{
g_io_scheduler_push_job_2
Memcheck:Leak
...
fun:g_system_thread_new
...
fun:g_io_scheduler_push_job
}
{
g_bus_get_sync__available_connections
Memcheck:Leak
...
fun:g_hash_table_new
fun:initable_init
fun:g_initable_init
fun:g_bus_get_sync
}
{
g_socket_connection_factory_register_type
Memcheck:Leak
...
fun:g_socket_connection_factory_register_type
}
{
g_test_add_vtable
Memcheck:Leak
...
fun:g_test_add_vtable
}
{
g_mutex_lock
Memcheck:Leak
...
fun:g_mutex_impl_new
fun:g_mutex_get_impl
fun:g_mutex_lock
}
{
g_thread_self
Memcheck:Leak
...
fun:g_thread_self
}
{
g_rec_mutex_lock
Memcheck:Leak
...
fun:g_rec_mutex_impl_new
fun:g_rec_mutex_get_impl
fun:g_rec_mutex_lock
}
{
test_case_run
Memcheck:Leak
...
fun:g_malloc0
fun:test_case_run
...
fun:g_test_run_suite
}
{
g_get_charset
Memcheck:Leak
...
fun:g_get_charset
}
{
g_test_run_suite__timer_new
Memcheck:Leak
...
fun:g_timer_new
fun:test_case_run
...
fun:g_test_run_suite
}
{
g_test_run_suite__timer_new2
Memcheck:Leak
...
fun:g_timer_new
fun:test_case_run_suite_internal
...
fun:g_test_run_suite
}
{
g_test_run_suite__strconcat
Memcheck:Leak
...
fun:g_strconcat
fun:test_case_run
...
fun:g_test_run_suite
fun:g_test_run
}
{
g_type_interface_add_prerequisite
Memcheck:Leak
...
fun:g_type_interface_add_prerequisite
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:g_slist_copy
fun:g_test_run_suite_internal
...
fun:g_test_run_suite
}
{
g_set_prgname
Memcheck:Leak
...
fun:g_set_prgname
}
{
g_test_run_suite__strconcat_2
Memcheck:Leak
...
fun:g_strconcat
fun:g_test_run_suite_internal
}
{
g_test_run_suite__strdup
Memcheck:Leak
...
fun:g_strdup
fun:g_test_run_suite_internal
}
{
g_private_get
Memcheck:Leak
...
fun:g_private_get
}
{
g_private_set
Memcheck:Leak
...
fun:g_private_set
}
{
g_static_mutex_get_mutex_impl
Memcheck:Leak
...
fun:g_static_mutex_get_mutex_impl
}
{
g_variant_type_info_unref
Memcheck:Leak
...
fun:g_hash_table_remove
fun:g_variant_type_info_unref
}
{
g_rw_lock_reader_lock
Memcheck:Leak
...
fun:g_rw_lock_impl_new
fun:g_rw_lock_get_impl
fun:g_rw_lock_reader_lock
}
{
g_child_watch_finalize__rt_sigaction
Memcheck:Param
rt_sigaction(act->sa_flags)
fun:__libc_sigaction
...
fun:g_child_watch_finalize
}
{
g_dbus_worker_new
Memcheck:Leak
fun:calloc
...
fun:_g_dbus_worker_new
}
{
gdbus_shared_thread_func
Memcheck:Leak
match-leak-kinds: definite
...
fun:g_malloc
...
fun:gdbus_shared_thread_func
}
{
g_task_start_task_thread
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
fun:g_slice_alloc
fun:g_slice_alloc0
...
fun:g_thread_pool_push
fun:g_task_start_task_thread
}
{
g_get_language_names
Memcheck:Leak
match-leak-kinds: definite
fun:calloc
fun:g_malloc0
fun:g_get_language_names
}
{
g_get_filename_charsets
Memcheck:Leak
match-leak-kinds: definite
...
fun:g_get_filename_charsets
fun:g_filename_display_name
}
{
g_main_current_source
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
...
fun:g_main_current_source
fun:g_task_return
fun:g_task_thread_pool_thread
}
{
g_once_init_enter
Memcheck:Leak
match-leak-kinds: definite
...
fun:g_once_init_enter
}
{
g_child_watch_source_new
Memcheck:Leak
match-leak-kinds: definite
...
fun:g_thread_new
...
fun:g_child_watch_source_new
}
{
continue_writing_in_idle_cb
Memcheck:Leak
match-leak-kinds: definite
...
fun:g_task_new
...
fun:continue_writing_in_idle_cb
fun:g_main_context_dispatch
}
{
g_main_current_source
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:g_main_current_source
}
{
g_thread_pool_push
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:g_thread_pool_push
}
{
leak_test_dbus_dispose
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:g_main_loop_run
fun:g_test_dbus_down
}
{
leak_test_dbus_down
Memcheck:Leak
match-leak-kinds: definite
fun:calloc
fun:g_malloc0
fun:g_main_loop_new
fun:g_test_dbus_down
}
{
leak_socket_client_connect
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
fun:g_slice_alloc
fun:g_slice_alloc0
fun:g_socket_client_connect_async
fun:g_socket_client_connect_to_uri_async
}
{
leak_signal_handlers_disconnect_matched
Memcheck:Leak
match-leak-kinds: definite
fun:calloc
fun:g_malloc0
...
fun:g_slice_alloc
...
fun:g_signal_handlers_disconnect_matched
}
{
g_tls_connection_gnutls_init_priorities
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
fun:g_strdup
fun:g_tls_connection_gnutls_init_priorities
}
{
g_tls_connection_gnutls_heisenbug_likely_same_as_above
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
fun:g_strdup
...
fun:g_tls_client_connection_new
}
{
g_unix_signal_add_full
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
...
fun:g_thread_new
...
fun:g_unix_signal_add_full
}
{
glib_worker_1
Memcheck:Leak
...
fun:glib_worker_main
}
+7 -7
View File
@@ -28,11 +28,11 @@
/* This function hovers in a quantum superposition of horrifying and
* beautiful. Future generations may interpret it as modern art.
*/
static gboolean
run_libtest (const char *cmd, GError **error)
gboolean
ot_test_run_libtest (const char *cmd, GError **error)
{
gboolean ret = FALSE;
const char *builddir = g_getenv ("G_TEST_BUILDDIR");
const char *srcdir = g_getenv ("G_TEST_SRCDIR");
int estatus;
g_autoptr(GPtrArray) argv = g_ptr_array_new ();
g_autoptr(GString) cmdstr = g_string_new ("");
@@ -40,8 +40,8 @@ run_libtest (const char *cmd, GError **error)
g_ptr_array_add (argv, "bash");
g_ptr_array_add (argv, "-c");
g_string_append (cmdstr, ". ");
g_string_append (cmdstr, builddir);
g_string_append (cmdstr, "set -xeuo pipefail; . ");
g_string_append (cmdstr, srcdir);
g_string_append (cmdstr, "/tests/libtest.sh; ");
g_string_append (cmdstr, cmd);
@@ -68,7 +68,7 @@ ot_test_setup_repo (GCancellable *cancellable,
g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
glnx_unref_object OstreeRepo* ret_repo = NULL;
if (!run_libtest ("setup_test_repository", error))
if (!ot_test_run_libtest ("setup_test_repository archive-z2", error))
goto out;
ret_repo = ostree_repo_new (repo_path);
@@ -91,7 +91,7 @@ ot_test_setup_sysroot (GCancellable *cancellable,
g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
glnx_unref_object OstreeSysroot *ret_sysroot = NULL;
if (!run_libtest ("setup_os_repository \"archive-z2\" \"syslinux\"", error))
if (!ot_test_run_libtest ("setup_os_repository \"archive-z2\" \"syslinux\"", error))
goto out;
ret_sysroot = ostree_sysroot_new (sysroot_path);
+1
View File
@@ -27,6 +27,7 @@
G_BEGIN_DECLS
gboolean ot_test_run_libtest (const char *cmd, GError **error);
OstreeRepo *ot_test_setup_repo (GCancellable *cancellable,
GError **error);
+54 -6
View File
@@ -69,6 +69,7 @@ export TEST_GPG_KEYID_3="DF444D67"
# this by copying locally.
echo "Copying gpghome to ${test_tmpdir}"
cp -a "${test_srcdir}/gpghome" ${test_tmpdir}
chmod -R u+w "${test_tmpdir}"
export TEST_GPG_KEYHOME=${test_tmpdir}/gpghome
export OSTREE_GPG_HOME=${test_tmpdir}/gpghome/trusted
@@ -77,15 +78,28 @@ if test -n "${OT_TESTS_DEBUG:-}"; then
fi
if test -n "${OT_TESTS_VALGRIND:-}"; then
CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${test_srcdir}/ostree-valgrind.supp"
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
CMD_PREFIX="env LD_PRELOAD=${test_builddir}/libreaddir-rand.so"
# 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
CMD_PREFIX="env LD_PRELOAD=${test_builddir}/libreaddir-rand.so"
else
CMD_PREFIX=""
fi
fi
assert_streq () {
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
}
assert_str_match () {
if ! echo "$1" | grep -E -q "$2"; then
(echo 1>&2 "$1 does not match regexp $2"; exit 1)
fi
}
assert_not_streq () {
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2"; exit 1)
}
@@ -100,13 +114,17 @@ assert_has_dir () {
assert_not_has_file () {
if test -f "$1"; then
echo 1>&2 "File '$1' exists"; exit 1
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' exists"
exit 1
fi
}
assert_not_file_has_content () {
if grep -q -e "$2" "$1"; then
echo 1>&2 "File '$1' incorrectly matches regexp '$2'"; exit 1
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' incorrectly matches regexp '$2'"
exit 1
fi
}
@@ -118,13 +136,38 @@ assert_not_has_dir () {
assert_file_has_content () {
if ! grep -q -e "$2" "$1"; then
echo 1>&2 "File '$1' doesn't match regexp '$2'"; exit 1
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' doesn't match regexp '$2'"
exit 1
fi
}
assert_symlink_has_content () {
if ! test -L "$1"; then
echo 1>&2 "File '$1' is not a symbolic link"
exit 1
fi
if ! readlink "$1" | grep -q -e "$2"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "Symbolic link '$1' doesn't match regexp '$2'"
exit 1
fi
}
assert_file_empty() {
if test -s "$1"; then
echo 1>&2 "File '$1' is not empty"; exit 1
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' is not empty"
exit 1
fi
}
assert_files_hardlinked() {
f1=$(stat -c %i $1)
f2=$(stat -c %i $2)
if [ "$f1" != "$f2" ]; then
echo 1>&2 "Files '$1' and '$2' are not hardlinked"
exit 1
fi
}
@@ -370,6 +413,11 @@ skip_without_fuse () {
exit 0
fi
if ! capsh --print | grep -q 'Bounding set.*[^a-z]cap_sys_admin'; then
echo "1..0 # SKIP No cap_sys_admin in bounding set, can't use FUSE"
exit 0
fi
if ! [ -w /dev/fuse ]; then
echo "1..0 # SKIP no write access to /dev/fuse"
exit 0
-199
View File
@@ -1,199 +0,0 @@
{
g_type_init_with_debug_flags calloc
Memcheck:Leak
fun:calloc
...
fun:g_type_init_with_debug_flags
...
}
{
g_type_add_interface_static malloc
Memcheck:Leak
fun:malloc
...
fun:g_type_add_interface_static
...
}
{
g_type_add_interface_dynamic malloc
Memcheck:Leak
fun:malloc
...
fun:g_type_add_interface_dynamic
...
}
{
g_type_class_ref malloc
Memcheck:Leak
fun:malloc
...
fun:g_type_class_ref
...
}
{
g_type_register_dynamic malloc
Memcheck:Leak
fun:malloc
...
fun:g_type_register_dynamic
...
}
{
g_type_init_with_debug_flags malloc
Memcheck:Leak
fun:malloc
...
fun:g_type_init_with_debug_flags
...
}
{
g_type_init_with_debug_flags realloc
Memcheck:Leak
fun:realloc
...
fun:g_type_init_with_debug_flags
...
}
{
g_test_add_vtable malloc
Memcheck:Leak
fun:malloc
...
fun:g_test_add_vtable
...
}
{
g_test_init
Memcheck:Leak
fun:malloc
...
fun:g_test_init
...
}
{
g_type_register_static malloc
Memcheck:Leak
fun:malloc
...
fun:g_type_register_static
...
}
{
g_type_register_static realloc
Memcheck:Leak
fun:realloc
...
fun:g_type_register_static
...
}
{
g_type_register_fundamental never freed
Memcheck:Leak
fun:malloc
...
fun:g_type_register_fundamental
...
}
{
g_type_class_ref never finalized
Memcheck:Leak
fun:calloc
...
fun:g_type_class_ref
...
}
{
DBusGValue qdata
Memcheck:Leak
fun:realloc
fun:g_realloc
fun:g_type_set_qdata
fun:_dbus_g_value_types_init
...
}
{
gettext conditional jump
Memcheck:Cond
fun:__GI___strcasecmp_l
fun:__gconv_open
fun:_nl_find_msg
fun:__dcigettext
...
}
{
gettext uninitialized value
Memcheck:Value8
fun:__GI___strcasecmp_l
fun:__gconv_open
fun:_nl_find_msg
fun:__dcigettext
...
}
{
font config invalid reads
Memcheck:Addr4
...
fun:FcConfigParseAndLoad
...
}
{
dynamic loader conditional jump
Memcheck:Cond
fun:index
fun:expand_dynamic_string_token
fun:_dl_map_object
fun:map_doit
fun:_dl_catch_error
fun:do_preload
fun:dl_main
...
}
{
g_vfs_get_local
Memcheck:Leak
...
fun:g_vfs_get_local
...
}
{
_g_io_modules_ensure_loaded
Memcheck:Leak
...
fun:_g_io_modules_ensure_loaded
...
}
{
_g_io_module_get_default
Memcheck:Leak
...
fun:_g_io_module_get_default
...
}
{
_dl_allocate_tls
Memcheck:Leak
...
fun:_dl_allocate_tls
...
}
+1
View File
@@ -0,0 +1 @@
# Use this to suppress "possibly lost" for global statics
+1 -2
View File
@@ -97,7 +97,6 @@ readdir (DIR *dirp)
while (cache_another)
{
DirEntries *de;
GSList *l;
errno = 0;
ret = real_readdir (dirp);
@@ -110,12 +109,12 @@ readdir (DIR *dirp)
{
if (g_random_boolean ())
{
struct dirent *copy;
if (!de)
{
de = dir_entries_new ();
g_hash_table_insert (direntcache, dirp, de);
}
struct dirent *copy;
copy = g_memdup (ret, sizeof (struct dirent));
g_ptr_array_add (de->entries, copy);
}
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
#
# Copyright (C) 2016 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. $(dirname $0)/libtest.sh
# Exports OSTREE_SYSROOT so --sysroot not needed.
setup_os_repository "archive-z2" "syslinux"
echo "1..1"
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
export rev
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
os_repository_new_commit
rm sysroot/ostree/repo/tmp/* -rf
export TEST_BOOTID=4072029c-8b10-60d1-d31b-8422eeff9b42
if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${TEST_BOOTID} \
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT"
fi
stagepath=$(ls -d sysroot/ostree/repo/tmp/staging-${TEST_BOOTID}-*)
assert_has_dir "${stagepath}"
# We have an older failed stage, now use a new boot id
export NEW_TEST_BOOTID=5072029c-8b10-60d1-d31b-8422eeff9b42
if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${NEW_TEST_BOOTID} \
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=FOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT"
fi
newstagepath=$(ls -d sysroot/ostree/repo/tmp/staging-${NEW_TEST_BOOTID}-*)
assert_has_dir "${newstagepath}"
env OSTREE_BOOTID=${NEW_TEST_BOOTID} ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
newstagepath=$(ls -d sysroot/ostree/repo/tmp/staging-${NEW_TEST_BOOTID}-*)
assert_not_has_dir "${stagepath}"
assert_not_has_dir "${newstagepath}"
echo "ok admin bootid GC"
+138
View File
@@ -34,6 +34,143 @@ test_repo_is_not_system (gconstpointer 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;
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_assert_no_error (error);
return g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (mem_out_stream));
}
static void
test_raw_file_to_archive_z2_stream (gconstpointer data)
{
OstreeRepo *repo = OSTREE_REPO (data);
g_autofree gchar *commit_checksum = 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);
g_assert_no_error (error);
reachable = ostree_repo_traverse_new_reachable ();
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))
{
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;
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);
g_assert_no_error (error);
input_bytes = input_stream_to_bytes (input);
/* This is to simulate NULL input received from
* ostree_repo_load_file. Instead of creating the mem_input
* variable, I could also rewind the input stream and pass it to
* the function below, but this would assume that the input
* stream implements either the GSeekable or
* 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);
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);
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_assert_no_error (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);
g_assert_true (g_bytes_equal (input_bytes, input2_bytes));
g_assert_true (g_variant_equal (xattrs, xattrs2));
/* TODO: Not sure how to compare fileinfos */
++checks;
}
/* to make sure we really tested the function */
g_assert_cmpint (checks, >, 0);
}
int main (int argc, char **argv)
{
g_autoptr(GError) error = NULL;
@@ -46,6 +183,7 @@ int main (int argc, char **argv)
goto out;
g_test_add_data_func ("/repo-not-system", repo, test_repo_is_not_system);
g_test_add_data_func ("/raw-file-to-archive-z2-stream", repo, test_raw_file_to_archive_z2_stream);
return g_test_run();
out:
+1
View File
@@ -20,6 +20,7 @@
#include "config.h"
#include "libglnx.h"
#include "libgsystem.h"
#include <glib.h>
#include <stdlib.h>
+31 -2
View File
@@ -23,7 +23,7 @@ set -euo pipefail
setup_test_repository "archive-z2"
echo '1..2'
echo '1..5'
$OSTREE checkout test2 test2-co
$OSTREE commit --no-xattrs -b test2-noxattrs -s "test2 without xattrs" --tree=dir=test2-co
@@ -35,10 +35,39 @@ mkdir t
(cd t && tar xf ../test2.tar)
${CMD_PREFIX} ostree --repo=repo diff --no-xattrs test2-noxattrs ./t > diff.txt
assert_file_empty diff.txt
rm test2.tar diff.txt t -rf
echo 'ok export gnutar diff (no xattrs)'
cd ${test_tmpdir}
${OSTREE} 'export' test2-noxattrs --subpath=baz -o test2-subpath.tar
mkdir t2
(cd t2 && tar xf ../test2-subpath.tar)
${CMD_PREFIX} ostree --repo=repo diff --no-xattrs ./t2 ./t/baz > diff.txt
assert_file_empty diff.txt
echo 'ok export --subpath gnutar diff (no xattrs)'
cd ${test_tmpdir}
${OSTREE} 'export' test2-noxattrs --prefix=the-prefix/ -o test2-prefix.tar
mkdir t3
(cd t3 && tar xf ../test2-prefix.tar)
${CMD_PREFIX} ostree --repo=repo diff --no-xattrs test2-noxattrs ./t3/the-prefix > diff.txt
assert_file_empty diff.txt
echo 'ok export --prefix gnutar diff (no xattrs)'
cd ${test_tmpdir}
${OSTREE} 'export' test2-noxattrs --subpath=baz --prefix=the-prefix/ -o test2-prefix-subpath.tar
mkdir t4
(cd t4 && tar xf ../test2-prefix-subpath.tar)
${CMD_PREFIX} ostree --repo=repo diff --no-xattrs ./t4/the-prefix ./t/baz > diff.txt
${CMD_PREFIX} ostree --repo=repo diff --no-xattrs test2-noxattrs ./t3/the-prefix > diff.txt
assert_file_empty diff.txt
echo 'ok export --prefix --subpath gnutar diff (no xattrs)'
rm test2.tar test2-subpath.tar diff.txt t t2 t3 t4 -rf
cd ${test_tmpdir}
${OSTREE} 'export' test2 -o test2.tar
${OSTREE} commit -b test2-from-tar -s 'Import from tar' --tree=tar=test2.tar
+346 -46
View File
@@ -42,6 +42,8 @@ test_data_init (TestData *td)
GError *error = NULL;
struct archive *a = archive_write_new ();
struct archive_entry *ae;
uid_t uid = getuid ();
gid_t gid = getgid ();
td->tmpd = g_mkdtemp (g_strdup ("/var/tmp/test-libarchive-import-XXXXXX"));
g_assert_cmpint (0, ==, chdir (td->tmpd));
@@ -59,12 +61,16 @@ test_data_init (TestData *td)
ae = archive_entry_new ();
archive_entry_set_pathname (ae, "/");
archive_entry_set_mode (ae, S_IFDIR | 0755);
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
archive_entry_free (ae);
ae = archive_entry_new ();
archive_entry_set_pathname (ae, "/file");
archive_entry_set_mode (ae, S_IFREG | 0777);
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
archive_entry_set_size (ae, 4);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
g_assert_cmpint (4, ==, archive_write_data (a, "foo\n", 4));
@@ -73,6 +79,8 @@ test_data_init (TestData *td)
ae = archive_entry_new ();
archive_entry_set_pathname (ae, "/devnull");
archive_entry_set_mode (ae, S_IFCHR | 0777);
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
archive_entry_set_devmajor (ae, 1);
archive_entry_set_devminor (ae, 3);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
@@ -81,6 +89,26 @@ test_data_init (TestData *td)
ae = archive_entry_new ();
archive_entry_set_pathname (ae, "/anotherfile");
archive_entry_set_mode (ae, S_IFREG | 0777);
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
archive_entry_set_size (ae, 4);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
g_assert_cmpint (4, ==, archive_write_data (a, "bar\n", 4));
archive_entry_free (ae);
ae = archive_entry_new ();
archive_entry_set_pathname (ae, "/etc");
archive_entry_set_mode (ae, S_IFDIR | 0755);
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
archive_entry_free (ae);
ae = archive_entry_new ();
archive_entry_set_pathname (ae, "/etc/file");
archive_entry_set_mode (ae, S_IFREG | 0777);
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
archive_entry_set_size (ae, 4);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
g_assert_cmpint (4, ==, archive_write_data (a, "bar\n", 4));
@@ -123,6 +151,15 @@ spawn_cmdline (const char *cmd, GError **error)
return TRUE;
}
static void
test_archive_setup (int fd, struct archive *a)
{
g_assert_cmpint (0, ==, lseek (fd, 0, SEEK_SET));
g_assert_cmpint (0, ==, archive_read_support_format_all (a));
g_assert_cmpint (0, ==, archive_read_support_filter_all (a));
g_assert_cmpint (0, ==, archive_read_open_fd (a, fd, 8192));
}
static void
test_libarchive_noautocreate_empty (gconstpointer data)
{
@@ -132,10 +169,7 @@ test_libarchive_noautocreate_empty (gconstpointer data)
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
g_assert_cmpint (0, ==, lseek (td->fd_empty, 0, SEEK_SET));
g_assert_cmpint (0, ==, archive_read_support_format_all (a));
g_assert_cmpint (0, ==, archive_read_support_filter_all (a));
g_assert_cmpint (0, ==, archive_read_open_fd (a, td->fd_empty, 8192));
test_archive_setup (td->fd_empty, a);
(void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error);
g_assert_no_error (error);
@@ -153,10 +187,7 @@ test_libarchive_autocreate_empty (gconstpointer data)
opts.autocreate_parents = 1;
g_assert_cmpint (0, ==, lseek (td->fd_empty, 0, SEEK_SET));
g_assert_cmpint (0, ==, archive_read_support_format_all (a));
g_assert_cmpint (0, ==, archive_read_support_filter_all (a));
g_assert_cmpint (0, ==, archive_read_open_fd (a, td->fd_empty, 8192));
test_archive_setup (td->fd_empty, a);
(void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error);
g_assert_no_error (error);
@@ -172,68 +203,95 @@ test_libarchive_error_device_file (gconstpointer data)
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
g_assert_cmpint (0, ==, lseek (td->fd, 0, SEEK_SET));
g_assert_cmpint (0, ==, archive_read_support_format_all (a));
g_assert_cmpint (0, ==, archive_read_support_filter_all (a));
g_assert_cmpint (0, ==, archive_read_open_fd (a, td->fd, 8192));
test_archive_setup (td->fd, a);
(void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error);
g_assert (error != NULL);
}
static gboolean
skip_if_no_xattr (TestData *td)
{
/* /var/tmp might actually be a tmpfs */
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_test_skip (message);
return TRUE;
}
return FALSE;
}
static gboolean
import_write_and_ref (OstreeRepo *repo,
OstreeRepoImportArchiveOptions *opts,
struct archive *a,
const char *ref,
OstreeRepoCommitModifier *modifier,
GError **error)
{
gboolean ret = FALSE;
glnx_unref_object GFile *root = NULL;
g_autofree char *commit_checksum = NULL;
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
if (!ostree_repo_prepare_transaction (repo, NULL, NULL, error))
goto out;
if (!ostree_repo_import_archive_to_mtree (repo, opts, a, mtree, modifier,
NULL, error))
goto out;
if (!ostree_repo_write_mtree (repo, mtree, &root, NULL, error))
goto out;
if (!ostree_repo_write_commit (repo, NULL, "", "", NULL,
OSTREE_REPO_FILE (root),
&commit_checksum, NULL, error))
goto out;
ostree_repo_transaction_set_ref (repo, NULL, ref, commit_checksum);
if (!ostree_repo_commit_transaction (repo, NULL, NULL, error))
goto out;
ret = TRUE;
out:
return ret;
}
static void
test_libarchive_ignore_device_file (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
GCancellable *cancellable = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
glnx_unref_object GFile *root = NULL;
g_autofree char *commit_checksum = NULL;
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));
if (skip_if_no_xattr (td))
goto out;
g_test_skip (message);
goto out;
}
g_assert_cmpint (0, ==, lseek (td->fd, 0, SEEK_SET));
g_assert_cmpint (0, ==, archive_read_support_format_all (a));
g_assert_cmpint (0, ==, archive_read_support_filter_all (a));
g_assert_cmpint (0, ==, archive_read_open_fd (a, td->fd, 8192));
test_archive_setup (td->fd, a);
opts.ignore_unsupported_content = TRUE;
if (!ostree_repo_prepare_transaction (td->repo, NULL, cancellable, &error))
goto out;
if (!ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error))
goto out;
if (!ostree_repo_write_mtree (td->repo, mtree, &root, cancellable, &error))
goto out;
if (!ostree_repo_write_commit (td->repo, NULL, "", "", NULL,
OSTREE_REPO_FILE (root),
&commit_checksum, cancellable, &error))
goto out;
ostree_repo_transaction_set_ref (td->repo, NULL, "foo", commit_checksum);
if (!ostree_repo_commit_transaction (td->repo, NULL, cancellable, &error))
if (!import_write_and_ref (td->repo, &opts, a, "foo", NULL, &error))
goto out;
/* check contents */
if (!spawn_cmdline ("ostree --repo=repo ls foo file", &error))
goto out;
if (!spawn_cmdline ("ostree --repo=repo ls foo anotherfile", &error))
goto out;
if (!spawn_cmdline ("ostree --repo=repo ls foo /etc/file", &error))
goto out;
if (spawn_cmdline ("ostree --repo=repo ls foo devnull", &error))
g_assert_not_reached ();
g_assert (error != NULL);
@@ -243,6 +301,243 @@ test_libarchive_ignore_device_file (gconstpointer data)
g_assert_no_error (error);
}
static gboolean
check_ostree_convention (GError *error)
{
if (!spawn_cmdline ("ostree --repo=repo ls bar file", &error))
return FALSE;
if (!spawn_cmdline ("ostree --repo=repo ls bar anotherfile", &error))
return FALSE;
if (!spawn_cmdline ("ostree --repo=repo ls bar /usr/etc/file", &error))
return FALSE;
if (spawn_cmdline ("ostree --repo=repo ls bar /etc/file", &error))
g_assert_not_reached ();
g_assert (error != NULL);
g_clear_error (&error);
if (spawn_cmdline ("ostree --repo=repo ls bar devnull", &error))
g_assert_not_reached ();
g_assert (error != NULL);
g_clear_error (&error);
return TRUE;
}
static void
test_libarchive_ostree_convention (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
if (skip_if_no_xattr (td))
goto out;
test_archive_setup (td->fd, a);
opts.autocreate_parents = TRUE;
opts.use_ostree_convention = TRUE;
opts.ignore_unsupported_content = TRUE;
if (!import_write_and_ref (td->repo, &opts, a, "bar", NULL, &error))
goto out;
if (!check_ostree_convention (error))
goto out;
out:
g_assert_no_error (error);
}
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)");
if (strcmp (path, "/anotherfile") == 0)
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));
}
static void
test_libarchive_xattr_callback (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
OstreeRepoCommitModifier *modifier = NULL;
char buf[7] = { 0 };
if (skip_if_no_xattr (td))
goto out;
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
ostree_repo_commit_modifier_set_xattr_callback (modifier, xattr_cb,
NULL, NULL);
test_archive_setup (td->fd, a);
opts.ignore_unsupported_content = TRUE;
if (!import_write_and_ref (td->repo, &opts, a, "baz", modifier, &error))
goto out;
/* check contents */
if (!spawn_cmdline ("ostree --repo=repo checkout baz baz-checkout", &error))
goto out;
g_assert_cmpint (0, >, getxattr ("baz-checkout/file", "user.data", NULL, 0));
g_assert_cmpint (ENODATA, ==, errno);
if (getxattr ("baz-checkout/anotherfile", "user.data", buf, sizeof buf) < 0)
{
glnx_set_prefix_error_from_errno (&error, "%s", "getxattr");
goto out;
}
g_assert_cmpstr (buf, ==, "mydata");
out:
if (modifier)
ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
}
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;
return NULL;
}
static void
entry_pathname_test_helper (gconstpointer data, gboolean on)
{
TestData *td = (void*)data; GError *error = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0, };
OstreeRepoCommitModifier *modifier = NULL;
gboolean met_etc_file = FALSE;
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
ostree_repo_commit_modifier_set_xattr_callback (modifier, path_cb,
NULL, &met_etc_file);
test_archive_setup (td->fd, a);
opts.autocreate_parents = TRUE;
opts.use_ostree_convention = TRUE;
opts.ignore_unsupported_content = TRUE;
opts.callback_with_entry_pathname = on;
if (!import_write_and_ref (td->repo, &opts, a, "bar", modifier, &error))
goto out;
/* the flag shouldn't have any effect on the final tree */
if (!check_ostree_convention (error))
goto out;
if (!on && met_etc_file)
{
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Received callback with /etc/file");
goto out;
}
if (on && !met_etc_file)
{
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Did not receive callback with /etc/file");
goto out;
}
out:
g_assert_no_error (error);
}
static void
test_libarchive_no_use_entry_pathname (gconstpointer data)
{
entry_pathname_test_helper (data, FALSE);
}
static void
test_libarchive_use_entry_pathname (gconstpointer data)
{
entry_pathname_test_helper (data, TRUE);
}
static void
test_libarchive_selinux (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
struct archive *a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
glnx_unref_object OstreeSePolicy *sepol = NULL;
OstreeRepoCommitModifier *modifier = NULL;
char buf[64] = { 0 };
if (skip_if_no_xattr (td))
goto out;
{
glnx_unref_object GFile *root = g_file_new_for_path ("/");
/* creation should always succeed */
sepol = ostree_sepolicy_new (root, NULL, &error);
g_assert (sepol != NULL);
}
if (ostree_sepolicy_get_name (sepol) == NULL)
{
g_test_skip ("SELinux disabled");
goto out;
}
modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL);
ostree_repo_commit_modifier_set_sepolicy (modifier, sepol);
test_archive_setup (td->fd, a);
opts.ignore_unsupported_content = TRUE;
if (!import_write_and_ref (td->repo, &opts, a, "bob", modifier, &error))
goto out;
/* check contents */
if (!spawn_cmdline ("ostree --repo=repo checkout bob bob-checkout", &error))
goto out;
if (getxattr ("bob-checkout/etc", "security.selinux", buf, sizeof buf) < 0)
{
glnx_set_prefix_error_from_errno (&error, "%s", "getxattr");
goto out;
}
buf[(sizeof buf) - 1] = '\0';
g_assert_cmpstr (buf, ==, "system_u:object_r:etc_t:s0");
out:
if (modifier)
ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
}
int main (int argc, char **argv)
{
TestData td = {NULL,};
@@ -256,10 +551,15 @@ int main (int argc, char **argv)
g_test_add_data_func ("/libarchive/autocreate-empty", &td, test_libarchive_autocreate_empty);
g_test_add_data_func ("/libarchive/error-device-file", &td, test_libarchive_error_device_file);
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-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/use-entry-pathname", &td, test_libarchive_use_entry_pathname);
g_test_add_data_func ("/libarchive/selinux", &td, test_libarchive_selinux);
r = g_test_run();
if (td.tmpd)
if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL)
(void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
return r;
}
+78 -39
View File
@@ -26,57 +26,95 @@ fi
. $(dirname $0)/libtest.sh
echo "1..7"
echo "1..20"
setup_test_repository "bare"
cd ${test_tmpdir}
mkdir foo
cd foo
echo hi > hi
ln -s hi hello
mkdir subdir
echo contents > subdir/more
mkdir subdir/1
touch subdir/1/empty
mkdir subdir/2
touch subdir/2/empty
echo not > subdir/2/notempty
mkdir -p usr/bin
echo contents > usr/bin/foo
touch usr/bin/foo0
ln usr/bin/foo usr/bin/bar
ln usr/bin/foo0 usr/bin/bar0
ln -s foo usr/bin/sl
mkdir -p usr/local/bin
ln usr/bin/foo usr/local/bin/baz
ln usr/bin/foo0 usr/local/bin/baz0
ln usr/bin/sl usr/local/bin/slhl
touch usr/bin/setuidme
touch usr/bin/skipme
tar -c -z -f ../foo.tar.gz .
find . | cpio -o -H newc > ../foo.cpio
cd ..
$OSTREE commit -s "from tar" -b test-tar --tree=tar=foo.tar.gz
cat > statoverride.txt <<EOF
2048 /usr/bin/setuidme
EOF
cat > skiplist.txt <<EOF
/usr/bin/skipme
EOF
$OSTREE commit -s "from tar" -b test-tar \
--statoverride=statoverride.txt \
--skip-list=skiplist.txt \
--tree=tar=foo.tar.gz
echo "ok tar commit"
$OSTREE commit -s "from cpio" -b test-cpio \
--statoverride=statoverride.txt \
--skip-list=skiplist.txt \
--tree=tar=foo.cpio
echo "ok cpio commit"
cd ${test_tmpdir}
$OSTREE checkout test-tar test-tar-checkout
cd test-tar-checkout
assert_file_has_content hi hi
assert_file_has_content hello hi
assert_file_has_content subdir/more contents
assert_has_file subdir/1/empty
assert_has_file subdir/2/empty
cd ${test_tmpdir}
rm -rf test-tar-checkout
echo "ok tar contents"
assert_valid_checkout () {
cd ${test_tmpdir}
$OSTREE checkout test-$1 test-$1-checkout
cd test-$1-checkout
cd ${test_tmpdir}
mkdir hardlinktest
cd hardlinktest
echo other > otherfile
echo foo1 > foo
ln foo bar
tar czf ${test_tmpdir}/hardlinktest.tar.gz .
cd ${test_tmpdir}
$OSTREE commit -s 'hardlinks' -b test-hardlinks --tree=tar=hardlinktest.tar.gz
rm -rf hardlinktest
echo "ok hardlink commit"
# basic content check
assert_file_has_content usr/bin/foo contents
assert_file_has_content usr/bin/bar contents
assert_file_has_content usr/local/bin/baz contents
assert_file_empty usr/bin/foo0
assert_file_empty usr/bin/bar0
assert_file_empty usr/local/bin/baz0
echo "ok $1 contents"
cd ${test_tmpdir}
$OSTREE checkout test-hardlinks test-hardlinks-checkout
cd test-hardlinks-checkout
assert_file_has_content foo foo1
assert_file_has_content bar foo1
echo "ok hardlink contents"
# hardlinks
assert_files_hardlinked usr/bin/foo usr/bin/bar
assert_files_hardlinked usr/bin/foo usr/local/bin/baz
echo "ok $1 hardlink"
assert_files_hardlinked usr/bin/foo0 usr/bin/bar0
assert_files_hardlinked usr/bin/foo0 usr/local/bin/baz0
echo "ok $1 hardlink to empty files"
# symlinks
assert_symlink_has_content usr/bin/sl foo
assert_file_has_content usr/bin/sl contents
echo "ok $1 symlink"
# ostree checkout doesn't care if two symlinks are actually hardlinked
# together (which is fine). checking that it's also a symlink is good enough.
assert_symlink_has_content usr/local/bin/slhl foo
echo "ok $1 hardlink to symlink"
# stat override
test -u usr/bin/setuidme
echo "ok $1 setuid"
# skip list
test ! -f usr/bin/skipme
echo "ok $1 file skip"
cd ${test_tmpdir}
rm -rf test-$1-checkout
}
assert_valid_checkout tar
assert_valid_checkout cpio
cd ${test_tmpdir}
mkdir multicommit-files
@@ -115,3 +153,4 @@ cd ${test_tmpdir}
$OSTREE checkout partial partial-checkout
cd partial-checkout
assert_file_has_content subdir/original "original"
echo "ok tar partial commit contents"
+2
View File
@@ -21,6 +21,8 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
skip_without_user_xattrs
echo '1..2'
setup_test_repository "archive-z2"
+132
View File
@@ -0,0 +1,132 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "libglnx.h"
#include <glib.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <string.h>
#include "libostreetest.h"
typedef struct {
OstreeRepo *repo;
} TestData;
static void
test_data_init (TestData *td)
{
GError *local_error = NULL;
GError **error = &local_error;
g_autofree char *http_address = NULL;
g_autofree char *repo_url = NULL;
td->repo = ot_test_setup_repo (NULL, error);
if (!td->repo)
goto out;
if (!ot_test_run_libtest ("setup_fake_remote_repo1 archive-z2", error))
goto out;
if (!g_file_get_contents ("httpd-address", &http_address, NULL, error))
goto out;
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_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))
goto out;
}
out:
g_assert_no_error (local_error);
}
static void
test_pull_multi_nochange (gconstpointer data)
{
GError *local_error = NULL;
GError **error = &local_error;
TestData *td = (void*)data;
char *refs[] = { "main", NULL };
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))
goto out;
if (!ostree_repo_pull (td->repo, "origin", (char**)&refs, 0, NULL, NULL, error))
goto out;
out:
g_assert_no_error (local_error);
}
static void
test_pull_multi_error_then_ok (gconstpointer data)
{
GError *local_error = NULL;
GError **error = &local_error;
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))
goto out;
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))
g_assert_not_reached ();
g_clear_error (&tmp_error);
if (!ostree_repo_pull (td->repo, "origin", (char**)&ok_refs, 0, NULL, NULL, error))
goto out;
}
out:
g_assert_no_error (local_error);
}
int main (int argc, char **argv)
{
TestData td = {NULL,};
int r;
test_data_init (&td);
g_test_init (&argc, &argv, NULL);
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();
return r;
}
+80
View File
@@ -0,0 +1,80 @@
#!/bin/bash
#
# Copyright (C) 2016 Endless Mobile, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. $(dirname $0)/libtest.sh
setup_fake_remote_repo1 "archive-z2"
echo '1..1'
cd ${test_tmpdir}
# get a list of XX/XXXXXXX...XX.commit
find ostree-srv/gnomerepo/objects -name '*.commit' | cut -d/ -f4- | sort >${test_tmpdir}/original_commits
gnomerepo_url="$(cat httpd-address)/ostree/gnomerepo"
mkdir mirror-srv
cd mirror-srv
mkdir gnomerepo
${CMD_PREFIX} ostree --repo=gnomerepo init --mode "archive-z2"
${CMD_PREFIX} ostree --repo=gnomerepo remote add --set=gpg-verify=false origin ${gnomerepo_url}
${CMD_PREFIX} ostree --repo=gnomerepo pull --mirror --depth=-1 origin main
find gnomerepo/objects -name '*.commit' | cut -d/ -f3- | sort >${test_tmpdir}/mirror_commits
if ! cmp --quiet ${test_tmpdir}/original_commits ${test_tmpdir}/mirror_commits
then
assert_not_reached 'original repository and its mirror should have the same commits'
fi
cd ${test_tmpdir}
mkdir mirror-httpd
cd mirror-httpd
ln -s ${test_tmpdir}/mirror-srv ostree
mirror_log="${test_tmpdir}/mirror_log"
${CMD_PREFIX} ostree trivial-httpd --log-file=${mirror_log} --autoexit --daemonize -p ${test_tmpdir}/mirror-httpd-port
port=$(cat ${test_tmpdir}/mirror-httpd-port)
echo "http://127.0.0.1:${port}" > ${test_tmpdir}/mirror-httpd-address
cd ${test_tmpdir}
mirrorrepo_url="$(cat mirror-httpd-address)/ostree/gnomerepo"
mkdir repo
${CMD_PREFIX} ostree --repo=repo init
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin ${gnomerepo_url}
rm -rf ${test_tmpdir}/ostree-srv/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull --depth=-1 origin main
then
assert_not_reached 'pulling from removed remote should have failed'
fi
if ! ${CMD_PREFIX} ostree --repo=repo pull --depth=-1 --url=${mirrorrepo_url} origin main
then
cat ${mirror_log}
assert_not_reached 'fetching from the overridden URL should succeed'
fi
find repo/objects -name '*.commit' | cut -d/ -f3- | sort >${test_tmpdir}/repo_commits
if ! cmp --quiet ${test_tmpdir}/original_commits ${test_tmpdir}/repo_commits
then
assert_not_reached 'original repository and its mirror should have the same commits'
fi
echo "ok pull url override"
+31
View File
@@ -65,4 +65,35 @@ ${CMD_PREFIX} ostree refs --repo=repo | wc -l > refscount.delete3
assert_file_has_content refscount.delete3 "^3$"
assert_not_file_has_content reflist '^test-1$'
#Add a few more commits, to test --create
${CMD_PREFIX} ostree --repo=repo commit --branch=ctest -m ctest -s ctest tree
${CMD_PREFIX} ostree --repo=repo commit --branch=foo/ctest -m ctest -s ctest tree
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount
assert_file_has_content refscount "^5$"
if ${CMD_PREFIX} ostree --repo=repo refs --create=ctest-new; then
assert_not_reached "refs --create unexpectedly succeeded without specifying an existing ref!"
fi
if ${CMD_PREFIX} ostree --repo=repo refs ctest --create; then
assert_not_reached "refs --create unexpectedly succeeded without specifying the ref to create!"
fi
if ${CMD_PREFIX} ostree --repo=repo refs does-not-exist --create=ctest-new; then
assert_not_reached "refs --create unexpectedly succeeded for a prefix that doesn't exist!"
fi
if ${CMD_PREFIX} ostree --repo=repo refs ctest --create=foo; then
assert_not_reached "refs --create unexpectedly succeeded for a prefix that is already in use by a folder!"
fi
if ${CMD_PREFIX} ostree --repo=repo refs foo/ctest --create=ctest; then
assert_not_reached "refs --create unexpectedly succeeded in overwriting an existing prefix!"
fi
#Check to see if any uncleaned tmp files were created after failed --create
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount.create1
assert_file_has_content refscount.create1 "^5$"
${CMD_PREFIX} ostree --repo=repo refs ctest --create ctest-new
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount.create2
assert_file_has_content refscount.create2 "^6$"
echo "ok refs"
-40
View File
@@ -1,40 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2013 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
echo "1..1"
. $(dirname $0)/libtest.sh
setup_test_repository "bare"
cd ${test_tmpdir}
cat > test-statoverride.txt <<EOF
+2048 /abinary
EOF
$OSTREE checkout test2 test2-checkout
touch test2-checkout/abinary
chmod a+x test2-checkout/abinary
(cd test2-checkout && $OSTREE commit -b test2 -s "with statoverride" --statoverride=../test-statoverride.txt)
rm -rf test2-checkout
$OSTREE checkout test2 test2-checkout
test -u test2-checkout/abinary
echo "ok"
+11 -2
View File
@@ -19,10 +19,19 @@
set -euo pipefail
echo '1..1'
echo '1..2'
echo "Verifying all expected symbols are actually exported..."
grep ' ostree_[A-Za-z0-9_]*;' ${G_TEST_SRCDIR}/src/libostree/libostree.sym | sed -e 's,^ *\([A-Za-z0-9_]*\);,\1,' | sort -u > expected-symbols.txt
eu-readelf -a ${G_TEST_BUILDDIR}/.libs/libostree-1.so | grep 'FUNC.*GLOBAL.*DEFAULT.*@@LIBOSTREE_' | sed -e 's,^.* \(ostree_[A-Za-z0-9_]*\)@@LIBOSTREE_[0-9_.]*,\1,' |sort -u > found-symbols.txt
diff -u expected-symbols.txt found-symbols.txt
echo "ok exports"
echo 'ok'
# cmd__private__ is private. The fetcher symbol should not have been made public.
grep -E -v '(ostree_cmd__private__)|(ostree_fetcher_config_flags_get_type)' found-symbols.txt > expected-documented.txt
echo "Verifying all public symbols are documented:"
grep '^ostree_' ${G_TEST_SRCDIR}/apidoc/ostree-sections.txt |sort -u > found-documented.txt
diff -u expected-documented.txt found-documented.txt
echo 'ok documented symbols'
+1 -1
View File
@@ -37,7 +37,7 @@ function libtestExec(shellCode) {
let testdatadir = GLib.getenv("G_TEST_SRCDIR");
let libtestPath = GLib.build_filenamev([testdatadir, 'libtest.sh'])
let proc = GSystem.Subprocess.new_simple_argv(['bash', '-c',
'. ' + GLib.shell_quote(libtestPath) + '; ' + shellCode],
'set -xeuo pipefail; . ' + GLib.shell_quote(libtestPath) + '; ' + shellCode],
GSystem.SubprocessStreamDisposition.INHERIT,
GSystem.SubprocessStreamDisposition.INHERIT,
null);