From fb519f0361565cad0d340095263a1e8866ec4f89 Mon Sep 17 00:00:00 2001 From: Alex Kiernan Date: Thu, 31 Oct 2019 11:30:00 +0000 Subject: [PATCH 1/3] tests: Handle EPIPE failures when head terminates When using musl, it appears that the default is line buffered output, so when `head -1` reads from a pipe we have to handle the source end of the pipe getting EPIPE. Signed-off-by: Alex Kiernan --- tests/pull-test.sh | 2 +- tests/test-pull-mirrorlist.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pull-test.sh b/tests/pull-test.sh index 0a97a119..2cfd8e02 100644 --- a/tests/pull-test.sh +++ b/tests/pull-test.sh @@ -177,7 +177,7 @@ if ! skip_one_without_user_xattrs; then ${CMD_PREFIX} ostree --repo=cacherepo pull-local ostree-srv/gnomerepo main rev=$(ostree --repo=cacherepo rev-parse main) ${CMD_PREFIX} ostree --repo=cacherepo ls -R -C main > ls.txt - regfile_hash=$(grep -E -e '^-0' ls.txt | head -1 | awk '{ print $5 }') + regfile_hash=$((grep -E -e '^-0' ls.txt || true) | head -1 | awk '{ print $5 }') ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false corruptrepo $(cat httpd-address)/ostree/corruptrepo # Make this a loop so in the future we can add more object types like commit etc. for object in ${regfile_hash}.file; do diff --git a/tests/test-pull-mirrorlist.sh b/tests/test-pull-mirrorlist.sh index 4e44852d..85ff66e9 100755 --- a/tests/test-pull-mirrorlist.sh +++ b/tests/test-pull-mirrorlist.sh @@ -47,12 +47,12 @@ setup_mirror content_mirror3 # Let's delete a file from 1 so that it falls back on 2 cd ${test_tmpdir}/content_mirror1/ostree/gnomerepo -filez=$(find objects/ -name '*.filez' | head -n 1) +filez=$((find objects/ -name '*.filez' || true) | head -n 1) rm ${filez} # Let's delete a file from 1 and 2 so that it falls back on 3 cd ${test_tmpdir}/content_mirror1/ostree/gnomerepo -filez=$(find objects/ -name '*.filez' | head -n 1) +filez=$((find objects/ -name '*.filez' || true) | head -n 1) rm ${filez} cd ${test_tmpdir}/content_mirror2/ostree/gnomerepo rm ${filez} From 3d48021fb0892721fab8359b49470e521aaed493 Mon Sep 17 00:00:00 2001 From: Alex Kiernan Date: Thu, 31 Oct 2019 11:28:07 +0000 Subject: [PATCH 2/3] tests/core: Assume C.UTF-8 if locale isn't found When building with musl there's no locale command, also its default locale is C.UTF-8, so just get C.UTF-8 if we can't find locale. Signed-off-by: Alex Kiernan --- tests/libtest-core.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh index bc191332..46aafab0 100644 --- a/tests/libtest-core.sh +++ b/tests/libtest-core.sh @@ -37,9 +37,15 @@ assert_not_reached () { # Some tests look for specific English strings. Use a UTF-8 version # of the C (POSIX) locale if we have one, or fall back to en_US.UTF-8 # (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8) -export LC_ALL=$(locale -a | grep -Ee '\.(UTF-8|utf8)' | grep -iEe '^(C|en_US)' | head -1 || true) -if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi - +# +# If we can't find the locale command assume we have support for C.UTF-8 +# (e.g. musl based systems) +if type -p locale >/dev/null; then + export LC_ALL=$(locale -a | grep -Ee '\.(UTF-8|utf8)' | grep -iEe '^(C|en_US)' | head -1 || true) + if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi +else + export LC_ALL=C.UTF-8 +fi # A GNU extension, used whenever LC_ALL is not C unset LANGUAGE From abf1a7392b2fa1945286a39a35190d74fe141e52 Mon Sep 17 00:00:00 2001 From: Alex Kiernan Date: Thu, 31 Oct 2019 17:09:36 +0000 Subject: [PATCH 3/3] tests: Avoid musl failure with `cp -a` When copying the tree, using musl and GNU coreutils, something gets confused when setting the ownership of symlinks and the copy fails with: cp: failed to preserve ownership for osdata-devel/bin: Not supported Rework using tar to avoid the problem. Signed-off-by: Alex Kiernan --- tests/libtest.sh | 4 +++- tests/test-admin-gpg.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/libtest.sh b/tests/libtest.sh index ba00073a..3f5fd931 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -440,7 +440,9 @@ EOF ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.10 -b testos/buildmaster/x86_64-runtime -s "Build" cd ${test_tmpdir} - cp -a osdata osdata-devel + rm -rf osdata-devel + mkdir osdata-devel + tar -C osdata -cf - . | tar -C osdata-devel -xf - cd osdata-devel mkdir -p usr/include echo "a development header" > usr/include/foo.h diff --git a/tests/test-admin-gpg.sh b/tests/test-admin-gpg.sh index 1f50c8a9..dc776743 100755 --- a/tests/test-admin-gpg.sh +++ b/tests/test-admin-gpg.sh @@ -90,7 +90,9 @@ EOF ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.10 -b testos/buildmaster/x86_64-runtime -s "Build" --gpg-sign=$keyid --gpg-homedir=${test_tmpdir}/gpghome cd ${test_tmpdir} - cp -a osdata osdata-devel + rm -rf osdata-devel + mkdir osdata-devel + tar -C osdata -cf - . | tar -C osdata-devel -xf - cd osdata-devel mkdir -p usr/include echo "a development header" > usr/include/foo.h