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

rust/tests: Adjust for new ostree #3051

Merged
merged 1 commit into from
Sep 20, 2023
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
15 changes: 9 additions & 6 deletions rust-bindings/tests/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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]
Expand Down
17 changes: 10 additions & 7 deletions tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions tests/test-admin-gpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/test-commit-sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions tests/test-pull-contenturl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
5 changes: 5 additions & 0 deletions tests/test-pull-metalink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions tests/test-pull-mirrorlist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions tests/test-pull-override-url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading