From 68a66dd7e3cc3ea6164770a1188bd84d51d73f2a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 29 Aug 2017 18:09:04 +0100 Subject: [PATCH] Add patches to make the tests pass again when /var/tmp is on tmpfs tmpfs does not support user xattrs. --- debian/changelog | 2 + ...cit-uses-of-bare-user-if-no-user-xat.patch | 190 ++++++++++++++++++ ...ng-single-checks-without-user-xattrs.patch | 31 +++ debian/patches/series | 5 + ...ly-Skip-final-step-if-no-user-xattrs.patch | 59 ++++++ ...t-Skip-if-extended-attributes-are-un.patch | 142 +++++++++++++ ...-This-test-uses-bare-user-hence-need.patch | 21 ++ 7 files changed, 450 insertions(+) create mode 100644 debian/patches/basic-test-Skip-explicit-uses-of-bare-user-if-no-user-xat.patch create mode 100644 debian/patches/libtest-Allow-skipping-single-checks-without-user-xattrs.patch create mode 100644 debian/patches/series create mode 100644 debian/patches/test-basic-user-only-Skip-final-step-if-no-user-xattrs.patch create mode 100644 debian/patches/test-libarchive-import-Skip-if-extended-attributes-are-un.patch create mode 100644 debian/patches/test-pull-bareuser.sh-This-test-uses-bare-user-hence-need.patch diff --git a/debian/changelog b/debian/changelog index dd4bdcbf..84ad56a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ ostree (2017.10-1) UNRELEASED; urgency=medium * Only run tests when building architecture-dependent packages. The tests aren't so interesting that we want to run them again when splitting -arch/-indep builds. + * Add patches to make the tests pass again when /var/tmp is on tmpfs, + which does not support user xattrs -- Simon McVittie Tue, 29 Aug 2017 16:08:09 +0100 diff --git a/debian/patches/basic-test-Skip-explicit-uses-of-bare-user-if-no-user-xat.patch b/debian/patches/basic-test-Skip-explicit-uses-of-bare-user-if-no-user-xat.patch new file mode 100644 index 00000000..01a11e36 --- /dev/null +++ b/debian/patches/basic-test-Skip-explicit-uses-of-bare-user-if-no-user-xat.patch @@ -0,0 +1,190 @@ +From: Simon McVittie +Date: Tue, 29 Aug 2017 17:02:43 +0100 +Subject: basic-test: Skip explicit uses of bare-user if no user xattrs + +Signed-off-by: Simon McVittie +--- + tests/basic-test.sh | 138 +++++++++++++++++++++++++++++----------------------- + 1 file changed, 77 insertions(+), 61 deletions(-) + +diff --git a/tests/basic-test.sh b/tests/basic-test.sh +index 9ae26f4..de4bd44 100644 +--- a/tests/basic-test.sh ++++ b/tests/basic-test.sh +@@ -106,19 +106,23 @@ echo "ok shortened checksum" + (cd repo && ${CMD_PREFIX} ostree rev-parse test2) + echo "ok repo-in-cwd" + +-rm test-repo -rf +-ostree_repo_init test-repo --mode=bare-user +-ostree_repo_init test-repo --mode=bare-user +-rm test-repo -rf +-echo "ok repo-init on existing repo" +- +-rm test-repo -rf +-ostree_repo_init test-repo --mode=bare-user +-${CMD_PREFIX} ostree --repo=test-repo refs +-rm -rf test-repo/tmp +-${CMD_PREFIX} ostree --repo=test-repo refs +-assert_has_dir test-repo/tmp +-echo "ok autocreate tmp" ++if ! skip_one_without_user_xattrs; then ++ rm test-repo -rf ++ ostree_repo_init test-repo --mode=bare-user ++ ostree_repo_init test-repo --mode=bare-user ++ rm test-repo -rf ++ echo "ok repo-init on existing repo" ++fi ++ ++if ! skip_one_without_user_xattrs; then ++ rm test-repo -rf ++ ostree_repo_init test-repo --mode=bare-user ++ ${CMD_PREFIX} ostree --repo=test-repo refs ++ rm -rf test-repo/tmp ++ ${CMD_PREFIX} ostree --repo=test-repo refs ++ assert_has_dir test-repo/tmp ++ echo "ok autocreate tmp" ++fi + + rm checkout-test2 -rf + $OSTREE checkout test2 checkout-test2 +@@ -262,27 +266,31 @@ cd ${test_tmpdir} + assert_file_has_content diff-test2-2 'M */four$' + echo "ok diff file changing type" + +-cd ${test_tmpdir} +-mkdir repo2 +-# Use a different mode to test hardlinking metadata only +-if grep -q 'mode=archive' repo/config || is_bare_user_only_repo repo; then +- opposite_mode=bare-user +-else +- opposite_mode=archive ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ mkdir repo2 ++ # Use a different mode to test hardlinking metadata only ++ if grep -q 'mode=archive' repo/config || is_bare_user_only_repo repo; then ++ opposite_mode=bare-user ++ else ++ opposite_mode=archive ++ fi ++ ostree_repo_init repo2 --mode=$opposite_mode ++ ${CMD_PREFIX} ostree --repo=repo2 pull-local repo ++ test2_commitid=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2) ++ test2_commit_relpath=/objects/${test2_commitid:0:2}/${test2_commitid:2}.commit ++ assert_files_hardlinked repo/${test2_commit_relpath} repo2/${test2_commit_relpath} ++ echo "ok pull-local (hardlinking metadata)" + fi +-ostree_repo_init repo2 --mode=$opposite_mode +-${CMD_PREFIX} ostree --repo=repo2 pull-local repo +-test2_commitid=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2) +-test2_commit_relpath=/objects/${test2_commitid:0:2}/${test2_commitid:2}.commit +-assert_files_hardlinked repo/${test2_commit_relpath} repo2/${test2_commit_relpath} +-echo "ok pull-local (hardlinking metadata)" + +-cd ${test_tmpdir} +-rm repo2 -rf && mkdir repo2 +-ostree_repo_init repo2 --mode=$opposite_mode +-${CMD_PREFIX} ostree --repo=repo2 pull-local --bareuseronly-files repo test2 +-${CMD_PREFIX} ostree --repo=repo2 fsck -q +-echo "ok pull-local --bareuseronly-files" ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ rm repo2 -rf && mkdir repo2 ++ ostree_repo_init repo2 --mode=$opposite_mode ++ ${CMD_PREFIX} ostree --repo=repo2 pull-local --bareuseronly-files repo test2 ++ ${CMD_PREFIX} ostree --repo=repo2 fsck -q ++ echo "ok pull-local --bareuseronly-files" ++fi + + # This is mostly a copy of the suid test in test-basic-user-only.sh, + # but for the `pull --bareuseronly-files` case. +@@ -303,11 +311,13 @@ fi + assert_file_has_content err.txt 'object.*\.file: invalid mode.*with bits 040.*' + echo "ok pull-local (bareuseronly files)" + +-cd ${test_tmpdir} +-${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone +-cd test2-checkout-from-local-clone +-assert_file_has_content yet/another/tree/green 'leaf' +-echo "ok local clone checkout" ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ ${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone ++ cd test2-checkout-from-local-clone ++ assert_file_has_content yet/another/tree/green 'leaf' ++ echo "ok local clone checkout" ++fi + + $OSTREE checkout -U test2 checkout-user-test2 + echo "ok user checkout" +@@ -496,24 +506,28 @@ cd ${test_tmpdir} + $OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null + echo "ok subdir noent" + +-cd ${test_tmpdir} +-mkdir repo3 +-ostree_repo_init repo3 --mode=bare-user +-${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2 +-${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2 +-echo "ok pull-local with --remote arg" ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ mkdir repo3 ++ ostree_repo_init repo3 --mode=bare-user ++ ${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2 ++ ${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2 ++ echo "ok pull-local with --remote arg" ++fi + +-cd ${test_tmpdir} +-${CMD_PREFIX} ostree --repo=repo3 prune +-find repo3/objects -name '*.commit' > objlist-before-prune +-rm repo3/refs/heads/* repo3/refs/mirrors/* repo3/refs/remotes/* -rf +-${CMD_PREFIX} ostree --repo=repo3 prune --refs-only +-find repo3/objects -name '*.commit' > objlist-after-prune +-if cmp -s objlist-before-prune objlist-after-prune; then +- fatal "Prune didn't delete anything!" ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ ${CMD_PREFIX} ostree --repo=repo3 prune ++ find repo3/objects -name '*.commit' > objlist-before-prune ++ rm repo3/refs/heads/* repo3/refs/mirrors/* repo3/refs/remotes/* -rf ++ ${CMD_PREFIX} ostree --repo=repo3 prune --refs-only ++ find repo3/objects -name '*.commit' > objlist-after-prune ++ if cmp -s objlist-before-prune objlist-after-prune; then ++ fatal "Prune didn't delete anything!" ++ fi ++ rm repo3 objlist-before-prune objlist-after-prune -rf ++ echo "ok prune" + fi +-rm repo3 objlist-before-prune objlist-after-prune -rf +-echo "ok prune" + + cd ${test_tmpdir} + rm repo3 -rf +@@ -597,14 +611,16 @@ $OSTREE show --print-detached-metadata-key=SIGNATURE test2 > test2-meta + assert_file_has_content test2-meta "HANCOCK" + echo "ok metadata commit with strings" + +-cd ${test_tmpdir} +-rm repo2 -rf +-mkdir repo2 +-ostree_repo_init repo2 --mode=bare-user +-${CMD_PREFIX} ostree --repo=repo2 pull-local repo +-${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta +-assert_file_has_content test2-meta "HANCOCK" +-echo "ok pull-local after commit metadata" ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ rm repo2 -rf ++ mkdir repo2 ++ ostree_repo_init repo2 --mode=bare-user ++ ${CMD_PREFIX} ostree --repo=repo2 pull-local repo ++ ${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta ++ assert_file_has_content test2-meta "HANCOCK" ++ echo "ok pull-local after commit metadata" ++fi + + cd ${test_tmpdir} + ${CMD_PREFIX} ostree --repo=repo remote --set=tls-permissive=true add aremote http://remote.example.com/repo testos/buildmaster/x86_64-runtime diff --git a/debian/patches/libtest-Allow-skipping-single-checks-without-user-xattrs.patch b/debian/patches/libtest-Allow-skipping-single-checks-without-user-xattrs.patch new file mode 100644 index 00000000..fa59fe63 --- /dev/null +++ b/debian/patches/libtest-Allow-skipping-single-checks-without-user-xattrs.patch @@ -0,0 +1,31 @@ +From: Simon McVittie +Date: Tue, 29 Aug 2017 17:02:18 +0100 +Subject: libtest: Allow skipping single checks without user xattrs + +Signed-off-by: Simon McVittie +--- + tests/libtest.sh | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/tests/libtest.sh b/tests/libtest.sh +index ff09650..7f334c0 100755 +--- a/tests/libtest.sh ++++ b/tests/libtest.sh +@@ -489,6 +489,17 @@ os_repository_new_commit () + cd ${test_tmpdir} + } + ++# Usage: if ! skip_one_without_user_xattrs; then ... more tests ...; fi ++skip_one_without_user_xattrs () { ++ touch test-xattrs ++ if ! setfattr -n user.testvalue -v somevalue test-xattrs; then ++ echo "ok # SKIP - this test requires xattr support" ++ return 0 ++ else ++ return 1 ++ fi ++} ++ + skip_without_user_xattrs () { + touch test-xattrs + setfattr -n user.testvalue -v somevalue test-xattrs || \ diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 00000000..a2c88e21 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,5 @@ +test-libarchive-import-Skip-if-extended-attributes-are-un.patch +test-pull-bareuser.sh-This-test-uses-bare-user-hence-need.patch +libtest-Allow-skipping-single-checks-without-user-xattrs.patch +basic-test-Skip-explicit-uses-of-bare-user-if-no-user-xat.patch +test-basic-user-only-Skip-final-step-if-no-user-xattrs.patch diff --git a/debian/patches/test-basic-user-only-Skip-final-step-if-no-user-xattrs.patch b/debian/patches/test-basic-user-only-Skip-final-step-if-no-user-xattrs.patch new file mode 100644 index 00000000..61a94315 --- /dev/null +++ b/debian/patches/test-basic-user-only-Skip-final-step-if-no-user-xattrs.patch @@ -0,0 +1,59 @@ +From: Simon McVittie +Date: Tue, 29 Aug 2017 17:03:37 +0100 +Subject: test-basic-user-only: Skip final step if no user xattrs + +We don't want to skip the entire test, because the whole point of +bare-user-only is that it works in the absence of xattrs; but we do +need to skip this last stage, which explicitly uses a bare-user +repository. + +Signed-off-by: Simon McVittie +--- + tests/test-basic-user-only.sh | 36 +++++++++++++++++++----------------- + 1 file changed, 19 insertions(+), 17 deletions(-) + +diff --git a/tests/test-basic-user-only.sh b/tests/test-basic-user-only.sh +index fb071fe..ce69e49 100755 +--- a/tests/test-basic-user-only.sh ++++ b/tests/test-basic-user-only.sh +@@ -72,21 +72,23 @@ $CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable di + assert_file_has_mode dir-co/worldwritable-dir 775 + echo "ok didn't make world-writable dir" + +-cd ${test_tmpdir} +-rm repo-input -rf +-rm repo -rf +-ostree_repo_init repo init --mode=bare-user-only +-ostree_repo_init repo-input init --mode=bare-user +-rm files -rf && mkdir files +-echo afile > files/afile +-ln -s afile files/afile-link +-$CMD_PREFIX ostree --repo=repo-input commit --canonical-permissions -b testtree --tree=dir=files +-afile_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile) +-afile_link_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile-link) +-$CMD_PREFIX ostree pull-local --repo=repo repo-input +-assert_files_hardlinked repo/${afile_relobjpath} repo-input/${afile_relobjpath} +-if files_are_hardlinked repo/${afile_link_relobjpath} repo-input/${afile_link_relobjpath}; then +- assert_not_reached "symlinks hardlinked across bare-user?" ++if ! skip_one_without_user_xattrs; then ++ cd ${test_tmpdir} ++ rm repo-input -rf ++ rm repo -rf ++ ostree_repo_init repo init --mode=bare-user-only ++ ostree_repo_init repo-input init --mode=bare-user ++ rm files -rf && mkdir files ++ echo afile > files/afile ++ ln -s afile files/afile-link ++ $CMD_PREFIX ostree --repo=repo-input commit --canonical-permissions -b testtree --tree=dir=files ++ afile_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile) ++ afile_link_relobjpath=$(ostree_file_path_to_relative_object_path repo-input testtree /afile-link) ++ $CMD_PREFIX ostree pull-local --repo=repo repo-input ++ assert_files_hardlinked repo/${afile_relobjpath} repo-input/${afile_relobjpath} ++ if files_are_hardlinked repo/${afile_link_relobjpath} repo-input/${afile_link_relobjpath}; then ++ assert_not_reached "symlinks hardlinked across bare-user?" ++ fi ++ $OSTREE fsck -q ++ echo "ok hardlink pull from bare-user" + fi +-$OSTREE fsck -q +-echo "ok hardlink pull from bare-user" diff --git a/debian/patches/test-libarchive-import-Skip-if-extended-attributes-are-un.patch b/debian/patches/test-libarchive-import-Skip-if-extended-attributes-are-un.patch new file mode 100644 index 00000000..bb340814 --- /dev/null +++ b/debian/patches/test-libarchive-import-Skip-if-extended-attributes-are-un.patch @@ -0,0 +1,142 @@ +From: Simon McVittie +Date: Tue, 29 Aug 2017 16:46:19 +0100 +Subject: test-libarchive-import: Skip if extended attributes are unsupported + +This is the case at build-time on some (all?) Debian autobuilders. + +Signed-off-by: Simon McVittie +--- + tests/test-libarchive-import.c | 57 +++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 56 insertions(+), 1 deletion(-) + +diff --git a/tests/test-libarchive-import.c b/tests/test-libarchive-import.c +index 8f884a6..6047d35 100644 +--- a/tests/test-libarchive-import.c ++++ b/tests/test-libarchive-import.c +@@ -35,6 +35,7 @@ typedef struct { + int fd; + int fd_empty; + char *tmpd; ++ GError *skip_all; + } TestData; + + static void +@@ -136,7 +137,13 @@ test_data_init (TestData *td) + g_assert_cmpint (0, ==, mkdir ("repo", 0755)); + + ostree_repo_create (td->repo, OSTREE_REPO_MODE_BARE_USER, NULL, &error); +- g_assert_no_error (error); ++ ++ /* G_IO_ERROR_NOT_SUPPORTED probably means no extended attribute support */ ++ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) ++ g_propagate_prefixed_error (&td->skip_all, g_steal_pointer (&error), ++ "Unable to set up repository: "); ++ else ++ g_assert_no_error (error); + } + } + +@@ -169,6 +176,12 @@ test_libarchive_noautocreate_empty (gconstpointer data) + OstreeRepoImportArchiveOptions opts = { 0, }; + glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new (); + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ return; ++ } ++ + test_archive_setup (td->fd_empty, a); + + (void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error); +@@ -185,6 +198,12 @@ test_libarchive_autocreate_empty (gconstpointer data) + OstreeRepoImportArchiveOptions opts = { 0, }; + glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new (); + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ return; ++ } ++ + opts.autocreate_parents = 1; + + test_archive_setup (td->fd_empty, a); +@@ -203,6 +222,12 @@ test_libarchive_error_device_file (gconstpointer data) + OstreeRepoImportArchiveOptions opts = { 0, }; + glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new (); + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ return; ++ } ++ + test_archive_setup (td->fd, a); + + (void)ostree_repo_import_archive_to_mtree (td->repo, &opts, a, mtree, NULL, NULL, &error); +@@ -276,6 +301,12 @@ test_libarchive_ignore_device_file (gconstpointer data) + if (skip_if_no_xattr (td)) + goto out; + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ goto out; ++ } ++ + test_archive_setup (td->fd, a); + + opts.ignore_unsupported_content = TRUE; +@@ -338,6 +369,12 @@ test_libarchive_ostree_convention (gconstpointer data) + if (skip_if_no_xattr (td)) + goto out; + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ goto out; ++ } ++ + test_archive_setup (td->fd, a); + + opts.autocreate_parents = TRUE; +@@ -382,6 +419,12 @@ test_libarchive_xattr_callback (gconstpointer data) + if (skip_if_no_xattr (td)) + goto out; + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ goto out; ++ } ++ + modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL); + ostree_repo_commit_modifier_set_xattr_callback (modifier, xattr_cb, + NULL, NULL); +@@ -437,6 +480,12 @@ entry_pathname_test_helper (gconstpointer data, gboolean on) + if (skip_if_no_xattr (td)) + goto out; + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ goto out; ++ } ++ + modifier = ostree_repo_commit_modifier_new (0, NULL, NULL, NULL); + ostree_repo_commit_modifier_set_xattr_callback (modifier, path_cb, + NULL, &met_etc_file); +@@ -500,6 +549,12 @@ test_libarchive_selinux (gconstpointer data) + if (skip_if_no_xattr (td)) + goto out; + ++ if (td->skip_all != NULL) ++ { ++ g_test_skip (td->skip_all->message); ++ goto out; ++ } ++ + { + glnx_unref_object GFile *root = g_file_new_for_path ("/"); + diff --git a/debian/patches/test-pull-bareuser.sh-This-test-uses-bare-user-hence-need.patch b/debian/patches/test-pull-bareuser.sh-This-test-uses-bare-user-hence-need.patch new file mode 100644 index 00000000..8a19bf49 --- /dev/null +++ b/debian/patches/test-pull-bareuser.sh-This-test-uses-bare-user-hence-need.patch @@ -0,0 +1,21 @@ +From: Simon McVittie +Date: Tue, 29 Aug 2017 17:01:41 +0100 +Subject: test-pull-bareuser.sh: This test uses bare-user, hence needs xattrs + +Signed-off-by: Simon McVittie +--- + tests/test-pull-bareuser.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/test-pull-bareuser.sh b/tests/test-pull-bareuser.sh +index 0729247..2e35723 100755 +--- a/tests/test-pull-bareuser.sh ++++ b/tests/test-pull-bareuser.sh +@@ -21,6 +21,7 @@ set -euo pipefail + + . $(dirname $0)/libtest.sh + ++skip_without_user_xattrs + setup_fake_remote_repo1 "archive" + + repo_mode=bare-user