Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-admin-deploy-var: Don't rely on OSTREE_FEATURES #3184

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -696,18 +696,20 @@ skip_without_fuse () {
[ -e /etc/mtab ] || skip "no /etc/mtab"
}

has_gpgme () {
local ret
has_ostree_feature () {
local ret=0
# Note that this needs to write to a file and then grep the file, to
# avoid ostree --version being killed with SIGPIPE and exiting with a
# nonzero status under `set -o pipefail`.
Comment on lines +702 to +703
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man...wow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, more involved than I expected. This PR brought to you by the dept. of Unix arcana.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it's eminently useful, I stopped using pipefail years ago after being burned by the same issue in tar. It might be nice to install a SIGPIPE handler in the version printing code since this is likely to affect other ostree consumers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I've said many times with coworkers in live video chats, but rarely externally is that a nontrivial component of why I still (20+ years later) wake up and log into my computer for this job is that I just really enjoy collaborating with lots of smart people across the internet. Also there's the continual "surprise" factor in computers as in "what did someone figure out how to make them do this year" (and right now it's AI).

Anyways this little bit combines those two - I just want to say thanks @smcv as one of those smart people on the Internet for everything you do 🙏 - and this little bit of pipefail is one of those surprises 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #3203.

${CMD_PREFIX} ostree --version > version.txt
grep -q -e '- gpgme' version.txt
ret=$?
grep -q -e "- $1\$" version.txt || ret=$?
rm -f version.txt
return ${ret}
}

skip_without_gpgme() {
if ! has_gpgme; then
skip "no gpg support compiled in"
skip_without_ostree_feature () {
if ! has_ostree_feature "$1"; then
skip "no $1 support compiled in"
fi
}

Expand Down Expand Up @@ -750,21 +752,6 @@ libtest_cleanup_gpg () {
}
libtest_exit_cmds+=(libtest_cleanup_gpg)

has_sign_ed25519 () {
local ret
${CMD_PREFIX} ostree --version > version.txt
grep -q -e '- sign-ed25519' version.txt
ret=$?
rm -f version.txt
return ${ret}
}

skip_without_sign_ed25519() {
if ! has_sign_ed25519; then
skip "no ed25519 support compiled in"
fi
}

# Keys for ed25519 signing tests
ED25519PUBLIC=
ED25519SEED=
Expand Down
6 changes: 3 additions & 3 deletions tests/pull-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function verify_initial_contents() {

n_base_tests=35
gpg_tests=3
if has_gpgme; then
if has_ostree_feature gpgme; then
echo "1..$(($n_base_tests+$gpg_tests))"
else
echo "1..$((n_base_tests))"
Expand Down Expand Up @@ -633,7 +633,7 @@ fi
assert_file_has_content err.txt "404"
echo "ok pull repo 404"

if has_gpgme; then
if has_ostree_feature gpgme; then
cd ${test_tmpdir}
repo_init --set=gpg-verify=true
if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main 2>err.txt; then
Expand All @@ -653,7 +653,7 @@ assert_file_has_content err.txt "404"
find ostree-srv/gnomerepo/objects -name '*.dirtree.orig' | while read f; do mv ${f} $(dirname $f)/$(basename ${f} .orig); done
echo "ok pull repo 404 on dirtree object"

if has_gpgme; then
if has_ostree_feature gpgme; then
cd ${test_tmpdir}
repo_init --set=gpg-verify=true
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit ${COMMIT_ARGS} \
Expand Down
2 changes: 1 addition & 1 deletion tests/test-admin-deploy-var.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set -euox pipefail

. $(dirname $0)/libtest.sh

if ! echo "$OSTREE_FEATURES" | grep --quiet --no-messages "initial-var"; then
if ! has_ostree_feature initial-var; then
fatal missing initial-var
fi

Expand Down
5 changes: 1 addition & 4 deletions tests/test-commit-sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ set -euo pipefail

. $(dirname $0)/libtest.sh

if ! has_gpgme; then
echo "1..0 #SKIP no gpg support compiled in"
exit 0
fi
skip_without_ostree_feature gpgme

if test -z "${OSTREE_HTTPD}"; then
echo "1..0 #SKIP no ostree-trivial-httpd"
Expand Down
6 changes: 1 addition & 5 deletions tests/test-composefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ set -euo pipefail

. $(dirname $0)/libtest.sh

if ! ${CMD_PREFIX} ostree --version | grep -q -e '- composefs'; then
echo "1..0 #SKIP no composefs support compiled in"
exit 0
fi

skip_without_ostree_feature composefs
skip_without_user_xattrs

setup_test_repository "bare-user"
Expand Down
2 changes: 1 addition & 1 deletion tests/test-create-usb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set -euo pipefail

. $(dirname $0)/libtest.sh

skip_without_gpgme
skip_without_ostree_feature gpgme

echo "1..5"

Expand Down
2 changes: 1 addition & 1 deletion tests/test-delta-ed25519.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -euo pipefail

skip_without_user_xattrs

skip_without_sign_ed25519
skip_without_ostree_feature sign-ed25519

bindatafiles="bash true ostree"

Expand Down
6 changes: 1 addition & 5 deletions tests/test-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@

set -euo pipefail

if ! ostree --version | grep -q -e '- libarchive'; then
echo "1..0 #SKIP no libarchive support compiled in"
exit 0
fi

. $(dirname $0)/libtest.sh

skip_without_ostree_feature libarchive
setup_test_repository "archive"

echo '1..6'
Expand Down
2 changes: 1 addition & 1 deletion tests/test-find-remotes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set -euo pipefail

. $(dirname $0)/libtest.sh

skip_without_gpgme
skip_without_ostree_feature gpgme

echo '1..1'

Expand Down
5 changes: 1 addition & 4 deletions tests/test-gpg-signed-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ set -euo pipefail

. $(dirname $0)/libtest.sh

if ! has_gpgme; then
echo "1..0 #SKIP no gpgme support compiled in"
exit 0
fi
skip_without_ostree_feature gpgme

num_tests=1

Expand Down
7 changes: 2 additions & 5 deletions tests/test-libarchive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@

set -euo pipefail

if ! ostree --version | grep -q -e '- libarchive'; then
echo "1..0 #SKIP no libarchive support compiled in"
exit 0
fi

. $(dirname $0)/libtest.sh

skip_without_ostree_feature libarchive

echo "1..18"

setup_test_repository "bare"
Expand Down
2 changes: 1 addition & 1 deletion tests/test-local-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ cmp checkout1.files checkout2.files
cmp checkout1.files checkout3.files
echo "ok checkouts same"

if has_gpgme; then
if has_ostree_feature gpgme; then
# These tests are needed GPG support
mkdir repo4
ostree_repo_init repo4 --mode="archive"
Expand Down
2 changes: 1 addition & 1 deletion tests/test-parent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -euo pipefail

skip_without_user_xattrs

skip_without_gpgme
skip_without_ostree_feature gpgme

echo '1..2'

Expand Down
2 changes: 1 addition & 1 deletion tests/test-pre-signed-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -euo pipefail

echo "1..1"

if ! has_sign_ed25519; then
if ! has_ostree_feature sign-ed25519; then
echo "ok pre-signed pull # SKIP due ed25519 unavailability"
exit 0
fi
Expand Down
6 changes: 3 additions & 3 deletions tests/test-pull-collections.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ do_commit() {
mkdir -p files
pushd files
local GPG_ARGS=""
if has_gpgme; then
if has_ostree_feature gpgme; then
GPG_ARGS="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi
${CMD_PREFIX} ostree --repo="../${repo}" commit -s "Test ${repo} commit for branch ${branch}" -b "${branch}" ${GPG_ARGS} "$@" > "../${branch}-checksum"
Expand All @@ -45,7 +45,7 @@ do_summary() {
shift 1

local GPG_ARGS=""
if has_gpgme; then
if has_ostree_feature gpgme; then
GPG_ARGS="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi
${CMD_PREFIX} ostree "--repo=${repo}" summary --update ${GPG_ARGS}
Expand Down Expand Up @@ -103,7 +103,7 @@ do_remote_add() {
shift 2

local GPG_ARGS=""
if has_gpgme; then
if has_ostree_feature gpgme; then
GPG_ARGS="--gpg-import=${test_tmpdir}/gpghome/key1.asc"
fi
${CMD_PREFIX} ostree "--repo=${repo}" remote add "${remote_repo}-remote" "file://$(pwd)/${remote_repo}" "$@" ${GPG_ARGS}
Expand Down
8 changes: 4 additions & 4 deletions tests/test-pull-contenturl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
echo "1..2"

COMMIT_SIGN=""
if has_gpgme; then
if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi

Expand All @@ -47,7 +47,7 @@ cp -a ${test_tmpdir}/ostree-srv ostree

# delete all the meta stuff from here
rm ostree/gnomerepo/summary
if has_gpgme; then
if has_ostree_feature gpgme; then
rm ostree/gnomerepo/summary.sig
find ostree/gnomerepo/objects -name '*.commitmeta' | xargs rm
fi
Expand All @@ -63,7 +63,7 @@ echo "http://127.0.0.1:${content_port}" > ${test_tmpdir}/httpd-content-address
cd ${test_tmpdir}
mkdir repo
ostree_repo_init repo
if has_gpgme; then VERIFY=true; else VERIFY=false; fi
if has_ostree_feature gpgme; then VERIFY=true; else VERIFY=false; fi
${CMD_PREFIX} ostree --repo=repo remote add origin \
--set=gpg-verify=$VERIFY --set=gpg-verify-summary=$VERIFY \
--contenturl=$(cat httpd-content-address)/ostree/gnomerepo \
Expand All @@ -72,7 +72,7 @@ ${CMD_PREFIX} ostree --repo=repo pull origin:main

echo "ok pull objects from contenturl"

if ! has_gpgme; then
if ! has_ostree_feature gpgme; then
echo "ok don't pull sigs from contenturl # SKIP not compiled with gpgme"
else
echo "ok don't pull sigs from contenturl"
Expand Down
4 changes: 2 additions & 2 deletions tests/test-pull-mirror-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh

COMMIT_SIGN=""
if has_gpgme; then
if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
echo "1..5"
else
Expand Down Expand Up @@ -67,7 +67,7 @@ find repo/objects -name '*.filez' | while read name; do
done
echo "ok pull mirror summary"

if ! has_gpgme; then
if ! has_ostree_feature gpgme; then
exit 0;
fi

Expand Down
2 changes: 1 addition & 1 deletion tests/test-pull-repeated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh

COMMIT_SIGN=""
if has_gpgme; then
if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi

Expand Down
5 changes: 1 addition & 4 deletions tests/test-pull-summary-caching.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ set -euo pipefail

. $(dirname $0)/libtest.sh

if ! has_gpgme; then
echo "1..0 #SKIP no gpg support compiled in"
exit 0
fi
skip_without_ostree_feature gpgme

# Ensure repo caching is in use.
unset OSTREE_SKIP_CACHE
Expand Down
4 changes: 2 additions & 2 deletions tests/test-pull-summary-sigs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set -euo pipefail
unset OSTREE_SKIP_CACHE

COMMIT_SIGN=""
if has_gpgme; then
if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
echo "1..10"
else
Expand Down Expand Up @@ -63,7 +63,7 @@ assert_file_has_content yet-another-copy/yet-another-hello-world "hello world ye
${CMD_PREFIX} ostree --repo=repo fsck
echo "ok pull mirror summary"

if ! has_gpgme; then
if ! has_ostree_feature gpgme; then
exit 0;
fi

Expand Down
2 changes: 1 addition & 1 deletion tests/test-signed-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ assert_file_has_content_literal err.txt ' No valid signatures found'
echo "ok dummy sig requires env"

# tests below require libsodium support
if ! has_sign_ed25519; then
if ! has_ostree_feature sign-ed25519; then
echo "ok Detached ed25519 signature # SKIP due libsodium unavailability"
echo "ok ed25519 signature verified # SKIP due libsodium unavailability"
echo "ok multiple signing # SKIP due libsodium unavailability"
Expand Down
4 changes: 2 additions & 2 deletions tests/test-signed-pull-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ do
PUBLIC_KEY="dummysign"
;;
ed25519)
if ! has_sign_ed25519; then
if ! has_ostree_feature sign-ed25519; then
echo "ok ${engine} pull mirror summary # SKIP due libsodium unavailability"
echo "ok ${engine} pull with signed summary # SKIP due libsodium unavailability"
echo "ok ${engine} prune summary cache # SKIP due libsodium unavailability"
Expand Down Expand Up @@ -174,7 +174,7 @@ do

done

if ! has_sign_ed25519; then
if ! has_ostree_feature sign-ed25519; then
echo "ok ${engine} pull with signed summary remote old summary # SKIP due libsodium unavailability"
echo "ok ${engine} pull with signed summary broken cache # SKIP due libsodium unavailability"
exit 0
Expand Down
2 changes: 1 addition & 1 deletion tests/test-signed-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fi
assert_file_has_content err.txt 'Invalid key reference'
echo "ok remote add errs"

if ! has_sign_ed25519; then
if ! has_ostree_feature sign-ed25519; then
echo "ok ed25519-key pull signed commit # SKIP due libsodium unavailability"
echo "ok ed25519-key re-pull signature for stored commit # SKIP due libsodium unavailability"
echo "ok ed25519-key+file pull signed commit # SKIP due libsodium unavailability"
Expand Down
2 changes: 1 addition & 1 deletion tests/test-summary-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set -euo pipefail
echo "1..2"

COMMIT_SIGN=""
if has_gpgme; then
if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi

Expand Down
2 changes: 1 addition & 1 deletion tests/test-summary-view.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set -euo pipefail
echo "1..2"

COMMIT_SIGN=""
if has_gpgme; then
if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi

Expand Down
Loading