From 6bd82cda5f609d4758cf5c430a32f8a4bb6c6ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 30 Dec 2017 21:39:37 +0100 Subject: Add ability to specify system mips toolchain in tests --- tests/run-all.sh | 2 +- tests/test.sh | 45 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/tests/run-all.sh b/tests/run-all.sh index 9c57391..dc07015 100755 --- a/tests/run-all.sh +++ b/tests/run-all.sh @@ -3,5 +3,5 @@ set -e for T in $(find "$(dirname "$0")" -name test.sh -type f -executable); do - timeout -k 120 60 "$T" + timeout -k 120 60 "$T" "$@" done diff --git a/tests/test.sh b/tests/test.sh index 1302bf4..7f83246 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -16,6 +16,37 @@ echo_fail() { exit 1 } +## Parse script arguments ####################################################### +TOOLCHAIN_SYS=false +TOOLCHAIN="mips-elf-" + +while [ $# -gt 0 ]; do + case "$1" in + -\?|-h|--help) + echo "QtMips test script ($TEST_NAME)" + echo "Usage: $0 [OPTION]..." + echo + echo "Options:" + echo " -s, --system-toolchain" + echo " Don't compile it's own toolchain. Use system toolchain instead" + echo " --toolchain PREFIX" + echo " What toolchain prefix should be used when system toolchain is used." + echo " In default mips-elf- is used." + echo " -h, -?, --help" + echo " Print this help text." + exit 0 + ;; + -s|--system-toolchain) + TOOLCHAIN_SYS=true + ;; + --toolchain) + TOOLCHAIN="$2" + shift + ;; + esac + shift +done + ## Check and init test ########################################################## # Check if test name is defined @@ -62,6 +93,8 @@ BUILD_DIR="$TEST_DIR_ROOT/build" # Directory where test should be build and executed TEST_DIR="$TEST_DIR_ROOT/$TEST_NAME" +# TODO verify that we really have system toolchain if configured. + ## Helper functions for building and running project ############################ qtmips_make() { @@ -83,7 +116,8 @@ qtmips_run() { MIPS_COMPILER="$TEST_DIR_ROOT/mips-qtmips-elf" -mips_compiler() { +_mips_compiler() { + export PATH="$PATH:$MIPS_COMPILER/bin" # Skip if we have compiler already [ ! -d "$MIPS_COMPILER" ] || return 0 # Otherwise compile it @@ -95,7 +129,12 @@ mips_compiler() { } mips_make_test() { - mips_compiler + local PREFIX="mips-qtmips-elf-" + if $TOOLCHAIN_SYS; then + PREFIX="$TOOLCHAIN" + else + _mips_compiler + fi mkdir -p "$TEST_DIR" - PATH="$PATH:$MIPS_COMPILER/bin" make -C "$TEST_SRC" O="$TEST_DIR" MIPS_PREFIX="mips-qtmips-elf-" "$@" + make -C "$TEST_SRC" O="$TEST_DIR" MIPS_PREFIX="$PREFIX" "$@" } -- cgit v1.2.3