1#!/bin/sh
2
3set -e
4
5SOFTOP=$(cd "$(dirname "$0")"/.. && pwd)
6
7BUILDTOP=build_ut_defs
8
9rebuild_config()
10{
11    local conf="$1"
12    mkdir -p "$BUILDTOP"
13    ( set -x
14     cmake  -DINIT_CONFIG="$conf" -B "$BUILDTOP"/"$conf" -DBUILD_UNIT_TESTS=ON \
15           -DBUILD_UNIT_TESTS_HOST=ON
16
17     cmake --build "$BUILDTOP"/"$conf" -- -j"$(nproc)"
18    )
19}
20
21main()
22{
23    local defconfig
24
25    # First make sure all configurations build
26    for d in "$SOFTOP"/src/arch/xtensa/configs/*_defconfig; do
27        defconfig=$(basename "$d")
28        rebuild_config "$defconfig"
29    done
30
31    # Now run all the tests
32    for d in "$BUILDTOP"/*_defconfig; do
33        ( set -x
34         cmake --build "$d" -- test
35        )
36    done
37}
38
39main "$@"
40