summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEvan Benn <evanbenn@chromium.org>2022-08-16 17:02:02 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-25 09:36:59 +0000
commit148e5b836dc52e8d81bb67f29dea7c81aa3d720f (patch)
treedabea89841ec086a42a174378e405a185367a340 /tests
parenta9c47c41cc3801cd888bdcdfd18d8f4d9f787ce5 (diff)
downloadvboot-148e5b836dc52e8d81bb67f29dea7c81aa3d720f.tar.gz
Makefile: Fix and simplify the RUNTEST test wrapper
Remove the qemu logic from the Makefile. Document the RUNTEST, BUILD_RUN and SRC_RUN variables. Ensure those variables are used consistently throughout the Makefile and test scripts. BUG=b:231084609 BRANCH=None TEST=FEATURES=test emerge vboot_reference TEST=FEATURES=test emerge-amd64-generic vboot_reference TEST=FEATURES=test emerge-hatch coreboot TEST=(coreboot upstream with this patch) make all TEST=make BUILD=build1 runtests TEST=make BUILD=build2 RUNTEST=env runtests Cq-Depend: chromium:3934904 Change-Id: Ifd18463d681bedbf7464165f2df0181474b36791 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3831828 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/common.sh13
-rwxr-xr-xtests/futility/run_test_scripts.sh3
-rwxr-xr-xtests/gen_fuzz_test_cases.sh2
-rwxr-xr-xtests/test_using_qemu.sh40
4 files changed, 8 insertions, 50 deletions
diff --git a/tests/common.sh b/tests/common.sh
index 78512254..ed1c9f06 100644
--- a/tests/common.sh
+++ b/tests/common.sh
@@ -7,14 +7,13 @@
# Determine script directory.
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
ROOT_DIR="$(dirname "${SCRIPT_DIR}")"
-SRCDIR="${SRCDIR:-${ROOT_DIR}}"
-BUILD="${BUILD:-${ROOT_DIR}/build}"
-BUILD_RUN="${BUILD_RUN:-${BUILD}}"
-SRC_RUN="${SRC_RUN:-${SRCDIR}}"
-BUILD_DIR="${BUILD}"
-BIN_DIR="${BUILD_DIR}/install_for_test/usr/bin"
+SRCDIR="${ROOT_DIR}"
+# BUILD_RUN should be supplied from the Makefile.
+# Some test scripts change the cwd so use an absolute path.
+BUILD_RUN="$(realpath "${BUILD_RUN}")"
+BIN_DIR="${BUILD_RUN}/install_for_test/usr/bin"
FUTILITY="${BIN_DIR}/futility"
-TEST_DIR="${BUILD_DIR}/tests"
+TEST_DIR="${BUILD_RUN}/tests"
TESTKEY_DIR="${SCRIPT_DIR}/testkeys"
TESTCASE_DIR="${SCRIPT_DIR}/testcases"
TESTKEY_SCRATCH_DIR="${TEST_DIR}/testkeys"
diff --git a/tests/futility/run_test_scripts.sh b/tests/futility/run_test_scripts.sh
index dc87f76b..09086998 100755
--- a/tests/futility/run_test_scripts.sh
+++ b/tests/futility/run_test_scripts.sh
@@ -6,11 +6,10 @@
# Load common constants and variables.
. "$(dirname "$0")/../common.sh"
-OUTDIR="${BUILD}/tests/futility_test_results"
+OUTDIR="${BUILD_RUN}/tests/futility_test_results"
[ -d "$OUTDIR" ] || mkdir -p "$OUTDIR"
# Let each test know where to find things...
-export BUILD
export BUILD_RUN
export SRCDIR
export FUTILITY
diff --git a/tests/gen_fuzz_test_cases.sh b/tests/gen_fuzz_test_cases.sh
index 1dede33d..0a9f6942 100755
--- a/tests/gen_fuzz_test_cases.sh
+++ b/tests/gen_fuzz_test_cases.sh
@@ -13,7 +13,7 @@ set -e
# Use a different directory for fuzzing test cases.
TESTKEY_DIR=${TESTKEY_DIR:-$(realpath "${SCRIPT_DIR}"/../tests/testkeys)}
-TESTCASE_DIR=${BUILD_DIR}/fuzz_testcases
+TESTCASE_DIR=${BUILD_RUN}/fuzz_testcases
TEST_IMAGE_FILE=${TESTCASE_DIR}/testimage
TEST_IMAGE_SIZE=500000
TEST_BOOTLOADER_FILE=${TESTCASE_DIR}/testbootloader
diff --git a/tests/test_using_qemu.sh b/tests/test_using_qemu.sh
deleted file mode 100755
index 99669d5e..00000000
--- a/tests/test_using_qemu.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2013 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Script to run a test under qemu
-#
-# Usage:
-# test_using_qemu.sh (command line to run)
-#
-# Required environment variables:
-# BUILD_RUN - path to build directory inside chroot
-# HOME - home directory inside chroot
-# QEMU_RUN - path to QEMU binary inside chroot
-# SYSROOT - path to root for target platform, outside chroot
-
-set -e
-
-# Set up mounts
-sudo mkdir -p "${SYSROOT}/proc" "${SYSROOT}/dev"
-sudo mount --bind /proc "${SYSROOT}/proc"
-sudo mount --bind /dev "${SYSROOT}/dev"
-
-# Don't exit on error, so we can capture the error code
-set +e
-sudo chroot "${SYSROOT}" "${QEMU_RUN}" \
- -E LD_LIBRARY_PATH=/lib64:/lib:/usr/lib64:/usr/lib \
- -E HOME="${HOME}" \
- -E BUILD="${BUILD_RUN}" \
- -- "$@"
-exit_code=$?
-set -e
-
-# Clean up mounts
-sudo umount -l "${SYSROOT}/proc"
-sudo umount -l "${SYSROOT}/dev"
-
-# Pass through exit code from command
-exit $exit_code