diff --git a/CMakeLists.txt b/CMakeLists.txt index c972891ae..a37b52ebe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ set(CMAKE_CXX_SCAN_FOR_MODULES NO) set(YOSYS_COMPILER_LAUNCHER "" CACHE STRING "Compiler launcher (ccache, sccache)") option(YOSYS_ENABLE_COVERAGE "Enable code coverage" OFF) option(YOSYS_ENABLE_PROFILING "Enable instruction profiling" OFF) +option(YOSYS_ENABLE_FUNCTIONAL_TESTS "Enable running functional tests" OFF) set(YOSYS_PROGRAM_PREFIX "" CACHE STRING "Name prefix for programs, libraries, and data") set(YOSYS_COMPONENTS "everything" CACHE STRING "List of components to build (use pass names)") @@ -534,6 +535,16 @@ if (NOT YOSYS_BUILD_PYTHON_ONLY) add_custom_target(test-vanilla COMMAND make vanilla-test ${makefile_vars} + ENABLE_FUNCTIONAL_TESTS=$,1,0> + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests + DEPENDS ${makefile_depends} + USES_TERMINAL + JOB_SERVER_AWARE TRUE + ) + + add_custom_target(test-functional + COMMAND make functional ${makefile_vars} + ENABLE_FUNCTIONAL_TESTS=$,1,0> WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests DEPENDS ${makefile_depends} USES_TERMINAL diff --git a/docs/source/yosys_internals/extending_yosys/test_suites.rst b/docs/source/yosys_internals/extending_yosys/test_suites.rst index e8b6634bc..3e30d36b8 100644 --- a/docs/source/yosys_internals/extending_yosys/test_suites.rst +++ b/docs/source/yosys_internals/extending_yosys/test_suites.rst @@ -76,15 +76,19 @@ If you don't have one of the :ref:`getting_started/installation:CAD suite(s)` installed, you should also install Z3 `following their instructions `_. -.. TODO:: CMAKE_TODO +Functional tests are disabled by default, to enable them use next code snippet +and run tests as usual: - How does this work under CMake? Is it only via ``make -C tests - ENABLE_FUNCTIONAL_TESTS=1`` and then manually setting ``BUILD_DIR`` and - ``PROGRAM_PREFIX``? And possibly also setting ``YOSYS`` et al if there is a - ``.exe``. Previous instructions: +.. code:: console - Then, set the :makevar:`ENABLE_FUNCTIONAL_TESTS` make variable when calling - ``make test`` and the functional tests will be run as well. + cmake -B build . -DYOSYS_ENABLE_FUNCTIONAL_TESTS=ON + cmake --build build --target test --parallel $(nproc) + +Or run just functional tests with: + +.. code:: console + + cmake --build build --target test-functional Docs tests ~~~~~~~~~~