mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
murdock: implement test result caching
This commit is contained in:
parent
88171698e0
commit
513c8821ca
52
.murdock
52
.murdock
@ -7,11 +7,12 @@ export RIOT_CI_BUILD=1
|
|||||||
export STATIC_TESTS=${STATIC_TESTS:-1}
|
export STATIC_TESTS=${STATIC_TESTS:-1}
|
||||||
export CFLAGS_DBG=""
|
export CFLAGS_DBG=""
|
||||||
export DLCACHE_DIR=${DLCACHE_DIR:-~/.dlcache}
|
export DLCACHE_DIR=${DLCACHE_DIR:-~/.dlcache}
|
||||||
|
export ENABLE_TEST_CACHE=${ENABLE_TEST_CACHE:-1}
|
||||||
|
|
||||||
NIGHTLY=${NIGHTLY:-0}
|
NIGHTLY=${NIGHTLY:-0}
|
||||||
RUN_TESTS=${RUN_TESTS:-${NIGHTLY}}
|
RUN_TESTS=${RUN_TESTS:-${NIGHTLY}}
|
||||||
|
|
||||||
DWQ_ENV="-E BOARDS -E APPS -E NIGHTLY -E RUN_TESTS"
|
DWQ_ENV="-E BOARDS -E APPS -E NIGHTLY -E RUN_TESTS -E ENABLE_TEST_CACHE -E TEST_HASH"
|
||||||
|
|
||||||
check_label() {
|
check_label() {
|
||||||
local label="${1}"
|
local label="${1}"
|
||||||
@ -24,6 +25,10 @@ check_label() {
|
|||||||
check_label "CI: run tests" && RUN_TESTS=1
|
check_label "CI: run tests" && RUN_TESTS=1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ "$ENABLE_TEST_CACHE" = "1" ] && {
|
||||||
|
check_label "CI: disable test cache" && export ENABLE_TEST_CACHE=0
|
||||||
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
echo "$@"
|
echo "$@"
|
||||||
exit 1
|
exit 1
|
||||||
@ -138,6 +143,30 @@ print_worker() {
|
|||||||
echo "-- running on worker ${DWQ_WORKER} thread ${DWQ_WORKER_THREAD}, build number $DWQ_WORKER_BUILDNUM."
|
echo "-- running on worker ${DWQ_WORKER} thread ${DWQ_WORKER_THREAD}, build number $DWQ_WORKER_BUILDNUM."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_hash_calc() {
|
||||||
|
local bindir=$1
|
||||||
|
|
||||||
|
# Why two times cut?
|
||||||
|
# "test-input-hash.sha1" contains a list of lines containing
|
||||||
|
# "<hash> <filename>" on each line.
|
||||||
|
# We need to filter out the filename, as it contains the full path name,
|
||||||
|
# which differs depending on the build machine.
|
||||||
|
#
|
||||||
|
# After piping through sha1sum, we get "<hash> -". " -" has to go so we save the
|
||||||
|
# hassle of escaping the resulting hash.
|
||||||
|
|
||||||
|
cat ${bindir}/test-input-hash.sha1 | cut -f1 -d' ' | sha1sum | cut -f1 -d' '
|
||||||
|
}
|
||||||
|
|
||||||
|
test_cache_get() {
|
||||||
|
test "${ENABLE_TEST_CACHE}" = "1" || return 1
|
||||||
|
test -n "$(redis-cli get $1)" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
test_cache_put() {
|
||||||
|
redis-cli set "$1" ok
|
||||||
|
}
|
||||||
|
|
||||||
# compile one app for one board with one toolchain. delete intermediates.
|
# compile one app for one board with one toolchain. delete intermediates.
|
||||||
compile() {
|
compile() {
|
||||||
local appdir=$1
|
local appdir=$1
|
||||||
@ -167,7 +196,7 @@ compile() {
|
|||||||
|
|
||||||
# compile
|
# compile
|
||||||
CCACHE_BASEDIR="$(pwd)" BOARD=$board TOOLCHAIN=$toolchain RIOT_CI_BUILD=1 \
|
CCACHE_BASEDIR="$(pwd)" BOARD=$board TOOLCHAIN=$toolchain RIOT_CI_BUILD=1 \
|
||||||
make -C${appdir} clean all -j${JOBS:-4}
|
make -C${appdir} clean all test-input-hash -j${JOBS:-4}
|
||||||
RES=$?
|
RES=$?
|
||||||
|
|
||||||
# run tests
|
# run tests
|
||||||
@ -178,8 +207,15 @@ compile() {
|
|||||||
BOARD=$board make -C${appdir} test
|
BOARD=$board make -C${appdir} test
|
||||||
RES=$?
|
RES=$?
|
||||||
elif is_in_list "$board" "$TEST_BOARDS_AVAILABLE"; then
|
elif is_in_list "$board" "$TEST_BOARDS_AVAILABLE"; then
|
||||||
BOARD=$board TOOLCHAIN=$toolchain make -C${appdir} test-murdock
|
test_hash=$(test_hash_calc "$BINDIR")
|
||||||
RES=$?
|
echo "-- test_hash=$test_hash"
|
||||||
|
if test_cache_get $test_hash; then
|
||||||
|
echo "-- skipping test due to positive cache hit"
|
||||||
|
else
|
||||||
|
BOARD=$board TOOLCHAIN=$toolchain TEST_HASH=$test_hash \
|
||||||
|
make -C${appdir} test-murdock
|
||||||
|
RES=$?
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -224,6 +260,14 @@ run_test() {
|
|||||||
echo "-- executing tests for $appdir on $board (compiled with $toolchain toolchain):"
|
echo "-- executing tests for $appdir on $board (compiled with $toolchain toolchain):"
|
||||||
hook run_test_pre
|
hook run_test_pre
|
||||||
BOARD=$board TOOLCHAIN=${toolchain} make -C$appdir flash-only test
|
BOARD=$board TOOLCHAIN=${toolchain} make -C$appdir flash-only test
|
||||||
|
RES=$?
|
||||||
|
|
||||||
|
if [ $RES -eq 0 -a -n "$TEST_HASH" ]; then
|
||||||
|
echo -n "-- saving test result to cache: "
|
||||||
|
test_cache_put $TEST_HASH
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $RES
|
||||||
}
|
}
|
||||||
|
|
||||||
# execute static tests
|
# execute static tests
|
||||||
|
Loading…
Reference in New Issue
Block a user