tests: Rework detection of trivial-httpd
authorColin Walters <walters@verbum.org>
Tue, 19 Sep 2023 19:25:36 +0000 (15:25 -0400)
committerColin Walters <walters@verbum.org>
Tue, 19 Sep 2023 20:52:13 +0000 (16:52 -0400)
Because it's now at the toplevel.

rust-bindings/tests/sign/mod.rs
tests/libtest.sh
tests/test-admin-gpg.sh
tests/test-commit-sign.sh
tests/test-pull-contenturl.sh
tests/test-pull-metalink.sh
tests/test-pull-mirrorlist.sh
tests/test-pull-override-url.sh

index 745076cbaa75760e52466b32c28c8dfa16bf68ad..0dc48ae70177291dd795f00fa6f137838f1bb0c7 100644 (file)
@@ -43,14 +43,19 @@ echo $ED25519SECRET > ed25519.secret
     );
     let s = Command::new("bash")
         .env("G_TEST_SRCDIR", pwd)
+        .env("OSTREE_HTTPD", "")
         .current_dir(path)
         .args(["-euo", "pipefail"])
         .args(["-c", cmd.as_str()])
         .stdout(std::process::Stdio::null())
-        .stderr(std::process::Stdio::null())
-        .status()
+        .stderr(std::process::Stdio::piped())
+        .output()
         .unwrap();
-    assert!(s.success());
+    if !s.status.success() {
+        let mut stderr = std::io::stderr().lock();
+        let _ = std::io::copy(&mut std::io::Cursor::new(&s.stderr), &mut stderr);
+        panic!("failed to source libtest: {:?}", s.status);
+    }
 
     let seckey = std::fs::read_to_string(path.join("ed25519.secret")).unwrap();
     let seckey = seckey.to_variant();
@@ -74,9 +79,7 @@ echo $ED25519SECRET > ed25519.secret
     let badsigs = [b"".as_slice()].to_variant();
 
     let e = signer.data_verify(payload, &badsigs).err().unwrap();
-    assert!(e
-        .to_string()
-        .contains("Invalid signature length of 0 bytes"))
+    assert!(e.to_string().contains("Ill-formed input"), "{}", e)
 }
 
 #[test]
index 9d871aa4304a5d6151e628a7054d3a2f06bdf058..fa9378270348c2ca2ea811aa2bfe0663d61ab766 100755 (executable)
@@ -25,11 +25,12 @@ else
   test_srcdir=$(dirname $0)
 fi
 
-if [ -n "${G_TEST_BUILDDIR:-}" ]; then
-  test_builddir="${G_TEST_BUILDDIR}/tests"
-else
-  test_builddir=$(dirname $0)
+top_builddir="${G_TEST_BUILDDIR:-}"
+if test -z "${top_builddir}"; then
+    top_builddir=$(cd $(dirname $0)/.. && pwd)
 fi
+
+test_builddir="${top_builddir}/tests"
 . ${test_srcdir}/libtest-core.sh
 
 # Make sure /sbin/capsh etc. are in our PATH even if non-root
@@ -180,9 +181,11 @@ 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"
 fi
 
-OSTREE_HTTPD="${G_TEST_BUILDDIR}/ostree-trivial-httpd"
-if ! [ -x "${OSTREE_HTTPD}" ]; then
-    fatal "Failed to find ${OSTREE_HTTPD}"
+if test -z "${OSTREE_HTTPD:-}"; then
+    OSTREE_HTTPD="${top_builddir}/ostree-trivial-httpd"
+    if ! [ -x "${OSTREE_HTTPD}" ]; then
+        OSTREE_HTTPD=
+    fi
 fi
 
 files_are_hardlinked() {
index dcf075c1e1e14902955f3a54c76cb91f0bc888b3..f71c306b93d001d8a0d2430df2e0731272f5c81c 100755 (executable)
@@ -21,6 +21,11 @@ set -euo pipefail
 
 . $(dirname $0)/libtest.sh
 
+if test -z "${OSTREE_HTTPD}"; then
+    echo "1..0 #SKIP no ostree-trivial-httpd"
+    exit 0
+fi
+
 setup_os_repository_signed () {
     mode=$1
     shift
index 2aad1cff5556f9cf2fcfbf331b08e0e14fa7c796..e0cea0b588ad6051d1a599ada6bb20231af8a5dc 100755 (executable)
@@ -26,6 +26,11 @@ if ! has_gpgme; then
     exit 0
 fi
 
+if test -z "${OSTREE_HTTPD}"; then
+    echo "1..0 #SKIP no ostree-trivial-httpd"
+    exit 0
+fi
+
 echo "1..7"
 
 keyid="472CDAFA"
index ba6a2a5f67e095ba89d9cb5865f54561c261c052..d47fdfe11059bf774304fe16c72e3ca24d53440b 100755 (executable)
@@ -21,6 +21,11 @@ set -euo pipefail
 
 . $(dirname $0)/libtest.sh
 
+if test -z "${OSTREE_HTTPD}"; then
+    echo "1..0 #SKIP no ostree-trivial-httpd"
+    exit 0
+fi
+
 echo "1..2"
 
 COMMIT_SIGN=""
index f73992b4470c8f0ab838cdc942aac9ebd12d42e3..22e5d59c910d80ffcd0b4e15ea519e595da540ca 100755 (executable)
@@ -21,6 +21,11 @@ set -euo pipefail
 
 . $(dirname $0)/libtest.sh
 
+if test -z "${OSTREE_HTTPD}"; then
+    echo "1..0 #SKIP no ostree-trivial-httpd"
+    exit 0
+fi
+
 setup_fake_remote_repo1 "archive"
 
 echo '1..9'
index 1d0d2c58edf01fdb6042b27096b97d37d65f0bcb..d04d1e48d969e8361f562c8494c2aff0cf2a0b18 100755 (executable)
@@ -21,6 +21,11 @@ set -euo pipefail
 
 . $(dirname $0)/libtest.sh
 
+if test -z "${OSTREE_HTTPD}"; then
+    echo "1..0 #SKIP no ostree-trivial-httpd"
+    exit 0
+fi
+
 echo "1..3"
 
 setup_fake_remote_repo1 "archive"
index 71a32714a72ed86e4f371c1b43efdf90b6f80cf5..4e8ed03538e209108df129609d9e9995dbe5d34f 100755 (executable)
@@ -21,6 +21,11 @@ set -euo pipefail
 
 . $(dirname $0)/libtest.sh
 
+if test -z "${OSTREE_HTTPD}"; then
+    echo "1..0 #SKIP no ostree-trivial-httpd"
+    exit 0
+fi
+
 setup_fake_remote_repo1 "archive"
 
 echo '1..1'