New upstream version 2021.1

This commit is contained in:
Simon McVittie committed 2021-04-14 12:52:43 +01:00
commit 1c67002e63
82 files changed
+4382 -4088

No files matched your search

+7 -1
View File
@@ -65,6 +65,12 @@ assert_not_file_has_content status.txt "pending"
assert_not_file_has_content status.txt "rollback"
validate_bootloader
# Test the bootable and linux keys
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo --print-metadata-key=ostree.linux show testos:testos/buildmaster/x86_64-runtime >out.txt
assert_file_has_content_literal out.txt 3.6.0
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo --print-metadata-key=ostree.bootable show testos:testos/buildmaster/x86_64-runtime >out.txt
assert_file_has_content_literal out.txt true
echo "ok deploy command"
${CMD_PREFIX} ostree admin --print-current-dir > curdir
@@ -89,7 +95,7 @@ echo "ok layout"
if ${CMD_PREFIX} ostree admin deploy --stage --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
fatal "staged when not booted"
fi
assert_file_has_content_literal err.txt "Cannot stage a deployment when not currently booted into an OSTree system"
assert_file_has_content_literal err.txt "Cannot stage deployment: Not currently booted into an OSTree system"
echo "ok staging does not work when not booted"
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
+8 -1
View File
@@ -21,7 +21,7 @@
set -euo pipefail
echo "1..$((86 + ${extra_basic_tests:-0}))"
echo "1..$((87 + ${extra_basic_tests:-0}))"
CHECKOUT_U_ARG=""
CHECKOUT_H_ARGS="-H"
@@ -226,6 +226,13 @@ $OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' --parent=none $test_tmpdi
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
echo "ok commit no parent"
cd ${test_tmpdir}
if $OSTREE commit ${COMMIT_ARGS} -b test-bootable --bootable $test_tmpdir/checkout-test2-4 2>err.txt; then
fatal "committed non-bootable tree"
fi
assert_file_has_content err.txt "error: .*No such file or directory"
echo "ok commit fails bootable if no kernel"
cd ${test_tmpdir}
# Do the --bind-ref=<the other test branch>, so we store both branches sorted
# in metadata and thus the checksums remain the same.
+9 -3
View File
@@ -147,6 +147,9 @@ fi
# This is substituted by the build for installed tests
BUILT_WITH_ASAN=""
if test -n "${ASAN_OPTIONS:-}"; then
BUILT_WITH_ASAN=1
fi
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"
@@ -412,11 +415,14 @@ setup_os_repository () {
echo "an hmac file" > ${hmac_path}
bootcsum=$(cat ${kernel_path} ${initramfs_path} | sha256sum | cut -f 1 -d ' ')
export bootcsum
bootable_flag=""
# Add the checksum for legacy dirs (/boot, /usr/lib/ostree-boot), but not
# /usr/lib/modules.
if [[ $bootdir != usr/lib/modules/* ]]; then
mv ${kernel_path}{,-${bootcsum}}
mv ${initramfs_path}{,-${bootcsum}}
else
bootable_flag="--bootable"
fi
echo "an executable" > usr/bin/sh
@@ -436,12 +442,12 @@ EOF
mkdir -p usr/etc/testdirectory
echo "a default daemon file" > usr/etc/testdirectory/test
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.9 -b testos/buildmaster/x86_64-runtime -s "Build"
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit ${bootable_flag} --add-metadata-string version=1.0.9 -b testos/buildmaster/x86_64-runtime -s "Build"
# Ensure these commits have distinct second timestamps
sleep 2
echo "a new executable" > usr/bin/sh
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.10 -b testos/buildmaster/x86_64-runtime -s "Build"
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit ${bootable_flag} --add-metadata-string version=1.0.10 -b testos/buildmaster/x86_64-runtime -s "Build"
cd ${test_tmpdir}
rm -rf osdata-devel
@@ -450,7 +456,7 @@ EOF
cd osdata-devel
mkdir -p usr/include
echo "a development header" > usr/include/foo.h
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.9 -b testos/buildmaster/x86_64-devel -s "Build"
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit ${bootable_flag} --add-metadata-string version=1.0.9 -b testos/buildmaster/x86_64-devel -s "Build"
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo fsck -q
+89
View File
@@ -95,6 +95,9 @@ test_data_init (TestData *td)
archive_entry_set_uid (ae, uid);
archive_entry_set_gid (ae, gid);
archive_entry_set_size (ae, 4);
archive_entry_xattr_add_entry (ae, "user.a_key", "my value", 8);
archive_entry_xattr_add_entry (ae, "user.key2", "", 0);
archive_entry_xattr_add_entry (ae, "user.b_key", "contains\0nuls", 14);
g_assert_cmpint (0, ==, archive_write_header (a, ae));
g_assert_cmpint (4, ==, archive_write_data (a, "bar\n", 4));
archive_entry_free (ae);
@@ -453,6 +456,90 @@ test_libarchive_xattr_callback (gconstpointer data)
g_assert_no_error (error);
}
static void
test_libarchive_xattr_import (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
char buf[15] = { 0 };
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;
if (!import_write_and_ref (td->repo, &opts, a, "baz", NULL, &error))
goto out;
/* check contents */
if (!spawn_cmdline ("ostree --repo=repo checkout baz import-checkout", NULL))
goto out;
spawn_cmdline ("ostree --repo=repo ls -R -X baz", NULL);
spawn_cmdline ("attr -l import-checkout/anotherfile", NULL);
ssize_t x = getxattr ("import-checkout/anotherfile", "user.a_key", buf, sizeof buf - 1);
g_assert_cmpint (x, ==, 8);
g_assert_cmpstr (buf, ==, "my value");
x = getxattr ("import-checkout/anotherfile", "user.key2", buf, sizeof buf - 1);
g_assert_cmpint (x, ==, 0);
x = getxattr ("import-checkout/anotherfile", "user.b_key", buf, sizeof buf - 1);
g_assert_cmpint (x, ==, 14);
g_assert (memcmp(buf, "contains\0nuls", 14) == 0);
out:
g_assert_no_error (error);
}
static void
test_libarchive_xattr_import_skip_xattr (gconstpointer data)
{
TestData *td = (void*)data;
GError *error = NULL;
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
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;
g_autoptr(OstreeRepoCommitModifier) modifier = ostree_repo_commit_modifier_new (
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS, NULL, NULL, NULL);
if (!import_write_and_ref (td->repo, &opts, a, "baz", modifier, &error))
goto out;
/* check contents */
if (!spawn_cmdline ("ostree --repo=repo checkout baz import-checkout", NULL))
goto out;
ssize_t n_attrs = listxattr ("import-checkout/anotherfile", NULL, 0);
g_assert_cmpint (n_attrs, ==, 0);
out:
g_assert_no_error (error);
}
static GVariant*
path_cb (OstreeRepo *repo,
const char *path,
@@ -610,6 +697,8 @@ int main (int argc, char **argv)
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-import", &td, test_libarchive_xattr_import);
g_test_add_data_func ("/libarchive/xattr-import-skip-xattr", &td, test_libarchive_xattr_import_skip_xattr);
g_test_add_data_func ("/libarchive/xattr-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);
+33 -1
View File
@@ -25,7 +25,7 @@ set -euo pipefail
setup_test_repository "archive"
echo "1..1"
echo "1..3"
cd ${test_tmpdir}
mkdir repo2
@@ -62,3 +62,35 @@ find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
echo "ok local pull depth"
# Check that pulling with depth != 0 succeeds with a missing parent
# commit. Prune the remote to truncate the history.
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo prune --refs-only --depth=0
rm -rf repo2/refs/heads/* repo2/refs/remotes/* repo2/objects/*/*.commit
${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=1 repo
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^1$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
rm -rf repo2/refs/heads/* repo2/refs/remotes/* repo2/objects/*/*.commit
${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=-1 repo
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^1$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
echo "ok local pull depth missing parent"
# Check that it errors if the ref head commit is missing.
cd ${test_tmpdir}
rm -f repo/objects/*/*.commit
rm -rf repo2/refs/heads/* repo2/refs/remotes/* repo2/objects/*/*.commit
if ${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=-1 repo; then
fatal "Local pull with depth -1 succeeded with missing HEAD commit"
fi
echo "ok local pull depth missing HEAD commit"
+10 -2
View File
@@ -117,7 +117,7 @@ do_pull() {
local branch=$3
shift 3
if ${CMD_PREFIX} ostree "--repo=${repo}" pull "${remote_repo}-remote" "${branch}"
if ${CMD_PREFIX} ostree "--repo=${repo}" pull "$@" "${remote_repo}-remote" "${branch}"
then return 0
else return 1
fi
@@ -129,7 +129,7 @@ do_local_pull() {
local branch=$3
shift 3
if ${CMD_PREFIX} ostree "--repo=${repo}" pull-local "${remote_repo}" "${branch}"
if ${CMD_PREFIX} ostree "--repo=${repo}" pull-local "$@" "${remote_repo}" "${branch}"
then return 0
else return 1
fi
@@ -221,19 +221,23 @@ if do_pull local collection-repo badcref1
then
assert_not_reached "pulling a commit without collection ID from a repo with collection ID should fail"
fi
do_pull local collection-repo badcref1 --disable-verify-bindings
if do_pull local collection-repo badcref2
then
assert_not_reached "pulling a commit with a mismatched collection ID from a repo with collection ID should fail"
fi
do_pull local collection-repo badcref2 --disable-verify-bindings
if do_pull local collection-repo badcref3
then
assert_not_reached "pulling a commit with empty collection ID from repo with collection ID should fail"
fi
do_pull local collection-repo badcref3 --disable-verify-bindings
do_pull local collection-repo goodcref1
if do_pull local collection-repo badcref4
then
assert_not_reached "pulling a commit that was not requested from repo with collection ID should fail"
fi
do_pull local collection-repo badcref4 --disable-verify-bindings
echo "ok 5 pull refs from remote repos"
@@ -243,19 +247,23 @@ if do_local_pull local collection-local-repo badclref1
then
assert_not_reached "pulling a commit without collection ID from a repo with collection ID should fail"
fi
do_local_pull local collection-local-repo badclref1 --disable-verify-bindings
if do_local_pull local collection-local-repo badclref2
then
assert_not_reached "pulling a commit with a mismatched collection ID from a repo with collection ID should fail"
fi
do_local_pull local collection-local-repo badclref2 --disable-verify-bindings
if do_local_pull local collection-local-repo badclref3
then
assert_not_reached "pulling a commit with empty collection ID from repo with collection ID should fail"
fi
do_local_pull local collection-local-repo badclref3 --disable-verify-bindings
do_local_pull local collection-local-repo goodclref1
if do_local_pull local collection-local-repo badclref4
then
assert_not_reached "pulling a commit that was not requested from repo with collection ID should fail"
fi
do_local_pull local collection-local-repo badclref4 --disable-verify-bindings
echo "ok 6 pull refs from local repos"
+43 -1
View File
@@ -25,7 +25,7 @@ set -euo pipefail
setup_fake_remote_repo1 "archive"
echo '1..1'
echo '1..3'
cd ${test_tmpdir}
mkdir repo
@@ -35,21 +35,63 @@ ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat
${CMD_PREFIX} ostree --repo=repo pull --depth=0 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^1$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
${CMD_PREFIX} ostree --repo=repo pull --depth=0 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^1$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
${CMD_PREFIX} ostree --repo=repo pull --depth=1 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^2$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
${CMD_PREFIX} ostree --repo=repo pull --depth=1 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^2$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
${CMD_PREFIX} ostree --repo=repo pull --depth=-1 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^3$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
echo "ok pull depth"
# Check that pulling with depth != 0 succeeds with a missing parent
# commit. Prune the remote to truncate the history.
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo prune --refs-only --depth=0
rm -rf repo/refs/heads/* repo/refs/remotes/* repo/objects/*/*.commit
${CMD_PREFIX} ostree --repo=repo pull --depth=1 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^1$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
rm -rf repo/refs/heads/* repo/refs/remotes/* repo/objects/*/*.commit
${CMD_PREFIX} ostree --repo=repo pull --depth=-1 origin main
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount "^1$"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount "^0$"
echo "ok pull depth missing parent"
# Check that it errors if the ref head commit is missing.
cd ${test_tmpdir}
rm -f ostree-srv/gnomerepo/objects/*/*.commit
rm -rf repo/refs/heads/* repo/refs/remotes/* repo/objects/*/*.commit
if ${CMD_PREFIX} ostree --repo=repo pull --depth=-1 origin main; then
fatal "Pull with depth -1 succeeded with missing HEAD commit"
fi
echo "ok pull depth missing HEAD commit"
+12
View File
@@ -175,6 +175,8 @@ cd ${test_tmpdir}
# Reset to the old valid summary and pull to cache it
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
touch -t 200101010101 ${test_tmpdir}/ostree-srv/gnomerepo/summary
touch -t 200101010101 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
repo_reinit
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
@@ -186,6 +188,7 @@ cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summ
# summary signature since it was generated on the server between the
# requests
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
touch -t 200202020202 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
if ${OSTREE} --repo=repo pull origin main 2>err.txt; then
assert_not_reached "Successful pull with old summary"
fi
@@ -197,6 +200,7 @@ cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summ
# Publish correct summary and check that subsequent pull succeeds
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
touch -t 200202020202 ${test_tmpdir}/ostree-srv/gnomerepo/summary
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
@@ -208,6 +212,8 @@ echo "ok pull with signed summary remote old summary"
# Reset to the old valid summary and pull to cache it
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
touch -t 200101010101 ${test_tmpdir}/ostree-srv/gnomerepo/summary
touch -t 200101010101 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
repo_reinit
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
@@ -220,6 +226,7 @@ cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summ
# is caching the old signature. This should succeed because the cached
# old summary is used.
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
touch -t 200202020202 ${test_tmpdir}/ostree-srv/gnomerepo/summary
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
@@ -228,6 +235,7 @@ cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summ
# Publish correct signature and check that subsequent pull succeeds
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
touch -t 200202020202 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
@@ -239,6 +247,8 @@ echo "ok pull with signed summary remote old summary signature"
# Reset to the old valid summary and pull to cache it
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
touch -t 200101010101 ${test_tmpdir}/ostree-srv/gnomerepo/summary
touch -t 200101010101 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
repo_reinit
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
@@ -273,6 +283,8 @@ cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summ
# Publish new signature and check that subsequent pull succeeds
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
touch -t 200202020202 ${test_tmpdir}/ostree-srv/gnomerepo/summary
touch -t 200202020202 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
${OSTREE} --repo=repo pull origin main
assert_has_file repo/tmp/cache/summaries/origin
assert_has_file repo/tmp/cache/summaries/origin.sig
+1 -1
View File
@@ -66,7 +66,7 @@ echo 'ok documented symbols'
# ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF
3e677623543b7fdc57b0e3d9c66eb477105b014411259762a328c1b5e82068f0 ${released_syms}
07a58e073b075b0c1c9862846dba2bb177d121bbbf503d960b30ede27aef30eb ${released_syms}
EOF
sha256sum -c released-sha256.txt