diff --git a/Jenkinsfile b/Jenkinsfile index c2f6407333389..a072fa71e107e 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,6 +52,7 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.Utils ci_lint = 'tlcpack/ci-lint:20220715-060127-37f9d3c49' ci_gpu = 'tlcpack/ci-gpu:20220715-060127-37f9d3c49' ci_cpu = 'tlcpack/ci-cpu:20220715-060127-37f9d3c49' +ci_minimal = 'tlcpack/ci-minimal:20220725-133226-d3cefdaf1' ci_wasm = 'tlcpack/ci-wasm:20220715-060127-37f9d3c49' ci_i386 = 'tlcpack/ci-i386:20220715-060127-37f9d3c49' ci_qemu = 'tlcpack/ci-qemu:20220630-060117-558ba99c7' @@ -66,6 +67,7 @@ properties([ parameters([ string(name: 'ci_arm_param', defaultValue: ''), string(name: 'ci_cpu_param', defaultValue: ''), + string(name: 'ci_minimal_param', defaultValue: ''), string(name: 'ci_gpu_param', defaultValue: ''), string(name: 'ci_hexagon_param', defaultValue: ''), string(name: 'ci_i386_param', defaultValue: ''), @@ -239,7 +241,7 @@ def prepare() { if (env.DETERMINE_DOCKER_IMAGES == 'yes') { sh( - script: "./tests/scripts/determine_docker_images.py ci_arm=${ci_arm} ci_cpu=${ci_cpu} ci_gpu=${ci_gpu} ci_hexagon=${ci_hexagon} ci_i386=${ci_i386} ci_lint=${ci_lint} ci_qemu=${ci_qemu} ci_wasm=${ci_wasm} ", + script: "./tests/scripts/determine_docker_images.py ci_arm=${ci_arm} ci_cpu=${ci_cpu} ci_minimal=${ci_minimal} ci_gpu=${ci_gpu} ci_hexagon=${ci_hexagon} ci_i386=${ci_i386} ci_lint=${ci_lint} ci_qemu=${ci_qemu} ci_wasm=${ci_wasm} ", label: 'Decide whether to use tlcpack or tlcpackstaging for Docker images', ) // Pull image names from the results of should_rebuild_docker.py @@ -253,6 +255,11 @@ def prepare() { label: "Find docker image name for ci_cpu", returnStdout: true, ).trim() + ci_minimal = sh( + script: "cat .docker-image-names/ci_minimal", + label: "Find docker image name for ci_minimal", + returnStdout: true, + ).trim() ci_gpu = sh( script: "cat .docker-image-names/ci_gpu", label: "Find docker image name for ci_gpu", @@ -287,6 +294,7 @@ def prepare() { ci_arm = params.ci_arm_param ?: ci_arm ci_cpu = params.ci_cpu_param ?: ci_cpu + ci_minimal = params.ci_minimal_param ?: ci_minimal ci_gpu = params.ci_gpu_param ?: ci_gpu ci_hexagon = params.ci_hexagon_param ?: ci_hexagon ci_i386 = params.ci_i386_param ?: ci_i386 @@ -298,6 +306,7 @@ def prepare() { echo "Docker images being used in this build:" echo " ci_arm = ${ci_arm}" echo " ci_cpu = ${ci_cpu}" + echo " ci_minimal = ${ci_minimal}" echo " ci_gpu = ${ci_gpu}" echo " ci_hexagon = ${ci_hexagon}" echo " ci_i386 = ${ci_i386}" @@ -448,6 +457,17 @@ def build_docker_images() { } } }, + 'ci_minimal': { + node('CPU') { + timeout(time: max_time, unit: 'MINUTES') { + init_git() + // We're purposefully not setting the built image here since they + // are not yet being uploaded to tlcpack + // ci_minimal = build_image('ci_minimal') + build_image('ci_minimal') + } + } + }, 'ci_gpu': { node('CPU') { timeout(time: max_time, unit: 'MINUTES') { @@ -594,6 +614,13 @@ def cpp_unittest(image) { ) } +def cpp_micro_unittest(image) { + sh ( + script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_cpp_unittest_micro.sh", + label: 'Build and run Micro C++ tests', + ) +} + def add_microtvm_permissions() { sh( @@ -725,6 +752,36 @@ stage('Build') { Utils.markStageSkippedForConditional('BUILD: CPU') } }, + 'BUILD: CPU MINIMAL': { + if (!skip_ci && is_docs_only_build != 1) { + node('CPU-SMALL') { + ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-cpu-minimal") { + docker_init(ci_minimal) + init_git() + sh ( + script: "${docker_run} ${ci_minimal} ./tests/scripts/task_config_build_minimal.sh build", + label: 'Create CPU minimal cmake config', + ) + make(ci_minimal, 'build', '-j2') + sh( + script: """ + set -eux + md5sum build/libtvm.so + aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/cpu-minimal/build/libtvm.so + md5sum build/libtvm_runtime.so + aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/cpu-minimal/build/libtvm_runtime.so + md5sum build/config.cmake + aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/cpu-minimal/build/config.cmake + """, + label: 'Upload artifacts to S3', + ) + + } + } + } else { + Utils.markStageSkippedForConditional('BUILD: CPU MINIMAL') + } + }, 'BUILD: WASM': { if (!skip_ci && is_docs_only_build != 1) { node('CPU-SMALL') { @@ -737,6 +794,7 @@ stage('Build') { ) make(ci_wasm, 'build', '-j2') cpp_unittest(ci_wasm) + cpp_micro_unittest(ci_wasm) timeout(time: max_time, unit: 'MINUTES') { ci_setup(ci_wasm) sh ( @@ -919,6 +977,7 @@ def shard_run_unittest_GPU_1_of_3() { ) cpp_unittest(ci_gpu) + cpp_micro_unittest(ci_gpu) sh( script: """ @@ -937,6 +996,7 @@ def shard_run_unittest_GPU_1_of_3() { ci_setup(ci_gpu) cpp_unittest(ci_gpu) + cpp_micro_unittest(ci_gpu) sh ( script: "${docker_run} ${ci_gpu} ./tests/scripts/task_python_unittest_gpuonly.sh", label: 'Run Python GPU unit tests', @@ -1436,6 +1496,7 @@ def shard_run_python_i386_1_of_5() { ci_setup(ci_i386) cpp_unittest(ci_i386) + cpp_micro_unittest(ci_i386) python_unittest(ci_i386) sh ( script: "${docker_run} ${ci_i386} ./tests/scripts/task_python_integration_i386only.sh", @@ -1704,6 +1765,7 @@ def shard_run_test_Hexagon_1_of_7() { add_hexagon_permissions() ci_setup(ci_hexagon) cpp_unittest(ci_hexagon) + cpp_micro_unittest(ci_hexagon) sh ( script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_python_hexagon.sh", label: 'Run Hexagon tests', @@ -2805,6 +2867,7 @@ def shard_run_topi_aarch64_1_of_2() { ci_setup(ci_arm) cpp_unittest(ci_arm) + cpp_micro_unittest(ci_arm) sh ( script: "${docker_run} ${ci_arm} ./tests/scripts/task_python_arm_compute_library.sh", label: 'Run test_arm_compute_lib test', @@ -2995,6 +3058,49 @@ def shard_run_frontend_aarch64_2_of_2() { } +def run_unittest_minimal() { + if (!skip_ci && is_docs_only_build != 1) { + node('CPU-SMALL') { + ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/ut-python-cpu-minimal") { + timeout(time: max_time, unit: 'MINUTES') { + try { + docker_init(ci_minimal) + init_git() + withEnv(['PLATFORM=minimal'], { + sh( + script: """ + set -eux + aws s3 cp --no-progress s3://${s3_prefix}/cpu-minimal/build/libtvm.so build/libtvm.so + md5sum build/libtvm.so + aws s3 cp --no-progress s3://${s3_prefix}/cpu-minimal/build/libtvm_runtime.so build/libtvm_runtime.so + md5sum build/libtvm_runtime.so + aws s3 cp --no-progress s3://${s3_prefix}/cpu-minimal/build/config.cmake build/config.cmake + md5sum build/config.cmake + """, + label: 'Download artifacts from S3', + ) + + cpp_unittest(ci_minimal) + python_unittest(ci_minimal) + }) + } finally { + sh( + script: """ + set -eux + aws s3 cp --no-progress build/pytest-results s3://${s3_prefix}/pytest-results --recursive + """, + label: 'Upload JUnits to S3', + ) + + junit 'build/pytest-results/*.xml' + } + } + } + } + } else { + Utils.markStageSkippedForConditional('unittest: CPU MINIMAL') + } +} def test() { stage('Test') { @@ -3119,6 +3225,9 @@ stage('Test') { 'frontend: aarch64 2 of 2': { shard_run_frontend_aarch64_2_of_2() }, + 'unittest: CPU MINIMAL': { + run_unittest_minimal() + }, 'unittest: CPU': { if (!skip_ci && is_docs_only_build != 1) { node('CPU-SMALL') { @@ -3147,6 +3256,7 @@ stage('Test') { ci_setup(ci_cpu) cpp_unittest(ci_cpu) + cpp_micro_unittest(ci_cpu) python_unittest(ci_cpu) fsim_test(ci_cpu) sh ( @@ -3198,6 +3308,7 @@ stage('Test') { add_microtvm_permissions() ci_setup(ci_qemu) cpp_unittest(ci_qemu) + cpp_micro_unittest(ci_qemu) sh ( script: "${docker_run} ${ci_qemu} ./tests/scripts/task_python_microtvm.sh", label: 'Run microTVM tests', @@ -3439,6 +3550,7 @@ def deploy() { def tag = "${date_Ymd_HMS}-${upstream_revision.substring(0, 8)}" update_docker(ci_arm, "tlcpackstaging/ci_arm:${tag}") update_docker(ci_cpu, "tlcpackstaging/ci_cpu:${tag}") + update_docker(ci_minimal, "tlcpackstaging/ci_minimal:${tag}") update_docker(ci_gpu, "tlcpackstaging/ci_gpu:${tag}") update_docker(ci_hexagon, "tlcpackstaging/ci_hexagon:${tag}") update_docker(ci_i386, "tlcpackstaging/ci_i386:${tag}") diff --git a/ci/jenkins/Build.groovy.j2 b/ci/jenkins/Build.groovy.j2 index fcde53f559395..2694dd299a846 100644 --- a/ci/jenkins/Build.groovy.j2 +++ b/ci/jenkins/Build.groovy.j2 @@ -33,6 +33,13 @@ def cpp_unittest(image) { ) } +def cpp_micro_unittest(image) { + sh ( + script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_cpp_unittest_micro.sh", + label: 'Build and run Micro C++ tests', + ) +} + def add_microtvm_permissions() { {% for folder in microtvm_template_projects %} @@ -123,6 +130,24 @@ stage('Build') { Utils.markStageSkippedForConditional('BUILD: CPU') } }, + 'BUILD: CPU MINIMAL': { + if (!skip_ci && is_docs_only_build != 1) { + node('CPU-SMALL') { + ws({{ m.per_exec_ws('tvm/build-cpu-minimal') }}) { + docker_init(ci_minimal) + init_git() + sh ( + script: "${docker_run} ${ci_minimal} ./tests/scripts/task_config_build_minimal.sh build", + label: 'Create CPU minimal cmake config', + ) + make(ci_minimal, 'build', '-j2') + {{ m.upload_artifacts(tag='cpu-minimal', filenames=tvm_lib) }} + } + } + } else { + Utils.markStageSkippedForConditional('BUILD: CPU MINIMAL') + } + }, 'BUILD: WASM': { if (!skip_ci && is_docs_only_build != 1) { node('CPU-SMALL') { @@ -135,6 +160,7 @@ stage('Build') { ) make(ci_wasm, 'build', '-j2') cpp_unittest(ci_wasm) + cpp_micro_unittest(ci_wasm) timeout(time: max_time, unit: 'MINUTES') { ci_setup(ci_wasm) sh ( diff --git a/ci/jenkins/Jenkinsfile.j2 b/ci/jenkins/Jenkinsfile.j2 index 45b7565bf5b54..e7ca72166c240 100644 --- a/ci/jenkins/Jenkinsfile.j2 +++ b/ci/jenkins/Jenkinsfile.j2 @@ -54,6 +54,7 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.Utils ci_lint = 'tlcpack/ci-lint:20220715-060127-37f9d3c49' ci_gpu = 'tlcpack/ci-gpu:20220715-060127-37f9d3c49' ci_cpu = 'tlcpack/ci-cpu:20220715-060127-37f9d3c49' +ci_minimal = 'tlcpack/ci-minimal:20220725-133226-d3cefdaf1' ci_wasm = 'tlcpack/ci-wasm:20220715-060127-37f9d3c49' ci_i386 = 'tlcpack/ci-i386:20220715-060127-37f9d3c49' ci_qemu = 'tlcpack/ci-qemu:20220630-060117-558ba99c7' diff --git a/ci/jenkins/Test.groovy.j2 b/ci/jenkins/Test.groovy.j2 index d219b47bc7929..e5a14439d8786 100644 --- a/ci/jenkins/Test.groovy.j2 +++ b/ci/jenkins/Test.groovy.j2 @@ -16,10 +16,12 @@ {% if shard_index == 1 %} {{ m.download_artifacts(tag='gpu2', filenames=tvm_multilib) }} cpp_unittest(ci_gpu) + cpp_micro_unittest(ci_gpu) {{ m.download_artifacts(tag='gpu', filenames=tvm_multilib) }} ci_setup(ci_gpu) cpp_unittest(ci_gpu) + cpp_micro_unittest(ci_gpu) {% else %} {{ m.download_artifacts(tag='gpu', filenames=tvm_multilib) }} ci_setup(ci_gpu) @@ -68,6 +70,7 @@ ci_setup(ci_i386) {% if shard_index == 1 %} cpp_unittest(ci_i386) + cpp_micro_unittest(ci_i386) {% endif %} python_unittest(ci_i386) sh ( @@ -92,6 +95,7 @@ ci_setup(ci_hexagon) {% if shard_index == 1 %} cpp_unittest(ci_hexagon) + cpp_micro_unittest(ci_hexagon) {% endif %} sh ( script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_python_hexagon.sh", @@ -160,6 +164,7 @@ ci_setup(ci_arm) {% if shard_index == 1 %} cpp_unittest(ci_arm) + cpp_micro_unittest(ci_arm) {% endif %} sh ( script: "${docker_run} ${ci_arm} ./tests/scripts/task_python_arm_compute_library.sh", @@ -187,6 +192,19 @@ ) {% endcall %} +def run_unittest_minimal() { + {% call m.test_step_body( + name="unittest: CPU MINIMAL", + node="CPU-SMALL", + ws="tvm/ut-python-cpu-minimal", + platform="minimal", + docker_image="ci_minimal", + ) %} + {{ m.download_artifacts(tag='cpu-minimal', filenames=tvm_lib) }} + cpp_unittest(ci_minimal) + python_unittest(ci_minimal) + {% endcall %} +} def test() { stage('Test') { @@ -199,6 +217,9 @@ stage('Test') { {{ method_name }}() }, {% endfor %} + 'unittest: CPU MINIMAL': { + run_unittest_minimal() + }, {% call m.test_step( name="unittest: CPU", node="CPU-SMALL", @@ -209,6 +230,7 @@ stage('Test') { {{ m.download_artifacts(tag='cpu', filenames=tvm_multilib_tsim) }} ci_setup(ci_cpu) cpp_unittest(ci_cpu) + cpp_micro_unittest(ci_cpu) python_unittest(ci_cpu) fsim_test(ci_cpu) sh ( @@ -227,6 +249,7 @@ stage('Test') { add_microtvm_permissions() ci_setup(ci_qemu) cpp_unittest(ci_qemu) + cpp_micro_unittest(ci_qemu) sh ( script: "${docker_run} ${ci_qemu} ./tests/scripts/task_python_microtvm.sh", label: 'Run microTVM tests', diff --git a/ci/jenkins/generate.py b/ci/jenkins/generate.py index 686e44e14dd52..a2d6de4a2952a 100644 --- a/ci/jenkins/generate.py +++ b/ci/jenkins/generate.py @@ -40,6 +40,10 @@ "name": "ci_cpu", "platform": "CPU", }, + { + "name": "ci_minimal", + "platform": "CPU", + }, { "name": "ci_gpu", "platform": "CPU", diff --git a/ci/jenkins/macros.j2 b/ci/jenkins/macros.j2 index 5d996ce19a559..406659dc25595 100644 --- a/ci/jenkins/macros.j2 +++ b/ci/jenkins/macros.j2 @@ -83,6 +83,28 @@ def {{ method_name }}() { {% endfor %} {% endmacro %} +{% macro test_step_body(name, node, ws, docker_image, platform) %} + if (!skip_ci && is_docs_only_build != 1) { + node('{{ node }}') { + ws({{ per_exec_ws(ws) }}) { + timeout(time: max_time, unit: 'MINUTES') { + try { + docker_init({{ docker_image }}) + init_git() + withEnv(['PLATFORM={{ platform }}'], { + {{ caller() | indent(width=8) | trim }} + }) + } finally { + {{ junit_to_s3() | indent(width=0) }} + junit 'build/pytest-results/*.xml' + } + } + } + } + } else { + Utils.markStageSkippedForConditional('{{ name }}') + } +{% endmacro %} {% macro test_step(name, node, ws, docker_image, platform) %} '{{ name }}': { diff --git a/tests/python/ci/test_ci.py b/tests/python/ci/test_ci.py index 0ed3f17015064..701910c826c17 100644 --- a/tests/python/ci/test_ci.py +++ b/tests/python/ci/test_ci.py @@ -910,6 +910,7 @@ def test_open_docker_update_pr( "ci_lint", "ci_gpu", "ci_cpu", + "ci_minimal", "ci_wasm", "ci_i386", "ci_qemu", diff --git a/tests/python/unittest/test_meta_schedule_task_scheduler.py b/tests/python/unittest/test_meta_schedule_task_scheduler.py index ad4e78b68f185..4830d42fc87e7 100644 --- a/tests/python/unittest/test_meta_schedule_task_scheduler.py +++ b/tests/python/unittest/test_meta_schedule_task_scheduler.py @@ -23,6 +23,7 @@ import pytest import tvm import tvm.testing +from tvm.support import libinfo from tvm import meta_schedule as ms from tvm._ffi.base import TVMError from tvm.meta_schedule.testing.dummy_object import DummyBuilder, DummyRunner @@ -337,7 +338,18 @@ def test_meta_schedule_task_scheduler_override_next_task_id_only(): # pylint: d ) -@pytest.mark.skip("Does array access OOB") +def should_skip_oob_test(): + flags = libinfo() + # TODO(gigiblender) This combination of flags should be enabled only in the ci_minimal CI configuration. + # Remove this once the OOB test is fixed. + return ( + flags["USE_RELAY_DEBUG"] == "ON" + and flags["USE_LLVM"] == "llvm-config" + and flags["USE_MICRO"] != "ON" + ) + + +@pytest.mark.skipif(should_skip_oob_test(), reason="Does array access OOB. Remove once fixed.") def test_meta_schedule_task_scheduler_multiple_gradient_based(): num_trials_per_iter = 6 max_trials_per_task = 101 diff --git a/tests/scripts/ci.py b/tests/scripts/ci.py index 60f5cf9ab626a..1e55b5bae3bbb 100755 --- a/tests/scripts/ci.py +++ b/tests/scripts/ci.py @@ -556,6 +556,10 @@ def add_subparser( CPP_UNITTEST = ("run c++ unitests", ["./tests/scripts/task_cpp_unittest.sh {build_dir}"]) +CPP_MICRO_UNITTEST = ( + "run micro c++ unitests", + ["./tests/scripts/task_cpp_unittest_micro.sh {build_dir}"], +) generated = [ generate_command( @@ -563,6 +567,7 @@ def add_subparser( help="Run GPU build and test(s)", options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "topi": ("run topi tests", ["./tests/scripts/task_python_topi.sh"]), "unittest": ( "run unit tests", @@ -580,6 +585,7 @@ def add_subparser( help="Run CPU build and test(s)", options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "integration": ( "run integration tests", ["./tests/scripts/task_python_integration.sh"], @@ -613,6 +619,7 @@ def add_subparser( help="Run i386 build and test(s)", options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "integration": ( "run integration tests", [ @@ -627,6 +634,7 @@ def add_subparser( help="Run WASM build and test(s)", options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "test": ("run WASM tests", ["./tests/scripts/task_web_wasm.sh"]), }, ), @@ -635,6 +643,7 @@ def add_subparser( help="Run QEMU build and test(s)", options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "test": ( "run microTVM tests", [ @@ -650,6 +659,7 @@ def add_subparser( post_build=["./tests/scripts/task_build_hexagon_api.sh --output build-hexagon"], options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "test": ( "run Hexagon API/Python tests", [ @@ -664,6 +674,7 @@ def add_subparser( precheck=check_arm_qemu, options={ "cpp": CPP_UNITTEST, + "micro_cpp": CPP_MICRO_UNITTEST, "python": ( "run full Python tests", [ diff --git a/tests/scripts/task_config_build_minimal.sh b/tests/scripts/task_config_build_minimal.sh index 21582cc752c22..651f54cea21bb 100755 --- a/tests/scripts/task_config_build_minimal.sh +++ b/tests/scripts/task_config_build_minimal.sh @@ -26,6 +26,7 @@ cp ../cmake/config.cmake . echo set\(USE_SORT ON\) >> config.cmake echo set\(USE_LLVM llvm-config\) >> config.cmake echo set\(USE_RELAY_DEBUG ON\) >> config.cmake +echo set\(CMAKE_BUILD_TYPE=Debug\) >> config.cmake echo set\(CMAKE_CXX_FLAGS \"-Werror -Wp,-D_GLIBCXX_ASSERTIONS\"\) >> config.cmake echo set\(HIDE_PRIVATE_SYMBOLS ON\) >> config.cmake echo set\(USE_LIBBACKTRACE ON\) >> config.cmake diff --git a/tests/scripts/task_cpp_unittest.sh b/tests/scripts/task_cpp_unittest.sh index ade05b9e461f8..a96e6ec5e4776 100755 --- a/tests/scripts/task_cpp_unittest.sh +++ b/tests/scripts/task_cpp_unittest.sh @@ -45,23 +45,7 @@ python3 tests/scripts/task_build.py \ --cmake-target cpptest \ --build-dir "${BUILD_DIR}" -# crttest requires USE_MICRO to be enabled. -if grep -Fq "set(USE_MICRO ON)" ${BUILD_DIR}/config.cmake; then - pushd "${BUILD_DIR}" - ninja crttest - popd -fi - - pushd "${BUILD_DIR}" ctest --gtest_death_test_style=threadsafe popd -# Test MISRA-C runtime. It requires USE_MICRO to be enabled. -if grep -Fq "set(USE_MICRO ON)" ${BUILD_DIR}/config.cmake; then - pushd apps/bundle_deploy - rm -rf build - make test_dynamic test_static - popd -fi - diff --git a/tests/scripts/task_cpp_unittest_micro.sh b/tests/scripts/task_cpp_unittest_micro.sh new file mode 100755 index 0000000000000..53bb55ca2a3da --- /dev/null +++ b/tests/scripts/task_cpp_unittest_micro.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +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 + +export LD_LIBRARY_PATH="lib:${LD_LIBRARY_PATH:-}" +# NOTE: important to use abspath, when VTA is enabled. +export VTA_HW_PATH=`pwd`/3rdparty/vta-hw + +# to avoid CI thread throttling. +export TVM_BIND_THREADS=0 +export OMP_NUM_THREADS=1 + +# Build cpptest suite +python3 tests/scripts/task_build.py \ + --sccache-bucket tvm-sccache-prod \ + --cmake-target cpptest \ + --build-dir "${BUILD_DIR}" + +# crttest +pushd "${BUILD_DIR}" +ninja crttest +popd + +# Test MISRA-C runtime. +pushd apps/bundle_deploy +rm -rf build +make test_dynamic test_static +popd +