New upstream version 2017.7

This commit is contained in:
Simon McVittie committed 2017-06-21 09:51:58 +01:00
commit 19f82ee114
127 files changed
+3512 -2635

No files matched your search

+2
View File
@@ -42,6 +42,8 @@ ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos
new_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
assert_not_streq "${orig_mtime}" "${new_mtime}"
${CMD_PREFIX} ostree admin status | tee status.txt
assert_not_file_has_content status.txt "pending"
assert_not_file_has_content status.txt "rollback"
validate_bootloader
echo "ok deploy command"
+96 -7
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..66"
echo "1..$((69 + ${extra_basic_tests:-0}))"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
@@ -28,7 +28,7 @@ echo "ok yaml version"
CHECKOUT_U_ARG=""
COMMIT_ARGS=""
DIFF_ARGS=""
if grep -q bare-user-only repo/config; then
if is_bare_user_only_repo repo; then
# In bare-user-only repos we can only represent files with uid/gid 0, no
# xattrs and canonical permissions, so we need to commit them as such, or
# we end up with repos that don't pass fsck
@@ -66,7 +66,7 @@ validate_checkout_basic checkout-test2
rm checkout-test2 -rf
# Only do these tests on bare-user/bare, not bare-user-only
# since the latter automatically synthesizes -U if it's not passed.
if ! grep -q bare-user-only repo/config; then
if ! is_bare_user_only_repo repo; then
if grep -q bare-user repo/config; then
if $OSTREE checkout -H test2 checkout-test2 2>err.txt; then
assert_not_reached "checkout -H worked?"
@@ -254,9 +254,44 @@ echo "ok diff file changing type"
cd ${test_tmpdir}
mkdir repo2
ostree_repo_init repo2 --mode=bare-user
# 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
echo "ok pull-local"
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"
# This is mostly a copy of the suid test in test-basic-user-only.sh,
# but for the `pull --bareuseronly-files` case.
cd ${test_tmpdir}
rm repo-input -rf
ostree_repo_init repo-input init --mode=archive
cd ${test_tmpdir}
cat > statoverride.txt <<EOF
2048 /some-setuid
EOF
mkdir -p files/
echo "a setuid file" > files/some-setuid
chmod 0644 files/some-setuid
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-suid --statoverride=statoverride.txt --tree=dir=files
if $CMD_PREFIX ostree pull-local --repo=repo --bareuseronly-files repo-input content-with-suid 2>err.txt; then
assert_not_reached "copying suid file with --bareuseronly-files worked?"
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
@@ -312,8 +347,13 @@ cd ${test_tmpdir}/checkout-test2-4
$OSTREE commit ${COMMIT_ARGS} -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
if ! is_bare_user_only_repo repo; then
test -g checkout-test2-override/a/nested/2
test -u checkout-test2-override/a/nested/3
else
test '!' -g checkout-test2-override/a/nested/2
test '!' -u checkout-test2-override/a/nested/3
fi
echo "ok commit statoverride"
cd ${test_tmpdir}
@@ -333,8 +373,30 @@ $OSTREE prune
echo "ok prune didn't fail"
cd ${test_tmpdir}
# Verify we can't cat dirs
for path in / /baz; do
if $OSTREE cat test2 $path 2>err.txt; then
assert_not_reached "cat directory"
fi
assert_file_has_content err.txt "open directory"
done
rm checkout-test2 -rf
$OSTREE cat test2 /yet/another/tree/green > greenfile-contents
assert_file_has_content greenfile-contents "leaf"
$OSTREE checkout test2 checkout-test2
ls -alR checkout-test2
ln -sr checkout-test2/{four,four-link}
ln -sr checkout-test2/{baz/cow,cow-link}
ln -sr checkout-test2/{cow-link,cow-link-link}
$OSTREE commit -b test2-withlink --tree=dir=checkout-test2
if $OSTREE cat test2-withlink /four-link 2>err.txt; then
assert_not_reached "cat directory"
fi
assert_file_has_content err.txt "open directory"
for path in /cow-link /cow-link-link; do
$OSTREE cat test2-withlink $path >contents.txt
assert_file_has_content contents.txt moo
done
echo "ok cat-file"
cd ${test_tmpdir}
@@ -383,6 +445,22 @@ assert_file_has_content checkout-test-union-add/union-add-test 'existing file fo
assert_file_has_content checkout-test-union-add/union-add-test2 'another file for union add testing'
echo "ok checkout union add"
cd ${test_tmpdir}
rm files -rf && mkdir files
mkdir files/worldwritable-dir
chmod a+w files/worldwritable-dir
$CMD_PREFIX ostree --repo=repo commit -b content-with-dir-world-writable --tree=dir=files
rm dir-co -rf
$CMD_PREFIX ostree --repo=repo checkout -U -H -M content-with-dir-world-writable dir-co
assert_file_has_mode dir-co/worldwritable-dir 775
if ! is_bare_user_only_repo repo; then
rm dir-co -rf
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
assert_file_has_mode dir-co/worldwritable-dir 777
fi
rm dir-co -rf
echo "ok checkout bareuseronly dir"
cd ${test_tmpdir}
rm -rf shadow-repo
mkdir shadow-repo
@@ -566,6 +644,17 @@ rm test2-checkout -rf
${CMD_PREFIX} ostree --repo=repo2 checkout -U test2 test2-checkout
assert_file_has_content test2-checkout/baz/cow moo
assert_has_dir repo2/uncompressed-objects-cache
ls repo2/uncompressed-objects-cache > ls.txt
if ! test -s ls.txt; then
assert_not_reached "repo didn't cache uncompressed objects"
fi
# we're in archive mode, but the repo we pull-local from might be
# bare-user-only, in which case, we skip these checks since bare-user-only
# doesn't store permission bits
if ! is_bare_user_only_repo repo; then
assert_file_has_mode test2-checkout/baz/cowro 600
assert_file_has_mode test2-checkout/baz/deeper/ohyeahx 755
fi
echo "ok disable cache checkout"
cd ${test_tmpdir}
+41 -20
View File
@@ -1,4 +1,8 @@
# Core source library for shell script tests
# Core source library for shell script tests; this
# file is intended to be the canonical source, which at
# is copied at least into:
#
# - https://github.com/projectatomic/rpm-ostree
#
# Copyright (C) 2017 Colin Walters <walters@verbum.org>
#
@@ -36,6 +40,7 @@ fi
# This should really be the default IMO
export G_DEBUG=fatal-warnings
assert_streq () {
test "$1" = "$2" || fatal "$1 != $2"
}
@@ -58,18 +63,29 @@ assert_has_dir () {
test -d "$1" || fatal "Couldn't find '$1'"
}
# Dump ls -al + file contents to stderr, then fatal()
_fatal_print_file() {
file="$1"
shift
ls -al "$file" >&2
sed -e 's/^/# /' < "$file" >&2
fatal "$@"
}
assert_not_has_file () {
if test -f "$1"; then
sed -e 's/^/# /' < "$1" >&2
fatal "File '$1' exists"
_fatal_print_file "$1" "File '$1' exists"
fi
}
assert_not_file_has_content () {
if grep -q -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
fatal "File '$1' incorrectly matches regexp '$2'"
fi
fpath=$1
shift
for re in "$@"; do
if grep -q -e "$re" "$fpath"; then
_fatal_print_file "$fpath" "File '$fpath' matches regexp '$re'"
fi
done
}
assert_not_has_dir () {
@@ -79,35 +95,40 @@ assert_not_has_dir () {
}
assert_file_has_content () {
if ! grep -q -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
fatal "File '$1' doesn't match regexp '$2'"
fi
fpath=$1
shift
for re in "$@"; do
if ! grep -q -e "$re" "$fpath"; then
_fatal_print_file "$fpath" "File '$fpath' doesn't match regexp '$re'"
fi
done
}
assert_file_has_content_literal () {
if ! grep -q -F -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
fatal "File '$1' doesn't match fixed string list '$2'"
_fatal_print_file "$1" "File '$1' doesn't match fixed string list '$2'"
fi
}
assert_file_has_mode () {
mode=$(stat -c '%a' $1)
if [ "$mode" != "$2" ]; then
fatal "File '$1' has wrong mode: expected $2, but got $mode"
fi
}
assert_symlink_has_content () {
if ! test -L "$1"; then
echo 1>&2 "File '$1' is not a symbolic link"
exit 1
fatal "File '$1' is not a symbolic link"
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
_fatal_print_file "$1" "Symbolic link '$1' doesn't match regexp '$2'"
fi
}
assert_file_empty() {
if test -s "$1"; then
sed -e 's/^/# /' < "$1" >&2
fatal "File '$1' is not empty"
_fatal_print_file "$1" "File '$1' is not empty"
fi
}
+45 -2
View File
@@ -116,10 +116,16 @@ else
fi
fi
files_are_hardlinked() {
f1=$(stat -c %i $1)
f2=$(stat -c %i $2)
[ "$f1" == "$f2" ]
}
assert_files_hardlinked() {
f1=$(stat -c %i $1)
f2=$(stat -c %i $2)
if [ "$f1" != "$f2" ]; then
if ! files_are_hardlinked "$f1" "$f2"; then
fatal "Files '$1' and '$2' are not hardlinked"
fi
}
@@ -157,9 +163,13 @@ setup_test_repository () {
mkdir baz
echo moo > baz/cow
echo mooro > baz/cowro
chmod 600 baz/cowro
echo alien > baz/saucer
mkdir baz/deeper
echo hi > baz/deeper/ohyeah
echo hix > baz/deeper/ohyeahx
chmod 755 baz/deeper/ohyeahx
ln -s nonexistent baz/alink
mkdir baz/another/
echo x > baz/another/y
@@ -446,6 +456,7 @@ os_repository_new_commit ()
{
boot_checksum_iteration=${1:-0}
content_iteration=${2:-0}
branch=${3:-testos/buildmaster/x86_64-runtime}
echo "BOOT ITERATION: $boot_checksum_iteration"
cd ${test_tmpdir}/osdata
rm boot/*
@@ -464,7 +475,7 @@ os_repository_new_commit ()
version=$(date "+%Y%m%d.${content_iteration}")
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" -b testos/buildmaster/x86_64-runtime -s "Build"
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" -b $branch -s "Build"
cd ${test_tmpdir}
}
@@ -494,3 +505,35 @@ has_gpgme () {
libtest_cleanup_gpg () {
gpg-connect-agent --homedir ${test_tmpdir}/gpghome killagent /bye || true
}
is_bare_user_only_repo () {
grep -q 'mode=bare-user-only' $1/config
}
# Given a path to a file in a repo for a ref, print its checksum
ostree_file_path_to_checksum() {
repo=$1
ref=$2
path=$3
$CMD_PREFIX ostree --repo=$repo ls -C $ref $path | awk '{ print $5 }'
}
# Given a path to a file in a repo for a ref, print the (relative) path to its
# object
ostree_file_path_to_relative_object_path() {
repo=$1
ref=$2
path=$3
checksum=$(ostree_file_path_to_checksum $repo $ref $path)
test -n "${checksum}"
echo objects/${checksum:0:2}/${checksum:2}.file
}
# Given a path to a file in a repo for a ref, print the path to its object
ostree_file_path_to_object_path() {
repo=$1
ref=$2
path=$3
relpath=$(ostree_file_path_to_relative_object_path $repo $ref $path)
echo ${repo}/${relpath}
}
+108 -11
View File
@@ -24,7 +24,7 @@ function repo_init() {
rm repo -rf
mkdir repo
ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo "$@"
}
function verify_initial_contents() {
@@ -35,10 +35,10 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
echo "1..16"
echo "1..25"
# Try both syntaxes
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main
${CMD_PREFIX} ostree --repo=repo pull origin:main
${CMD_PREFIX} ostree --repo=repo fsck
@@ -57,6 +57,33 @@ ${CMD_PREFIX} ostree --repo=mirrorrepo fsck
$OSTREE show main >/dev/null
echo "ok pull mirror"
mkdir otherbranch
echo someothercontent > otherbranch/someothercontent
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit -b otherbranch --tree=dir=otherbranch
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
rm mirrorrepo -rf
# All refs
ostree_repo_init mirrorrepo --mode=archive-z2
${CMD_PREFIX} ostree --repo=mirrorrepo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror origin
${CMD_PREFIX} ostree --repo=mirrorrepo fsck
for ref in main otherbranch; do
${CMD_PREFIX} ostree --repo=mirrorrepo rev-parse $ref
done
echo "ok pull mirror (all refs)"
rm mirrorrepo -rf
ostree_repo_init mirrorrepo --mode=archive-z2
${CMD_PREFIX} ostree --repo=mirrorrepo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
# Generate a summary in the mirror
${CMD_PREFIX} ostree --repo=mirrorrepo summary -u
summarysig=$(sha256sum < mirrorrepo/summary | cut -f 1 -d ' ')
# Mirror subset of refs: https://github.com/ostreedev/ostree/issues/846
${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror origin main
newsummarysig=$(sha256sum < mirrorrepo/summary | cut -f 1 -d ' ')
assert_streq ${summarysig} ${newsummarysig}
echo "ok pull mirror (ref subset with summary)"
cd ${test_tmpdir}
rm checkout-origin-main -rf
$OSTREE --repo=ostree-srv/gnomerepo checkout main checkout-origin-main
@@ -79,6 +106,35 @@ ${CMD_PREFIX} ostree --repo=mirrorrepo pull origin main
${CMD_PREFIX} ostree --repo=mirrorrepo fsck
echo "ok pull (refuses deltas)"
cd ${test_tmpdir}
rm mirrorrepo/refs/remotes/* -rf
${CMD_PREFIX} ostree --repo=mirrorrepo prune --refs-only
${CMD_PREFIX} ostree --repo=mirrorrepo pull --bareuseronly-files origin main
echo "ok pull (bareuseronly, safe)"
rm checkout-origin-main -rf
$OSTREE --repo=ostree-srv/gnomerepo checkout main checkout-origin-main
cat > statoverride.txt <<EOF
2048 /some-setuid
EOF
echo asetuid > checkout-origin-main/some-setuid
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit -b content-with-suid --statoverride=statoverride.txt --tree=dir=checkout-origin-main
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
# Verify we reject it both when unpacking and when mirroring
for flag in "" "--mirror"; do
if ${CMD_PREFIX} ostree --repo=mirrorrepo pull ${flag} --bareuseronly-files origin content-with-suid 2>err.txt; then
assert_not_reached "pulled unsafe bareuseronly"
fi
assert_file_has_content err.txt 'object.*\.file: invalid mode.*with bits 040.*'
done
echo "ok pull (bareuseronly, unsafe)"
cd ${test_tmpdir}
rm mirrorrepo/refs/remotes/* -rf
${CMD_PREFIX} ostree --repo=mirrorrepo prune --refs-only
${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror --bareuseronly-files origin main
echo "ok pull (bareuseronly mirror)"
cd ${test_tmpdir}
rm mirrorrepo/refs/remotes/* -rf
${CMD_PREFIX} ostree --repo=mirrorrepo prune --refs-only
@@ -128,7 +184,7 @@ assert_file_has_content main.txt ${rev}
echo "ok pull specific commit"
cd ${test_tmpdir}
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main
${CMD_PREFIX} ostree --repo=repo fsck
# Generate a delta from old to current, even though we aren't going to
@@ -153,7 +209,7 @@ ${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
# Explicitly test delta fetches via ref name as well as commit hash
for delta_target in main ${new_rev}; do
cd ${test_tmpdir}
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
${CMD_PREFIX} ostree --repo=repo pull --dry-run --require-static-deltas origin ${delta_target} >dry-run-pull.txt
# Compression can vary, so we support 400-699
@@ -166,7 +222,7 @@ done
# Explicitly test delta fetches via ref name as well as commit hash
for delta_target in main ${new_rev}; do
cd ${test_tmpdir}
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin ${delta_target}
if test ${delta_target} = main; then
@@ -179,7 +235,7 @@ ${CMD_PREFIX} ostree --repo=repo fsck
done
cd ${test_tmpdir}
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
${CMD_PREFIX} ostree --repo=repo pull --disable-static-deltas origin main
${CMD_PREFIX} ostree --repo=repo fsck
@@ -197,7 +253,7 @@ cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo static-delta generate --swap-endianness main
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas --dry-run origin main >byteswapped-dry-run-pull.txt
${CMD_PREFIX} ostree --repo=repo fsck
@@ -211,7 +267,7 @@ echo "ok pull byteswapped delta"
cd ${test_tmpdir}
rm ostree-srv/gnomerepo/deltas -rf
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
repo_init
repo_init --no-gpg-verify
if ${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin main 2>err.txt; then
assert_not_reached "--require-static-deltas unexpectedly succeeded"
fi
@@ -219,7 +275,7 @@ assert_file_has_content err.txt "deltas required, but none found"
${CMD_PREFIX} ostree --repo=repo fsck
# Now test with a partial commit
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull --commit-metadata-only origin main@${prev_rev}
if ${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin main 2>err.txt; then
assert_not_reached "--require-static-deltas unexpectedly succeeded"
@@ -227,7 +283,7 @@ fi
assert_file_has_content err.txt "deltas required, but none found"
echo "ok delta required but don't exist"
repo_init
repo_init --no-gpg-verify
${CMD_PREFIX} ostree --repo=repo pull origin main@${prev_rev}
if ${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin ${new_rev} 2>err.txt; then
assert_not_reached "--require-static-deltas unexpectedly succeeded"
@@ -294,3 +350,44 @@ fi
assert_file_has_content err.txt "ONE BILLION DOLLARS"
echo "ok unconfigured"
cd ${test_tmpdir}
repo_init
${CMD_PREFIX} ostree --repo=repo remote add origin-bad $(cat httpd-address)/ostree/noent
if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin-bad main 2>err.txt; then
assert_not_reached "pull repo 404 succeeded?"
fi
assert_file_has_content err.txt "404"
echo "ok pull repo 404"
cd ${test_tmpdir}
repo_init --set=gpg-verify=true
if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main 2>err.txt; then
assert_not_reached "pull repo 404 succeeded?"
fi
assert_file_has_content err.txt "GPG verification enabled, but no signatures found"
echo "ok pull repo 404 (gpg)"
cd ${test_tmpdir}
repo_init --set=gpg-verify=true
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit \
--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} -b main \
-s "A signed commit" --tree=ref=main
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u
# make sure gpg verification is correctly on
csum=$(${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo rev-parse main)
objpath=objects/${csum::2}/${csum:2}.commitmeta
remotesig=ostree-srv/gnomerepo/$objpath
localsig=repo/$objpath
mv $remotesig $remotesig.bak
if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main; then
assert_not_reached "pull with gpg-verify unexpectedly succeeded?"
fi
# ok now check that we can pull correctly
mv $remotesig.bak $remotesig
${CMD_PREFIX} ostree --repo=repo pull origin main
echo "ok pull signed commit"
rm $localsig
${CMD_PREFIX} ostree --repo=repo pull origin main
test -f $localsig
echo "ok re-pull signature for stored commit"
+72
View File
@@ -0,0 +1,72 @@
#!/bin/bash
#
# Copyright (C) 2014 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"
# This does:
# - init ostree repo in testos-repo
# - create system files in osdata and commit twice those contents into testos-repo
# - copy osdata to osdata-devel and make another change then commit
# - create sysroot with init-fs and os-init and syslinux
# sysroot has /ostree basics (but no contents), syslinux cfg and empty root dirs
echo "1..3"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
echo "rev=${rev}"
# Now sysroot/ostree has the objects from the testos-repo (obtained over http
# and kept in remote "testos"), but there is no deployment
# This initial deployment gets kicked off with some kernel arguments
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
echo "ok deploy"
# Create a new branch which we want to migrate to
os_repository_new_commit 1 1 testos/buildmaster/newbranch
# bootcsum now refers to this new commit
# Create a new commit with an empty tree, which marks the original branch as
# EOL, redirecting to the new one.
mkdir empty
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=$(pwd)/empty --add-metadata-string "ostree.endoflife=Product discontinued" --add-metadata-string "ostree.endoflife-rebase=testos/buildmaster/newbranch" -b testos/buildmaster/x86_64-runtime -s "EOL redirect to new branch"
echo "ok new branch"
# Upgrade existing checkout
${CMD_PREFIX} ostree admin upgrade --os=testos --pull-only
${CMD_PREFIX} ostree admin upgrade --os=testos --deploy-only
# Check we got redirected to the new branch
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf "${bootcsum}"
rev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse testos/buildmaster/newbranch)
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/usr/bin/content-iteration "1"
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0.origin "newbranch"
echo "ok update and redirect"
+50 -1
View File
@@ -170,6 +170,54 @@ test_raw_file_to_archive_z2_stream (gconstpointer data)
g_assert_cmpint (checks, >, 0);
}
static gboolean hi_content_stream_new (GInputStream **out_stream,
guint64 *out_length,
GError **error)
{
static const char hi[] = "hi";
g_autoptr(GMemoryInputStream) hi_memstream = (GMemoryInputStream*)g_memory_input_stream_new_from_data (hi, sizeof(hi)-1, NULL);
g_autoptr(GFileInfo) finfo = g_file_info_new ();
g_file_info_set_attribute_uint32 (finfo, "standard::type", G_FILE_TYPE_REGULAR);
g_file_info_set_attribute_boolean (finfo, "standard::is-symlink", FALSE);
g_file_info_set_attribute_uint32 (finfo, "unix::uid", 0);
g_file_info_set_attribute_uint32 (finfo, "unix::gid", 0);
g_file_info_set_attribute_uint32 (finfo, "unix::mode", S_IFREG|0644);
return ostree_raw_file_to_content_stream ((GInputStream*)hi_memstream, finfo, NULL, out_stream, out_length, NULL, error);
}
static void
test_object_writes (gconstpointer data)
{
OstreeRepo *repo = OSTREE_REPO (data);
g_autoptr(GError) error = NULL;
static const char hi_sha256[] = "2301b5923720c3edc1f0467addb5c287fd5559e3e0cd1396e7f1edb6b01be9f0";
/* Successful content write */
{ g_autoptr(GInputStream) hi_memstream = NULL;
guint64 len;
hi_content_stream_new (&hi_memstream, &len, &error);
g_assert_no_error (error);
g_autofree guchar *csum = NULL;
(void)ostree_repo_write_content (repo, hi_sha256, hi_memstream, len, &csum,
NULL, &error);
g_assert_no_error (error);
}
/* Invalid content write */
{ g_autoptr(GInputStream) hi_memstream = NULL;
guint64 len;
hi_content_stream_new (&hi_memstream, &len, &error);
g_assert_no_error (error);
g_autofree guchar *csum = NULL;
static const char invalid_hi_sha256[] = "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe";
g_assert (!ostree_repo_write_content (repo, invalid_hi_sha256, hi_memstream, len, &csum,
NULL, &error));
g_assert (error);
g_assert (strstr (error->message, "Corrupted file object"));
}
}
int main (int argc, char **argv)
{
g_autoptr(GError) error = NULL;
@@ -180,9 +228,10 @@ int main (int argc, char **argv)
repo = ot_test_setup_repo (NULL, &error);
if (!repo)
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);
g_test_add_data_func ("/objectwrites", repo, test_object_writes);
return g_test_run();
out:
+67
View File
@@ -22,4 +22,71 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
setup_test_repository "bare-user-only"
extra_basic_tests=4
. $(dirname $0)/basic-test.sh
# Reset things so we don't inherit a lot of state from earlier tests
cd ${test_tmpdir}
rm repo files -rf
ostree_repo_init repo init --mode=bare-user-only
# Init an archive repo where we'll store content that can't go into bare-user
cd ${test_tmpdir}
rm repo-input -rf
ostree_repo_init repo-input init --mode=archive
cd ${test_tmpdir}
cat > statoverride.txt <<EOF
2048 /some-setuid
EOF
mkdir -p files/
echo "a setuid file" > files/some-setuid
chmod 0644 files/some-setuid
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-suid --statoverride=statoverride.txt --tree=dir=files
if $CMD_PREFIX ostree pull-local --repo=repo repo-input 2>err.txt; then
assert_not_reached "copying suid file into bare-user worked?"
fi
assert_file_has_content err.txt "Invalid mode.*with bits 040.*in bare-user-only"
echo "ok failed to commit suid"
cd ${test_tmpdir}
rm repo-input -rf
ostree_repo_init repo-input init --mode=archive
rm files -rf && mkdir files
echo "a group writable file" > files/some-group-writable
chmod 0664 files/some-group-writable
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-group-writable --tree=dir=files
$CMD_PREFIX ostree pull-local --repo=repo repo-input
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-group-writable groupwritable-co
assert_file_has_mode groupwritable-co/some-group-writable 664
echo "ok supported group writable"
cd ${test_tmpdir}
rm repo-input -rf
ostree_repo_init repo-input init --mode=archive
rm files -rf && mkdir files
mkdir files/worldwritable-dir
chmod a+w files/worldwritable-dir
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-dir-world-writable --tree=dir=files
$CMD_PREFIX ostree pull-local --repo=repo repo-input
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
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?"
fi
$OSTREE fsck -q
echo "ok hardlink pull from bare-user"
+38
View File
@@ -25,4 +25,42 @@ skip_without_user_xattrs
setup_test_repository "bare-user"
extra_basic_tests=3
. $(dirname $0)/basic-test.sh
# Reset things so we don't inherit a lot of state from earlier tests
rm repo files -rf
setup_test_repository "bare-user"
cd ${test_tmpdir}
objpath_nonexec=$(ostree_file_path_to_object_path repo test2 baz/cow)
# Sigh, umask
touch testfile
default_mode=$(stat -c '%a' testfile)
rm testfile
assert_file_has_mode ${objpath_nonexec} ${default_mode}
objpath_ro=$(ostree_file_path_to_object_path repo test2 baz/cowro)
assert_file_has_mode ${objpath_ro} 600
objpath_exec=$(ostree_file_path_to_object_path repo test2 baz/deeper/ohyeahx)
assert_file_has_mode ${objpath_exec} 755
echo "ok bare-user committed modes"
rm test2-checkout -rf
$OSTREE checkout -U -H test2 test2-checkout
cd test2-checkout
assert_file_has_mode baz/cow ${default_mode}
assert_file_has_mode baz/cowro 600
assert_file_has_mode baz/deeper/ohyeahx 755
echo "ok bare-user checkout modes"
rm test2-checkout -rf
$OSTREE checkout -U -H test2 test2-checkout
touch test2-checkout/unwritable
chmod 0400 test2-checkout/unwritable
$OSTREE commit -b test2-unwritable --tree=dir=test2-checkout
chmod 0600 test2-checkout/unwritable
rm test2-checkout -rf
$OSTREE checkout -U -H test2-unwritable test2-checkout
cd test2-checkout
assert_file_has_mode unwritable 400
echo "ok bare-user unwritable"
+2 -2
View File
@@ -44,9 +44,9 @@ ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat
# Sanity check the setup, without headers the pull should fail
assert_fail ${CMD_PREFIX} ostree --repo=repo pull origin main
echo "ok, setup done"
echo "ok setup done"
# Now pull should succeed now
${CMD_PREFIX} ostree --repo=repo pull --http-header foo=bar --http-header baz=badger origin main
echo "ok, pull succeeded"
echo "ok pull succeeded"
+1 -1
View File
@@ -51,7 +51,7 @@ ${OSTREE} summary --view > summary.txt
assert_file_has_content_literal summary.txt "* main"
assert_file_has_content_literal summary.txt "* other"
assert_file_has_content_literal summary.txt "ostree.summary.last-modified"
assert_file_has_content_literal summary.txt "Static Deltas (ostree.static-deltas): {}"
assert_file_has_content_literal summary.txt "Timestamp (ostree.commit.timestamp): "
echo "ok view summary"
# Check the summary can be viewed raw too.
+14 -4
View File
@@ -17,10 +17,12 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
set -xeuo pipefail
echo '1..2'
echo '1..3'
released_syms=${G_TEST_SRCDIR}/src/libostree/libostree-released.sym
devel_syms=${G_TEST_SRCDIR}/src/libostree/libostree-devel.sym
if echo "$OSTREE_FEATURES" | grep --quiet --no-messages "experimental"; then
experimental_sym="${G_TEST_SRCDIR}/src/libostree/libostree-experimental.sym"
experimental_sections="${G_TEST_SRCDIR}/apidoc/ostree-experimental-sections.txt"
@@ -30,7 +32,7 @@ else
fi
echo "Verifying all expected symbols are actually exported..."
grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${G_TEST_SRCDIR}/src/libostree/libostree.sym $experimental_sym | sed -e 's,^ *\([A-Za-z0-9_]*\);,\1,' | sort -u > expected-symbols.txt
grep --no-filename ' ostree_[A-Za-z0-9_]*;' ${released_syms} ${devel_syms} ${experimental_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-9A-Z_.]*,\1,' |sort -u > found-symbols.txt
diff -u expected-symbols.txt found-symbols.txt
echo "ok exports"
@@ -39,7 +41,15 @@ echo "ok exports"
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 $experimental_sections |sort -u > found-documented.txt
grep --no-filename '^ostree_' ${G_TEST_SRCDIR}/apidoc/ostree-sections.txt $experimental_sections |sort -u > found-documented.txt
diff -u expected-documented.txt found-documented.txt
echo 'ok documented symbols'
# ONLY update this checksum in release commits!
cat > released-sha256.txt <<EOF
42f98d8816acbe22e925d18bf76ea2c6f7e12ee5d7a381979e6ed07bb6a1f755 ${released_syms}
EOF
sha256sum -c released-sha256.txt
echo "ok someone didn't add a symbol to a released version"