summaryrefslogtreecommitdiff
path: root/tests/test-switchroot.sh
diff options
context:
space:
mode:
authorAlex Kiernan <alex.kiernan@gmail.com>2019-12-29 12:43:34 +0000
committerAlex Kiernan <alex.kiernan@gmail.com>2019-12-29 14:24:30 +0000
commite4db245bec66f353c6aba1a661465ce649bd521e (patch)
tree178c7b4a212d1a3f82a6c984fd50163f6ed234a6 /tests/test-switchroot.sh
parentb9a95afacc483606426e263032e2595e64705e94 (diff)
downloadostree-e4db245bec66f353c6aba1a661465ce649bd521e.tar.gz
test-switchroot.sh: Find ostree-prepare-root in installed tests
When running with installed tests, ostree-prepare-root (probably) exists in /usr/lib. Add heuristics to look for it based on the directory we're running from. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Diffstat (limited to 'tests/test-switchroot.sh')
-rwxr-xr-xtests/test-switchroot.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/test-switchroot.sh b/tests/test-switchroot.sh
index bc3ec38b..2adaa0ac 100755
--- a/tests/test-switchroot.sh
+++ b/tests/test-switchroot.sh
@@ -2,6 +2,16 @@
this_script="${BASH_SOURCE:-$(readlink -f "$0")}"
+OSTREE_PREPARE_ROOT=$(dirname "${this_script}")/../ostree-prepare-root
+if [ ! -x "${OSTREE_PREPARE_ROOT}" ]; then
+ # ostree-prepare-root is in $libdir by default, assume we can find it
+ # based on our test directory, if not we'll have to skip this test.
+ OSTREE_PREPARE_ROOT=$(dirname "${this_script}")/../../../lib/ostree/ostree-prepare-root
+ if [ ! -x "${OSTREE_PREPARE_ROOT}" ]; then
+ OSTREE_PREPARE_ROOT=""
+ fi
+fi
+
setup_bootfs() {
mkdir -p "$1/proc" "$1/bin"
@@ -13,7 +23,7 @@ setup_bootfs() {
mount --bind "$1/override_cmdline" "$1/proc/cmdline"
touch "$1/this_is_bootfs"
- cp "$(dirname "$this_script")/../ostree-prepare-root" "$1/bin"
+ cp "${OSTREE_PREPARE_ROOT}" "$1/bin"
}
setup_rootfs() {
@@ -130,6 +140,9 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
[ -f /bin/busybox ] || \
skip "this test needs busybox"
+ [ -n "${OSTREE_PREPARE_ROOT}" ] || \
+ skip "this test needs ostree-prepare-root"
+
echo "1..3"
test_that_prepare_root_sets_sysroot_up_correctly_with_initrd
test_that_prepare_root_sets_root_up_correctly_with_no_initrd