From 364967634cd3c4d6d32340970e3c184c828c1f97 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 31 Mar 2022 23:19:10 +0000 Subject: [PATCH] test/topology: make tplg-build.sh callable from anywhere This removes two layers of indirection when trying to find what fails. The lack of this proved especially painful when working on #5632 and similar backports. Also move outputs to a subdirectory by default. No change when invoked from CMake which does not use the default output directory. Also show the exact m4 and alsatplg commands run when not using XARGS parallelization. Again this is critical when something fails. Signed-off-by: Marc Herbert --- scripts/build-tools.sh | 3 ++- tools/test/topology/tplg-build.sh | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/build-tools.sh b/scripts/build-tools.sh index 434109aba869..496ca4c2d7cc 100755 --- a/scripts/build-tools.sh +++ b/scripts/build-tools.sh @@ -24,7 +24,7 @@ usage: $0 [-c|-f|-h|-l|-p|-t|-T] -l Rebuild logger/ -p Rebuild probes/ -T Rebuild topology/ (not topology/development/! Use ALL) - -t Rebuild test/topology/ + -t Rebuild test/topology/ (or tools/test/topology/tplg-build.sh directly) -C No build, only CMake re-configuration. Shows CMake targets. EOFUSAGE @@ -75,6 +75,7 @@ Build commands for respective tools: probes: make -C "$BUILD_TOOLS_DIR" sof-probes topologies: make -C "$BUILD_TOOLS_DIR" topologies test tplgs: make -C "$BUILD_TOOLS_DIR" tests + (or ./tools/test/topology/tplg-build.sh directly) fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer" diff --git a/tools/test/topology/tplg-build.sh b/tools/test/topology/tplg-build.sh index 043ade4cf570..37a84e34e101 100755 --- a/tools/test/topology/tplg-build.sh +++ b/tools/test/topology/tplg-build.sh @@ -6,21 +6,25 @@ # binaries. Currently supports simple PCM <-> component <-> SSP style tests # using simple_test() -# Remove possible old topologies -rm -f test-*.conf test-*.tplg - # fail immediately on any errors set -e +MYDIR="$(cd $(dirname "$0") && pwd)" +cd "${MYDIR}" + # M4 preprocessor flags export M4PATH="../../topology/topology1:../../topology/topology1/m4:../../topology/topology1/common:../../topology/topology1/platform/intel:../../topology/topology1/platform/common" if [ -z "$SOF_TPLG_BUILD_OUTPUT" ] then - BUILD_OUTPUT="." + BUILD_OUTPUT="./build_test_topo" else BUILD_OUTPUT="$SOF_TPLG_BUILD_OUTPUT" fi +mkdir -p "$BUILD_OUTPUT" + +# Remove possible old topologies +rm -f "$BUILD_OUTPUT"/test-*.conf "$BUILD_OUTPUT"/test-*.tplg # Simple component test cases # can be used on components with 1 sink and 1 source. @@ -60,6 +64,7 @@ function simple_test { then TFILE="$i-dmic$6-${14}-$2-$4-$7-$((${13} / 1000))k-$1" echo "M4 pre-processing test $i -> ${TFILE}" + (set -x m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ -DTEST_DAI_LINK_NAME="$3" \ @@ -76,8 +81,11 @@ function simple_test { -DTEST_DMIC_PDM_CONFIG=${14} \ -DTEST_DMIC_UNMUTE_TIME=400 \ $i.m4 > "$BUILD_OUTPUT/${TFILE}.conf" + ) echo "Compiling test $i -> $BUILD_OUTPUT/${TFILE}.tplg" + (set -x alsatplg -v 1 -c "$BUILD_OUTPUT/${TFILE}.conf" -o "$BUILD_OUTPUT/${TFILE}.tplg" + ) else if [ "$USE_XARGS" == "yes" ] then @@ -123,6 +131,7 @@ function simple_test { fi fi echo "M4 pre-processing test $i -> ${TFILE}" + ( set -x m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ -DTEST_DAI_LINK_NAME="$3" \ @@ -138,8 +147,11 @@ function simple_test { -DTEST_PIPE_AMOUNT=${14} \ -DTEST_DAI_TYPE=$5 \ $i.m4 > "$BUILD_OUTPUT/${TFILE}.conf" + ) echo "Compiling test $i -> $BUILD_OUTPUT/${TFILE}.tplg" + (set -x alsatplg -v 1 -c "$BUILD_OUTPUT/${TFILE}.conf" -o "$BUILD_OUTPUT/${TFILE}.tplg" + ) fi fi fi