diff --git a/tests/scripts/ci.py b/tests/scripts/ci.py index 1ffd2d20e7ae..022d19200232 100755 --- a/tests/scripts/ci.py +++ b/tests/scripts/ci.py @@ -372,12 +372,14 @@ def fn( if precheck is not None: precheck() + build_dir = get_build_dir(name) + if skip_build: scripts = [] else: scripts = [ - f"./tests/scripts/task_config_build_{name}.sh {get_build_dir(name)}", - f"./tests/scripts/task_build.py --build-dir {get_build_dir(name)}", + f"./tests/scripts/task_config_build_{name}.sh {build_dir}", + f"./tests/scripts/task_build.py --build-dir {build_dir}", ] if post_build is not None: @@ -394,7 +396,7 @@ def fn( # Add named test suites for option_name, (_, extra_scripts) in options.items(): if kwargs.get(option_name, False): - scripts += extra_scripts + scripts.extend(script.format(build_dir=build_dir) for script in extra_scripts) docker( name=gen_name(f"ci-{name}"), @@ -553,7 +555,7 @@ def add_subparser( return subparser -CPP_UNITTEST = ("run c++ unitests", ["./tests/scripts/task_cpp_unittest.sh"]) +CPP_UNITTEST = ("run c++ unitests", ["./tests/scripts/task_cpp_unittest.sh {build_dir}"]) generated = [ generate_command( @@ -610,7 +612,10 @@ def add_subparser( generate_command( name="wasm", help="Run WASM build and test(s)", - options={"test": ("run WASM tests", ["./tests/scripts/task_web_wasm.sh"])}, + options={ + "cpp": CPP_UNITTEST, + "test": ("run WASM tests", ["./tests/scripts/task_web_wasm.sh"]), + }, ), generate_command( name="qemu", diff --git a/tests/scripts/task_cpp_unittest.sh b/tests/scripts/task_cpp_unittest.sh index a28efb0328ec..8ae2e9b1109f 100755 --- a/tests/scripts/task_cpp_unittest.sh +++ b/tests/scripts/task_cpp_unittest.sh @@ -18,6 +18,16 @@ set -euxo pipefail +if [ $# -gt 0 ]; then + BUILD_DIR="$1" +elif [ -n "${TVM_BUILD_PATH:-}" ]; then + # TVM_BUILD_PATH may contain multiple space-separated paths. If + # so, use the first one. + BUILD_DIR=$(IFS=" "; set -- $TVM_BUILD_PATH; echo $1) +else + BUILD_DIR=build +fi + # Python is required by apps/bundle_deploy source tests/scripts/setup-pytest-env.sh @@ -32,16 +42,17 @@ export OMP_NUM_THREADS=1 # Build cpptest suite python3 tests/scripts/task_build.py \ --sccache-bucket tvm-sccache-prod \ - --cmake-target cpptest + --cmake-target cpptest \ + --build-dir "${BUILD_DIR}" # crttest requires USE_MICRO to be enabled, which is currently the case # with all CI configs -pushd build +pushd "${BUILD_DIR}" ninja crttest popd -pushd build +pushd "${BUILD_DIR}" ctest --gtest_death_test_style=threadsafe popd