diff --git a/.github/workflows/build-cloe.yaml b/.github/workflows/build-cloe.yaml index 8e90c07ce..e25e7c130 100644 --- a/.github/workflows/build-cloe.yaml +++ b/.github/workflows/build-cloe.yaml @@ -28,9 +28,20 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04] - build_type: [RelWithDebInfo] - package_target: [package] + os: + - "ubuntu-20.04" + - "ubuntu-22.04" + conan_profile: + - "cloe-normal" + package_target: + # 1. Build each test configuration in Conan cache and run all tests + - "export-all smoketest-deps smoketest" + + # 2. Build cloe super-package in editable mode and run tests + - "editable all smoketest TEST_CONANFILES=tests/conanfile_all.py" + + # 3. Build individual packages in editable mode and run tests + - "editable-select build-all smoketest TEST_CONANFILES=tests/conanfile_split.py" env: CONAN_NON_INTERACTIVE: "yes" DEBIAN_FRONTEND: noninteractive @@ -59,12 +70,9 @@ jobs: - name: Configure Conan run: | make setup-conan - - name: Build cloe w/ package + conan config set general.default_profile=${{ matrix.conan_profile }} + conan config set general.default_build_profile=${{ matrix.conan_profile }} + make export-cli + - name: Build cloe run: | make ${{ matrix.package_target }} - - name: Build smoketest dependencies - run: | - make smoketest-deps - - name: Run smoketests - run: | - make smoketest diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..dc0096ad9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +# This CMakeLists.txt configures a super-build containing everything +# from this repo. +# +# It is currently experimental. +# + +cmake_minimum_required(VERSION 3.15 FATAL_ERROR) + +project(cloe LANGUAGES CXX) + +set(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/runtime/cmake") + +# Since a super-build does not export packages individually via Conan, +# we cannot depend on Conan-generated CMake config files, instead we +# use the CMake targets directly as if they were already found. +set(CLOE_FIND_PACKAGES OFF CACHE BOOL "Call find_package() for cloe packages" FORCE) + +# Ensure output goes to one place so cloe-launch can find the plugins +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) + +# Ensure we can test from this level. +include(CTest) + +add_subdirectory(fable) +add_subdirectory(runtime) +add_subdirectory(models) +add_subdirectory(oak) +add_subdirectory(engine) +add_subdirectory(plugins) diff --git a/Makefile b/Makefile index ee93372a1..6b8106100 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ # This file contains Makefile targets for the cloe project. # +# Make configuration: +SHELL := /bin/bash +GNUMAKEFLAGS := --no-print-directory +SUBMAKEFLAGS := + CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch @@ -20,78 +25,96 @@ AG := $(or \ # Build configuration: BUILD_DIR := build -LOCKFILE_SOURCE := conanfile.py -BUILD_LOCKFILE := ${BUILD_DIR}/conan.lock -LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${BUILD_LOCKFILE}" INSTALL_DIR := /usr/local CONAN_OPTIONS := +# Lockfile for cloe-meta: +META_LOCKFILE_SOURCE := meta/conanfile.py +META_BUILD_LOCKFILE := meta/build/conan.lock +META_LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${META_BUILD_LOCKFILE}" + .DEFAULT_GOAL := help .PHONY: help .SILENT: help help:: $(call print_help_usage) echo + $(call print_help_section, "Default target") + $(call print_help_target, help, "show this help on available targets") + echo # Setup targets --------------------------------------------------------------- include Makefile.setup +${META_BUILD_LOCKFILE}: + ${MAKE} -C meta LOCKFILE_SOURCE=conanfile.py lockfile + +.PHONY: lockfile +lockfile: ${META_BUILD_LOCKFILE} + # Workspace targets ----------------------------------------------------------- help:: $(call print_help_section, "Available workspace targets") - $(call print_help_target, status, "show status of each of the Conan packages") - $(call print_help_target, smoketest-deps, "build system test pre-requisites") - $(call print_help_target, smoketest, "run system tests") - $(call print_help_target, docs, "generate documentation") - $(call print_help_target, deploy, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]") - $(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}") - $(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe") + $(call print_help_target, docs, "generate Doxygen and Sphinx documentation") echo -${BUILD_LOCKFILE}: - ${MAKE} -f Makefile.package SOURCE_CONANFILE=/dev/null LOCKFILE_SOURCE=${LOCKFILE_SOURCE} ${BUILD_LOCKFILE} - -.PHONY: lockfile -lockfile: ${BUILD_LOCKFILE} +.PHONY: docs +docs: + $(call print_header, "Generating Doxygen documentation...") + ${MAKE} -C docs doxygen + $(call print_header, "Generating Sphinx documentation...") + ${MAKE} -C docs html -.PHONY: status -status: ${BUILD_LOCKFILE} - @for pkg in ${ALL_PKGS}; do \ - [ -d $${pkg} ] || continue; \ - ${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${LOCKFILE_OPTION} -C $${pkg} status || true; \ - done +help:: + $(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe") + $(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}") + echo -.PHONY: deploy -deploy: - $(call print_header, "Deploying binaries to ${INSTALL_DIR}...") - conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy . - mkdir -p ${INSTALL_DIR} - cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/ +.PHONY: export-cli +export-cli: + ${MAKE} -C cli export .PHONY: deploy-cli deploy-cli: $(call print_header, "Deploying cloe-launch binary with pip...") ${MAKE} -C cli install -.PHONY: export-cli -export-cli: - ${MAKE} -C cli export +help:: + $(call print_help_target, lockfile, "create a lockfile for cloe-meta package") + $(call print_help_target, status-all, "show status of each of the Conan packages") + $(call print_help_target, export-all, "export all package sources to Conan cache") + $(call print_help_target, build-all, "build individual packages locally in-source") + $(call print_help_target, deploy-all, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]") + $(call print_help_target, clean-all, "clean entire repository of temporary files") + $(call print_help_target, purge-all, "remove all cloe packages (in any version) from Conan cache") + echo -export: export-cli -package: export-cli +.PHONY: build-all +build-all: lockfile + ${MAKE} all-select UNSELECT_PKGS="meta" CONAN_OPTIONS="${CONAN_OPTIONS} ${META_LOCKFILE_OPTION}" -.PHONY: docs -docs: - $(call print_header, "Generating Doxygen documentation...") - ${MAKE} -C docs doxygen - $(call print_header, "Generating Sphinx documentation...") - ${MAKE} -C docs html +.PHONY: status-all +status-all: ${META_BUILD_LOCKFILE} + @for pkg in ${ALL_PKGS}; do \ + [ -d $${pkg} ] || continue; \ + ${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${META_LOCKFILE_OPTION} -C $${pkg} status || true; \ + done -.PHONY: smoketest-deps -smoketest-deps: export-cli smoketest-deps-select +.PHONY: export-all +export-all: + $(call print_header, "Exporting all cloe Conan packages...") + ${MAKE} export-select export-cli export -.PHONY: smoketest -smoketest: smoketest-select +.PHONY: deploy-all +deploy-all: + $(call print_header, "Deploying binaries to ${INSTALL_DIR}...") + conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy . + mkdir -p ${INSTALL_DIR} + cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/ + +.PHONY: clean-all +clean-all: + ${MAKE} clean clean-select .PHONY: purge-all purge-all: @@ -122,6 +145,8 @@ todos: ${AG} FIXME ${AG} XXX +# Hidden development targets -------------------------------------------------- + .PHONY: grep-uuids grep-uuids: ${AG} "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b" @@ -134,5 +159,12 @@ find-missing-eol: sanitize-files: git grep --cached -Ilz '' | while IFS= read -rd '' f; do tail -c1 < "$$f" | read -r _ || echo >> "$$f"; done -# Build targets --------------------------------------------------------------- +# Micro-packages build targets ------------------------------------------------ include Makefile.all + +# Mono-package build targets -------------------------------------------------- +DISABLE_HELP_PREAMBLE := true +help:: + @printf "Available $(_yel)cloe$(_rst) package targets:\n" + +include Makefile.package diff --git a/Makefile.all b/Makefile.all index ef48dc0ee..756786f89 100644 --- a/Makefile.all +++ b/Makefile.all @@ -35,8 +35,8 @@ SHELL := /bin/bash GNUMAKEFLAGS := --no-print-directory SUBMAKEFLAGS := -META_PKG := cloe -PLUGIN_PKGS := $(wildcard plugins/*) +META_PKG := meta +PLUGIN_PKGS := plugins/basic plugins/gndtruth_extractor plugins/minimator plugins/mocks plugins/noisy_sensor plugins/speedometer plugins/virtue ALL_PKGS := fable runtime models oak engine ${PLUGIN_PKGS} ${META_PKG} WITHOUT_PKGS := UNSELECT_PKGS := ${WITHOUT_PKGS} @@ -62,6 +62,7 @@ models: runtime oak: runtime engine: models oak ${PLUGIN_PKGS}: runtime models +${META_PKG}: fable runtime models oak engine ${PLUGIN_PKGS} ## BUILD_POLICY ## Usage: make BUILD_POLICY="missing" @@ -106,22 +107,13 @@ ${1}-each: ${4} endef REGEX_TARGET := 's/(-vendor|-select)?-each//' -$(filter-out ${META_PKG}, ${ALL_PKGS} ${ALL_VENDOR}): +${ALL_PKGS} ${ALL_VENDOR}: ${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET}) -# Re-define ${META_PKG} target to use Makefile.package, and only run for targets -# where it makes sense, since "${META_PKG}" is a Conan meta-package. -${META_PKG}: - for case in export package package-outdated list purge clean smoketest smoketest-deps; do \ - if [ "$$(echo '${MAKECMDGOALS}' | sed -re ${REGEX_TARGET})" == "$${case}" ]; then \ - ${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS}" $${case} || exit 1; \ - fi \ - done - # Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) -# define make_vendor_target -# $(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) -# endef +define make_vendor_target +$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) +endef # Usage: $(call make_every_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define make_every_target @@ -139,19 +131,16 @@ endef .PHONY: help .SILENT: help help:: - $(call print_help_section, "Available build targets") - -# $(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") -# $(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") -# $(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") + $(call print_help_section, "Available multi-package targets") +ifneq "${ALL_VENDOR}" "" help:: - echo - -$(call make_every_target, export, "export all package recipes", "[conan-cache]") +$(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") +$(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") +$(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") help:: - $(call print_help_target, package, "create ${META_PKG} package and plugins", "[conan-cache]") echo +endif $(call make_select_target, export-select, "export selected packages", "[conan-cache]") $(call make_select_target, package-select, "create selected packages with policy", "[conan-cache]") @@ -179,34 +168,19 @@ $(call make_select_target, clean-select, "remove build artifacts", "[in-source]" help:: echo $(call print_help_subsection, "Options") -# $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}") +ifneq "${ALL_VENDOR}" "" + $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}") +endif $(call print_help_option, WITH_PKGS, "", "include optional packages from ${_grn}UNSELECT_PKGS${_rst}") $(call print_help_option, LOCKFILE_SOURCE, "", "use specified conanfile as lockfile source for build") echo $(call print_help_subsection, "Defines") $(call print_help_option, BUILD_POLICY, ${BUILD_POLICY}) $(call print_help_define, CONAN_OPTIONS, ${CONAN_OPTIONS}) -# $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR}) -# $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR}) +ifneq "${ALL_VENDOR}" "" + $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR}) + $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR}) +endif $(call print_help_define_lines, UNSELECT_PKGS, ${UNSELECT_PKGS}) $(call print_help_define_lines, SELECT_PKGS, ${SELECT_PKGS}) echo - -.PHONY: package -package: export-select - # Build cloe with all targets and options together. - # - # This is different from the package target in that it always builds the - # packages from this workspace, the ones in SELECT_PKGS. - # This is different from the package-select target in that it builds them - # all together and thereby uses the correct dependency resolution with - # overrides and options. - TARGETS=$$( \ - for pkg in ${SELECT_PKGS}; do \ - if [ ! -d $${pkg} ]; then \ - continue; \ - fi; \ - echo -n "--build=$$(make --no-print-directory -C $${pkg} info-name) "; \ - done; \ - ) && \ - ${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS} $$TARGETS" package diff --git a/README.md b/README.md index 030f907b5..01734fc20 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,15 @@ See the Conan [documentation][6] for more information on how to do this. To build all packages, you should run the following: - make package + make export-all + make -C meta package This will export all Conan recipes from this repository and create the cloe package. Conan will download and build all necessary dependencies. Should any errors occur during the build, you may have to force Conan to build all packages instead of re-using packages it finds: ``` - make package CONAN_OPTIONS="--build" + make -C meta package CONAN_OPTIONS="--build" ``` Run `make help` to get an overview of the available targets we expect you to use. For more details on how this is done, have a look at the Makefiles in the @@ -166,7 +167,7 @@ Note that the above examples show the verbose output of the `cloe-launch` tool. Integration and system tests can be run to ensure that all the packages built are working together as expected: - make smoketest-deps + make export-all smoketest-deps make smoketest This will build packages in the required configurations as defined by the diff --git a/conanfile.py b/conanfile.py index 42e1464f5..b7ede528f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,7 +1,9 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path +from semver import SemVer from conan import ConanFile from conan.tools import cmake, files, scm @@ -16,22 +18,56 @@ class Cloe(ConanFile): description = "Closed-loop automated driving simulation environment" topics = ["simulation"] settings = "os", "compiler", "build_type", "arch" + provides = ( + "fable", + "cloe-runtime", + "cloe-models", + "cloe-oak", + "cloe-engine", + "cloe-plugins-core", + "cloe-plugin-basic", + "cloe-plugin-gndtruth-extractor", + "cloe-plugin-minimator", + "cloe-plugin-mocks", + "cloe-plugin-noisy-sensor", + "cloe-plugin-speedometer", + "cloe-plugin-virtue", + ) options = { - "with_vtd": [True, False], - "with_engine": [True, False], - - # Doesn't affect package ID: - "pedantic": [True, False], + "shared": [True, False], + "fPIC": [True, False], + "fable_allow_comments": [True, False], + "engine_server": [True, False], + "engine_lrdb": [True, False] } default_options = { - "with_vtd": False, - "with_engine": True, - - "pedantic": True, - - "cloe-engine:server": True, + "shared": True, + "fPIC": True, + "fable_allow_comments": True, + "engine_server": True, + "engine_lrdb": True, } + generators = "CMakeDeps", "VirtualRunEnv" no_copy_source = True + exports_sources = [ + "*/cmake/*", + "*/src/*", + "*/include/*", + "*/CMakeLists.txt", + + "fable/examples/*", + + "engine/lua/*", + "engine/webui/*", + "engine/vendor/*", + + "plugins/*/src/*", + "plugins/*/include/*", + "plugins/*/ui/*", + "plugins/*/CMakeLists.txt", + + "CMakelists.txt" + ] def set_version(self): version_file = Path(self.recipe_folder) / "VERSION" @@ -42,31 +78,120 @@ def set_version(self): self.version = git.run("describe --dirty=-dirty")[1:] def requirements(self): - def cloe_requires(dep): - self.requires(f"{dep}/{self.version}@cloe/develop") - - cloe_requires("cloe-runtime") - cloe_requires("cloe-models") - cloe_requires("cloe-plugin-basic") - cloe_requires("cloe-plugin-gndtruth-extractor") - cloe_requires("cloe-plugin-minimator") - cloe_requires("cloe-plugin-mocks") - cloe_requires("cloe-plugin-noisy-sensor") - cloe_requires("cloe-plugin-speedometer") - cloe_requires("cloe-plugin-virtue") - if self.options.with_vtd: - cloe_requires("cloe-plugin-vtd") - - boost_version = "[>=1.65.0]" - if self.options.with_engine: - cloe_requires("cloe-engine") - - # Overrides: - self.requires("fmt/9.1.0", override=True) - self.requires("inja/3.4.0", override=True) - self.requires("nlohmann_json/3.11.2", override=True) - self.requires("incbin/cci.20211107", override=True), - self.requires(f"boost/{boost_version}", override=True) - - def package_id(self): - del self.info.options.pedantic + self.requires("fmt/9.1.0") + self.requires("inja/3.4.0") + self.requires("nlohmann_json/3.11.2") + self.requires("incbin/cci.20211107"), + self.requires("spdlog/1.11.0") + self.requires("eigen/3.4.0") + self.requires("cli11/2.3.2", private=True) + self.requires("sol2/3.3.1") + self.requires("boost/[>=1.65.1]") + if self.options.engine_server: + self.requires("oatpp/1.3.0") + + def build_requirements(self): + self.test_requires("gtest/1.13.0") + + def layout(self): + cmake.cmake_layout(self) + self.cpp.build.bindirs = ["bin"] + self.cpp.source.includedirs.append(os.path.join(self.folders.build, "include")) + + def generate(self): + # The version as a single 32-bit number takes the format: + # + # (EPOCH << 24) | (MAJOR_VERSION << 16) | (MINOR_VERSION << 8) | PATCH_VERSION + # + # Each version consists of at most 8 bits, so 256 potential values, including 0. + # The epoch starts with 0, and is bumped after each version naming scheme. + semver = SemVer(self.version, True) + version_u32 = (0<<24) | (semver.major << 16) | (semver.minor << 8) | semver.patch + + tc = cmake.CMakeToolchain(self) + tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True + tc.cache_variables["CMAKE_MODULE_PATH"] = self.source_folder + "/runtime/cmake" + tc.cache_variables["FABLE_VERSION"] = self.version + tc.cache_variables["FABLE_VERSION_U32"] = version_u32 + tc.cache_variables["FABLE_ALLOW_COMMENTS"] = self.options.fable_allow_comments + tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version + tc.cache_variables["CLOE_VERSION"] = self.version + tc.cache_variables["CLOE_VERSION_U32"] = version_u32 + tc.cache_variables["CLOE_ENGINE_WITH_SERVER"] = self.options.engine_server + tc.cache_variables["CLOE_ENGINE_WITH_LRDB"] = self.options.engine_lrdb + tc.generate() + + def build(self): + cm = cmake.CMake(self) + if self.should_configure: + cm.configure() + if self.should_build: + cm.build() + if self.should_test: + cm.test() + + def package(self): + if self.should_install: + cm = cmake.CMake(self) + cm.install() + + # Package license files for compliance + for meta, dep in self.dependencies.items(): + if dep.package_folder is None: + continue + ref = str(meta.ref) + name = ref[: str(ref).index("/")] + files.copy( + self, + "*", + src=os.path.join(dep.package_folder, "licenses"), + dst=os.path.join(self.package_folder, "licenses", name), + ) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "cloe") + self.cpp_info.set_property("pkg_config_name", "cloe") + + self.cpp_info.components["fable"].libs = ["fable"] + self.cpp_info.components["fable"].set_property("cmake_file_name", "fable") + self.cpp_info.components["fable"].set_property("cmake_target_name", "fable::fable") + self.cpp_info.components["fable"].set_property("pkg_config_name", "fable") + + self.cpp_info.components["runtime"].libs = ["cloe-runtime"] + self.cpp_info.components["runtime"].requires = ["fable"] + self.cpp_info.components["runtime"].set_property("cmake_file_name", "cloe-runtime") + self.cpp_info.components["runtime"].set_property("cmake_target_name", "cloe::runtime") + self.cpp_info.components["runtime"].set_property("pkg_config_name", "cloe-runtime") + + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("pthread") + self.cpp_info.system_libs.append("dl") + + # Linking to libstdc++fs is required on GCC < 9. + # (GCC compilers with version < 7 have no std::filesystem support.) + # No consideration has been made yet for other compilers, + # please add them here as necessary. + if self.settings.get_safe("compiler") == "gcc" and self.settings.get_safe("compiler.version") in ["7", "8"]: + self.cpp_info.system_libs = ["stdc++fs"] + + self.cpp_info.libs = files.collect_libs(self) + if not self.in_local_cache: # editable build + self.cpp_info.builddirs.append(os.path.join(self.source_folder, "cmake")) + self.cpp_info.includedirs.append(os.path.join(self.build_folder, "include")) + bindir = os.path.join(self.build_folder, "bin") + luadir = os.path.join(self.source_folder, "engine/lua") + libdir = os.path.join(self.build_folder, "lib"); + else: + self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "cloe")) + bindir = os.path.join(self.package_folder, "bin") + luadir = os.path.join(self.package_folder, "lib/cloe/lua") + libdir = None + + self.output.info(f"Appending PATH environment variable: {bindir}") + self.runenv_info.prepend_path("PATH", bindir) + self.output.info(f"Appending CLOE_LUA_PATH environment variable: {luadir}") + self.runenv_info.prepend_path("CLOE_LUA_PATH", luadir) + if libdir is not None: + self.output.info(f"Appending LD_LIBRARY_PATH environment variable: {libdir}") + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/docs/develop/building-cloe.rst b/docs/develop/building-cloe.rst index e3c7989b4..c39eccc9d 100644 --- a/docs/develop/building-cloe.rst +++ b/docs/develop/building-cloe.rst @@ -29,7 +29,7 @@ directory of every Cloe package (e.g. in ``plugins/basic/``): .. comment: The path below is relative to the project docs folder, not this file. - .. runcmd:: make -C ../models help + .. runcmd:: bash -c "make -C ../models help | sed -e 's/\x1b\[[0-9;]*m//g'" :replace: "PACKAGE_DIR:.*\\//PACKAGE_DIR: \\/" ``conanfile.py`` @@ -61,22 +61,56 @@ Verify that the cloe-plugin-basic package is currently in editable mode:: make status .. note:: - Positive-Example: + Positive-Example:: - .. code-block:: + editable : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop - editable : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop + Negative-Example:: - Negative-Example: - - .. code-block:: - - ok : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop + ok : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop Now, you can build the package binaries in your local working directory:: make clean all +The next time when Conan needs the package ``cloe-plugin-basic`` in +this version, it will resolve the include and library directories +to this local build. It is important to understand that you as a +developer are now responsible for ABI compatibility!! + +.. note:: + Conan can build packages with any constellation of dependencies that + you may require. This means that it is necessary to build an individual + package in a way that is compatible with the final composition. + + For example, it may be that the entire set of packages as defined by + the ``cloe-meta`` package require ``boost/1.65.1``. When building + the ``basic`` plugin as in this example, it has no way of knowing + that this version of Boost will be used when building ``cloe-engine``. + Therefore Conan will use the latest version of the ``boost`` package + it can find, such as ``boost/1.78.0``. + + In normal non-editable builds, Conan tracks these potential + incompatibilities and prevents you from incorrect combinations. + In editable mode however, you are responsible. Combining code + linked to two different versions of Boost is undefined behavior + and will lead to segfaults or worse! + + The solution to this dilemma is to let Conan know when making + a local build to use the final composition configuration for + resolving dependency configurations. This can be done by + generating a lockfile first of the final composition, and + using this lockfile when building a part locally. + + This is common enough that there is a simple mechanism baked + into the Makefiles to use a Conan recipe for automatically + generating and using a lockfile:: + + make clean all LOCKFILE_SOURCE=${CLOE_ROOT}/conanfile-meta.py + + where ``${CLOE_ROOT}`` is the path to the repository root; for + the ``basic`` plugin, this is ``../..``. + Since the package is in editable mode, the binaries will be created in the ``./build/`` directory in your package sub-directory. @@ -91,6 +125,102 @@ Verify the package status:: If you execute the latter command from the top-level directory, you will see the status of all Cloe packages. +Practical Example +""""""""""""""""" + +Let's apply the above to a very practical example involving ``cloe-engine``. +Assume the following situation: I checkout a develop branch, such as +``develop``, with the intention of modifying the ``cloe-engine`` package. + +First, because I am going to make changes, I disable the use of ``git describe`` +for versioning by explicitely setting a version:: + + echo "0.99.0-develop" > VERSION + +Then I make sure the entire project is exported:: + + make export-all + +.. note:: + This is roughtly equivalent to:: + + ( cd fable && conan export conanfile.py fable/0.99.0-develop@cloe/develop) + ( cd runtime && conan export conanfile.py cloe-runtime/0.99.0-develop@cloe/develop) + ... + +If there are any changes in other packages, I want to pick up those as well. +I let Conan know that I want to use ``cloe-engine`` in editable mode:: + + cd engine + make editable + +.. note:: + This is equivalent to:: + + cd engine + conan editable add conanfile cloe-engine/0.99.0-develop@cloe/develop + +Now, I need to choose a configuration that I want to use for testing the +entire set of packages. I can use ``cloe-meta`` or I can use a configuration +in the ``tests/`` directory, such as ``tests/conanfile_split.py``. +I use this when building ``cloe-engine`` as the source for creating a lockfile:: + + cd engine + make clean all LOCKFILE_SOURCE=../tests/conanfile_split.py + +This will automatically build any missing dependencies that are necessary for +building ``cloe-engine``, after which it will build ``cloe-engine`` locally. + +Before running any tests, I may need to make sure any additional dependencies +not required by ``cloe-engine`` but required for the test execution are +built:: + + cloe-launch prepare tests/conanfile_split.py + +.. note:: + This is *approximately* equivalent to:: + + conan install ../tests/conanfile_split.py --build=outdated --build=cascade + +Once this is complete, we can launch into a correctly configured shell, +with ``PATH`` and ``LD_LIBRARY_PATH`` set so that the shell can find +``cloe-engine`` and it can find required libraries and plugins. + +.. code-block:: + + cloe-launch shell -c tests/conanfile_split.py + +And at this point we are done and can run tests, make modifications +to the editable ``cloe-engine`` package, rebuild, and run tests again:: + + bats tests + $EDITOR engine/src/main.cpp + make -C engine all + bats tests + + +Superbuild +---------- + +The practical example of in-source builds above was one of the easiest +configurations we could choose. It becomes more arduous when we want to +edit packages that other packages in turn depend on, because then we need +to compile multiple packages by hand in the correct order. + +To side-step all of this, we have the ``cloe`` package, which is a +super-build of all other packages. + +You can build in the Conan cache with:: + + make package + +You can build it locally with:: + + make all + +You can then launch a virtual environment with ``cloe-launch``:: + + cloe-launch shell tests/conanfile_all.py .. _Conan local cache: https://docs.conan.io/en/latest/mastering/custom_cache.html .. _Conan CMake integration: https://docs.conan.io/en/latest/integrations/build_system/cmake.html diff --git a/docs/install.rst b/docs/install.rst index 1de5e669a..3d42abf30 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -69,14 +69,15 @@ Build Cloe Packages ------------------- To build all packages, you should run the following:: - make package + make export-all + make -C meta package This will export all Conan recipes from this repository and create the cloe package. Conan will download and build all necessary dependencies. Should any errors occur during the build, you may have to force Conan to build all packages instead of re-using packages it finds:: - make package CONAN_OPTIONS="--build" + make -C meta package CONAN_OPTIONS="--build" .. note:: Depending on your Conan profile, building the Cloe packages can involve @@ -88,16 +89,16 @@ all packages instead of re-using packages it finds:: If you like, you can inspect what a Conan Cloe package looks like by browsing the Conan cache directory under ``~/.conan/data/cloe``. -Run ``make help`` to get an overview of the available targets we expect you to -use. For more details on how this is done, have a look at the Makefiles in the -repository root. +Run ``make help`` to get an overview of the available targets we anticipate you +may want to use. For more details on how this is done, have a look at the +Makefiles in the repository root. Run System Tests ---------------- To check that everything is working as it should, we recommend you run the included test suite once before commencing with anything else:: - make export smoketest-deps smoketest + make export-all smoketest-deps smoketest .. _Conan: https://conan.io .. _Conan documentation: https://docs.conan.io/en/latest/ diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 047474cfb..e97688b0a 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -2,9 +2,12 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_engine LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) -find_package(fable REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(fable REQUIRED) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() find_package(Boost REQUIRED) find_package(CLI11 REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -20,7 +23,7 @@ set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION}) set(PROJECT_GIT_REF "unknown") # Library libstack --------------------------------------------------- -add_library(cloe-stacklib +add_library(cloe-stacklib STATIC src/config.hpp src/stack.hpp src/stack.cpp @@ -28,13 +31,18 @@ add_library(cloe-stacklib src/stack_factory.cpp src/plugin.hpp src/plugin.cpp + + # Built-in plugins: + src/plugins/nop_controller.cpp + src/plugins/nop_controller.hpp + src/plugins/nop_simulator.cpp + src/plugins/nop_simulator.hpp ) add_library(cloe::stacklib ALIAS cloe-stacklib) set_target_properties(cloe-stacklib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON OUTPUT_NAME stack - LIBRARY_OUTPUT_DIRECTORY "lib" ) target_include_directories(cloe-stacklib PRIVATE @@ -43,6 +51,7 @@ target_include_directories(cloe-stacklib target_link_libraries(cloe-stacklib PUBLIC cloe::runtime + cloe::models fable::fable Boost::headers Threads::Threads @@ -72,8 +81,8 @@ if(BUILD_TESTING) gtest_add_tests(TARGET test-stacklib) endif() -# Library liblua------------------------------------------------------ -add_library(cloe-lualib +# Library libengine ---------------------------------------------- +add_library(cloe-enginelib STATIC src/lua_api.hpp src/lua_api.cpp src/lua_setup.hpp @@ -82,63 +91,11 @@ add_library(cloe-lualib src/lua_setup_fs.cpp src/lua_setup_stack.cpp src/lua_setup_sync.cpp -) -add_library(cloe::lualib ALIAS cloe-lualib) -target_compile_definitions(cloe-lualib - PUBLIC - SOL_ALL_SAFETIES_ON=1 - LRDB_USE_BOOST_ASIO=1 -) -set_target_properties(cloe-lualib PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - OUTPUT_NAME lua - LIBRARY_OUTPUT_DIRECTORY "lib" -) -target_include_directories(cloe-lualib - PRIVATE - src -) -target_link_libraries(cloe-lualib - PUBLIC - boost::boost - sol2::sol2 - cloe::stacklib - cloe::runtime - fable::fable - Threads::Threads -) -if(BUILD_TESTING) - add_executable(test-lualib - src/lua_stack_test.cpp - ) - set_target_properties(test-lualib PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - ) - target_link_libraries(test-lualib - GTest::gtest - GTest::gtest_main - Boost::boost - cloe::models - cloe::stacklib - cloe::lualib - ) - gtest_add_tests(TARGET test-lualib) -endif() - -# Library libengine ---------------------------------------------- -add_library(cloe-enginelib src/coordinator.cpp src/coordinator.hpp src/lua_action.cpp src/lua_action.hpp - src/plugins/nop_controller.cpp - src/plugins/nop_controller.hpp - src/plugins/nop_simulator.cpp - src/plugins/nop_simulator.hpp src/registrar.hpp - src/server.hpp # These are added below and depend on CLOE_ENGINE_WITH_SERVER: # src/server.cpp # src/server_mock.cpp @@ -147,9 +104,6 @@ add_library(cloe-enginelib src/simulation_context.cpp src/simulation_context.hpp src/simulation_progress.hpp - # These are added below and depend on CLOE_ENGINE_WITH_SERVER: - # src/server.cpp - # src/server_mock.cpp src/utility/command.cpp src/utility/command.hpp src/utility/defer.hpp @@ -162,10 +116,11 @@ set_target_properties(cloe-enginelib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON OUTPUT_NAME engine - LIBRARY_OUTPUT_DIRECTORY "lib" ) target_compile_definitions(cloe-enginelib PUBLIC + SOL_ALL_SAFETIES_ON=1 + LRDB_USE_BOOST_ASIO=1 CLOE_ENGINE_VERSION="${CLOE_ENGINE_VERSION}" CLOE_ENGINE_TIMESTAMP="${CLOE_ENGINE_TIMESTAMP}" PROJECT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\" @@ -176,11 +131,11 @@ target_include_directories(cloe-enginelib ) target_link_libraries(cloe-enginelib PUBLIC - cloe::lualib cloe::stacklib cloe::models cloe::runtime fable::fable + boost::boost sol2::sol2 Threads::Threads ) @@ -188,14 +143,16 @@ target_link_libraries(cloe-enginelib option(CLOE_ENGINE_WITH_SERVER "Enable integrated server component?" ON) if(CLOE_ENGINE_WITH_SERVER) message(STATUS "-> Enable server component") - find_package(cloe-oak REQUIRED) + if(CLOE_FIND_PACKAGES) + find_package(cloe-oak REQUIRED) + endif() target_sources(cloe-enginelib PRIVATE src/server.cpp) target_link_libraries(cloe-enginelib PRIVATE cloe::oak) - target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_SERVER=1) + target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_SERVER=1) else() message(STATUS "-> Disable server component") target_sources(cloe-enginelib PRIVATE src/server_mock.cpp) - target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_SERVER=0) + target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_SERVER=0) endif() option(CLOE_ENGINE_WITH_LRDB "Enable LRDB Lua Debugger?" ON) @@ -204,10 +161,29 @@ if(CLOE_ENGINE_WITH_LRDB) add_subdirectory(vendor/lrdb) target_sources(cloe-enginelib PRIVATE src/lua_debugger.cpp) target_link_libraries(cloe-enginelib PRIVATE lrdb::lrdb) - target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_LRDB=1) + target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_LRDB=1) else() message(STATUS "-> Disable LRDB component") - target_compile_definitions(cloe-lualib PUBLIC CLOE_ENGINE_WITH_LRDB=0) + target_compile_definitions(cloe-enginelib PUBLIC CLOE_ENGINE_WITH_LRDB=0) +endif() + +if(BUILD_TESTING) + add_executable(test-enginelib + src/lua_stack_test.cpp + ) + set_target_properties(test-enginelib PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + ) + target_link_libraries(test-enginelib + GTest::gtest + GTest::gtest_main + Boost::boost + cloe::models + cloe::stacklib + cloe::enginelib + ) + gtest_add_tests(TARGET test-enginelib) endif() # Executable --------------------------------------------------------- @@ -226,9 +202,7 @@ set_target_properties(cloe-engine PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON OUTPUT_NAME cloe-engine - RUNTIME_OUTPUT_DIRECTORY bin ) -set_target_linting(cloe-engine) target_include_directories(cloe-engine PRIVATE src @@ -236,7 +210,6 @@ target_include_directories(cloe-engine target_link_libraries(cloe-engine PRIVATE cloe::stacklib - cloe::lualib cloe::enginelib CLI11::CLI11 linenoise::linenoise diff --git a/engine/conanfile.py b/engine/conanfile.py index 889adc6cc..9d6a4c28c 100644 --- a/engine/conanfile.py +++ b/engine/conanfile.py @@ -70,7 +70,6 @@ def build_requirements(self): def layout(self): cmake.cmake_layout(self) - self.cpp.build.bindirs = ["bin"] def generate(self): tc = cmake.CMakeToolchain(self) @@ -123,8 +122,8 @@ def package_info(self): if self.in_local_cache: bindir = os.path.join(self.package_folder, "bin") luadir = os.path.join(self.package_folder, "lib/cloe/lua") - else: - bindir = os.path.join(self.build_folder, "bin") + else: # editable mode + bindir = os.path.join(self.build_folder) luadir = os.path.join(self.source_folder, "lua") self.output.info(f"Appending PATH environment variable: {bindir}") diff --git a/engine/tests/conanfile_with_server.py b/engine/tests/conanfile_with_server.py deleted file mode 100644 index a733ce2ca..000000000 --- a/engine/tests/conanfile_with_server.py +++ /dev/null @@ -1,32 +0,0 @@ -# mypy: ignore-errors -# pylint: skip-file - -from pathlib import Path - -from conan import ConanFile - - -class CloeTest(ConanFile): - python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" - python_requires_extend = "cloe-launch-profile.Base" - - @property - def cloe_launch_env(self): - return { - "CLOE_ENGINE_WITH_SERVER": "1", - "CLOE_LOG_LEVEL": "debug", - "CLOE_STRICT_MODE": "1", - "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "../..", - } - - def set_version(self): - self.version = self.project_version("../../VERSION") - - def requirements(self): - self.requires(f"cloe-engine/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-basic/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-mocks/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-noisy-sensor/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-speedometer/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop") diff --git a/engine/tests/conanfile_without_server.py b/engine/tests/conanfile_without_server.py deleted file mode 100644 index 0baebe875..000000000 --- a/engine/tests/conanfile_without_server.py +++ /dev/null @@ -1,35 +0,0 @@ -# mypy: ignore-errors -# pylint: skip-file - -from pathlib import Path - -from conan import ConanFile - - -class CloeTest(ConanFile): - python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" - python_requires_extend = "cloe-launch-profile.Base" - default_options = { - "cloe-engine:server": False, - } - - @property - def cloe_launch_env(self): - return { - "CLOE_ENGINE_WITH_SERVER": "0", - "CLOE_LOG_LEVEL": "debug", - "CLOE_STRICT_MODE": "1", - "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "../..", - } - - def set_version(self): - self.version = self.project_version("../../VERSION") - - def requirements(self): - self.requires(f"cloe-engine/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-basic/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-mocks/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-noisy-sensor/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-speedometer/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop") diff --git a/engine/tests/config_nop_infinite.json b/engine/tests/config_nop_infinite.json deleted file mode 100644 index e29064ef0..000000000 --- a/engine/tests/config_nop_infinite.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "version": "4", - "include": [ - "controller_virtue.json", - "controller_basic.json" - ], - "simulators": [ - { - "binding": "nop" - } - ], - "vehicles": [ - { - "name": "default", - "from": { - "simulator": "nop", - "index": 0 - }, - "components": { - "cloe::speedometer": { - "binding": "speedometer", - "name": "default_speed", - "from": "cloe::gndtruth_ego_sensor" - }, - "cloe::default_world_sensor": { - "binding": "noisy_object_sensor", - "name": "noisy_object_sensor", - "from": "cloe::default_world_sensor", - "args": { - "noise": [ - { - "target": "translation", - "distribution": { - "binding": "normal", - "mean": 0.0, - "std_deviation": 0.3 - } - } - ] - } - } - } - } - ] -} diff --git a/engine/tests/config_nop_smoketest.json b/engine/tests/config_nop_smoketest.json deleted file mode 100644 index 238708186..000000000 --- a/engine/tests/config_nop_smoketest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "4", - "include": [ - "config_nop_infinite.json" - ], - "server": { - "listen": false, - "listen_port": 23456 - }, - "triggers": [ - {"event": "virtue/failure", "action": "fail"}, - { - "label": "Vehicle default should never move with the nop binding.", - "event": "default_speed/kmph=>0.0", "action": "fail" - }, - {"event": "start", "action": "log=info: Running nop/basic smoketest."}, - {"event": "start", "action": "realtime_factor=-1"}, - {"event": "time=60", "action": "succeed"} - ] -} diff --git a/engine/tests/wip_brainstorm.lua b/engine/tests/wip_brainstorm.lua deleted file mode 100644 index 1d8c66627..000000000 --- a/engine/tests/wip_brainstorm.lua +++ /dev/null @@ -1,131 +0,0 @@ -local cloe = require("cloe") - --- which will schedule itself -cloe.load_plugin("vtd") -cloe.load_plugin("virtue") -require("vtd").setup(cloe.config.simulator.vtd) - -assert(not cloe.has_feature("cloe-server")) -if cloe.has_feature("cloe-server") then - cloe.server.setup({ - enabled = true, - listen_address = "0.0.0.0", - listen_port = 23456, - }) -end - -cloe.setup_scheduler { - step_size = "1ms" -} - -cloe.schedule { - on = "step", - priority = 1000, - run = function (sync) - cloe.plugins.vtd.process(sync) - end, -} - -cloe.schedule { - on = "post_step", - run = function (sync) - cloe.plugins.realtime.process(sync) - end, -} - -cloe.schedule { - on = "start", - run = function() - cloe.simulation.realtime_factor = -1 - end -} - -cloe.schedule { - { on = "start", run = "log=info: Running nop/basic smoketest" }, -} - --- Multiple actions can be scheduled -cloe.schedule { - group = "fail_conditions", - desc = "determine whether simulation is fail or success", - { - on = "step", - run = function (_) - if cloe.vehicle.default["speed_kmph"] > 100 then - cloe.debug() - cloe.simulation.fail("vehicle speed exceeded safe limit") - end - end - }, - { - on = "virtue.failure", - run = { - "log=error: Failed virtue test", - "fail", - } - }, -} - -cloe.schedule { on = "time=60s", run = "succeed" } - -cloe.schedule_test { - -- @class TestSpec - -- All events scheduled from within this test are given the UUID as the group, - -- which makes it easy to delete them when the test is over. - - -- @field id string|fun():string - id = "b653c3b0-5d29-4b91-b493-d72578ca62ad", - - -- @field name? string|fun():string = "" - name = "asdf", - - -- @field desc? string = "" - desc = "Make sure we can enable and disable Basic ACC", - - -- @field enabled? boolean|fun():boolean = true - enable = true, - - -- @type string|string[]|fun():boolean - on = "start", - - -- Run this as a coroutine, which lets us yield until... - -- @field fun(TestFixture) - run = function(test) - local basic = cloe.vehicle.default["basic"] - - basic.set_speed(80.0) - - -- This schedules a resumption and then uses coroutine.yield to let cloe continue - -- - -- cloe.schedule({ - -- on = function() return cloe.vehicle.default["speed_kmph"] > 50 end, - -- run = function() coroutine.resume(test.coroutine_id) end, - -- group = test.id, - -- }) - -- coroutine.yield() - -- - cloe.wait_until(function() return cloe.vehicle.default["speed_kmph"] > 50.0 end) - local time = cloe.state.time - - -- It should not take longer than 10 simulated seconds to get from 50 to 80 - local index = cloe.wait_until({ - -- Either succeed: - function() return cloe.vehicle.default["speed_kmph"] >= 79.0 end, - - -- Or timeout: - "next=10s", - - needs = "any" -- or "all" - }) - - if index == 1 then - test.assert(cloe.vehicle.default["speed_kmph"] >= 79.0) - test.succeed() - else - test.assert(cloe.state.time >= time + 10) - test.fail() - end - end, - - report = function() end, -} diff --git a/engine/tests/wip_config_nop_infinite.lua b/engine/tests/wip_config_nop_infinite.lua deleted file mode 100644 index 2fa86c762..000000000 --- a/engine/tests/wip_config_nop_infinite.lua +++ /dev/null @@ -1,99 +0,0 @@ -local cloe = require("cloe") -assert(cloe.has_feature("cloe-0.21")) - --- Nothing is available until it is loaded. -cloe.load_plugin("builtin://nop-simulator", "nop") -local plugins = cloe.util.split(os.getenv("CLOE_PLUGIN_PATH"), ":") -for _, p in ipairs(plugins) do - cloe.load_plugin(p) -end - -cloe.setup_plugin { - plugin = "nop" -} - -cloe.setup_vehicle({ - name = "default", - from = { - simulator = "nop", -- cloe.plugins.nop - index = 0 - }, - components = { - ["cloe::speedometer"] = { - binding = "speedometer", - name = "default_speed", - from = "cloe::gndtruth_ego_sensor" - }, - ["cloe::default_world_sensor"] = { - binding = "noisy_object_sensor", - name = "noisy_object_sensor", - from = "cloe::default_world_sensor", - args = { - noise = { - { - target = "translation", - distribution = { - binding = "normal", - mean = 0.0, - std_deviation = 0.3 - } - } - } - } - }, - } -}) - -cloe.setup_plugin { - plugin = "virtue", - vehicle = "default" -} - -cloe.setup_plugin { - plugin = "basic", - vehicle = "default" -} - -cloe.schedule_test { - id = "0d5a3cc7-4203-42d1-b50a-c1ea618cc92e", - name = "test_basic", - on = "start", - desc = "use the ACC functionality from the basic controller", - plot_signals = { - "blabla_stupid_long_m_asdf_asdM_1_2__signal_signal_duplicate2", - "blabla_stupid_long_m_asdf_asdM_1_2__signal_signal_duplicate3", - "blabla_stupid_long_m_asdf_asdM_1_2__signal_signal_duplicate4", - "blabla_stupid_long_m_asdf_asdM_1_2__signal_signal_duplicate5", - "blabla_stupid_long_m_asdf_asdM_1_2__signal_signal_duplicate6", - }, - run = function(z, sync) - local hmi = cloe.plugins.basic.hmi - - hmi.enable = false - z.wait_until(function() - return cloe.vehicles["default"]["speed"] > 50; - end) - z.wait_duration("1s") - hmi.enable = true - z.wait_duration("5s") - - z.comment("Press resume button") - hmi.resume = true - z.assert(hmi.resume == true, "Pressing the resume button works") - z.wait_duration("0.5s") - hmi.resume = false - - cloe.debug() - z.wait_duration("1s") - - -- Helper function - z.push_button = function(what, dur) - hmi[what] = true - z.wait_duration(dur) - hmi[what] = false - end - - -- Press plus button - z.push_button("plus", "1s") - end, -} diff --git a/engine/tests/wip_config_nop_smoketest.lua b/engine/tests/wip_config_nop_smoketest.lua deleted file mode 100644 index 57620b6e8..000000000 --- a/engine/tests/wip_config_nop_smoketest.lua +++ /dev/null @@ -1,51 +0,0 @@ -local cloe = require("cloe") -cloe.require_version("0.21") - --- Include the basic setup. (This file only --- schedules test success / fail conditions.) -cloe.load_file("wip_2.lua") - --- It is best practice to check for optional features --- before using them. -if cloe.has_feature("cloe-server") then - cloe.setup_server { - enabled = true - } -end - -cloe.schedule { - on = "start", - run = { - function() cloe.simulation.realtime_factor = -1 end, - "log=info: Running nop/basic smoketest", - } -} - --- Multiple actions can be scheduled -cloe.schedule { - -- Actions will be assigned the same group ID, which allows - -- scheduler actions to be performed on the entire set. - group = "fail_conditions", - { - on = "step", - run = function (_) - if cloe.vehicles.default["speed_kmph"] > 100 then - cloe.debug() -- launch interactive debugger - cloe.simulation.fail("vehicle speed exceeded safe limit") - end - end - }, - { - on = "virtue.failure", - run = { - "log=error: Failed virtue test", - "fail", - } - }, -} - -cloe.schedule { - group = "success_conditions", - on = "time=60s", - run = "succeed" -} diff --git a/engine/tests/wip_hello_plugin.lua b/engine/tests/wip_hello_plugin.lua deleted file mode 100644 index 5ca5a4fd2..000000000 --- a/engine/tests/wip_hello_plugin.lua +++ /dev/null @@ -1,35 +0,0 @@ -local cloe = require("cloe") - -local plugin = (function() - local A = {} - A.new = function(self, conf) - self.conf = conf - return self - end - A.step = function() - print("hello") - return "+100ms" - end - A.export = { - "step" - } - - local F = {} - F.name = "hello" - F.conf = { - cycle_length = "100ms", - last_cycle = "1000ms" - } - F.setup = function(conf) - conf = cloe.util.table_deep_extend(conf, F.conf) - return A:new(conf) - end - - return F -end)() - -local a = plugin.setup() -cloe.schedule_agent { - unit = a, - name = "hello" -} diff --git a/engine/tests/wip_hello_world.lua b/engine/tests/wip_hello_world.lua deleted file mode 100644 index e69de29bb..000000000 diff --git a/engine/tests/wip_include_json.lua b/engine/tests/wip_include_json.lua deleted file mode 100644 index 336f3f100..000000000 --- a/engine/tests/wip_include_json.lua +++ /dev/null @@ -1,17 +0,0 @@ --- Simplest configuration just loads an existing stackfile. --- - --- The `cloe` table is loaded by default within cloe-engine. --- --- This will do nothing in cloe-engine, but it will give us --- completion when using a Lua LSP. -local cloe = require("cloe") - --- cloe.has_feature() lets us check whether we have a certain --- version or feature of cloe. -assert(cloe.has_feature("cloe-0.21"), "cloe is not recent enough") - --- cloe.load_stackfile() lets us load a stackfile. This may --- be dropped or shimmed in the future. -cloe.require_feature("cloe-stackfile-4") -cloe.load_stackfile("config_nop_smoketest.json") diff --git a/engine/tests/wip_setup.lua b/engine/tests/wip_setup.lua deleted file mode 100644 index 97dfa894c..000000000 --- a/engine/tests/wip_setup.lua +++ /dev/null @@ -1,78 +0,0 @@ --- Low-level plugin loading and setup. --- --- We are assuming that cloe has the plugin search path set via environment --- or that the plugins reside in their normal locations. -local cloe = require("cloe") - -do - cloe.load_plugin("minimator") - local a = require("minimator").setup { - vehicles = { - "default" - } - } - cloe.schedule_agent { - agent = a, - name = "minimator", - } - - print("Module " .. a .. " input:") - for key in pairs(a.input) do - print("", key) - end - print("Module " .. a .. " outputs:") - for key in pairs(a.output) do - print("", key) - end -end - -do - cloe.load_plugin("speedometer") - local a = require("speedometer").setup() - cloe.schedule_agent { - agent = a, - name = "default_speed" - } - cloe.pipe( - cloe.agents.minimator.default.ego_sensor, - cloe.agents.default_speed.ego_sensor - ) -end - -do - local m = require("speedometer").setup() - cloe.schedule_agent { - agent = m, - name = "dummy_speed", - } - cloe.pipe( - { - pipe = "output", - async = false, - name = "minimator.vehicles.default.ego_sensor", - type = "user description of function", - func = cloe.agents.minimator.vehicles.default.ego_sensor.func, - }, - cloe.agents.dummy_speed.ego_sensor - ) -end - -do - cloe.load_plugin("basic") - local m = require("basic").setup() - cloe.schedule_agent { - agent = m, - name = "basic", - } - - print("Module " .. m .. " input:") - for key in pairs(m.input) do - print("", key) - end - print("Module " .. m .. " outputs:") - for key in pairs(m.output) do - print("", key) - end - - cloe.pipe("minimator.default.ego_sensor", "basic.ego_sensor") -end diff --git a/engine/tests/wip_setup_v2.lua b/engine/tests/wip_setup_v2.lua deleted file mode 100644 index af9b8f38f..000000000 --- a/engine/tests/wip_setup_v2.lua +++ /dev/null @@ -1,28 +0,0 @@ --- High-level plugin loading and setup. --- --- We are assuming that cloe has the plugin search path set via environment --- or that the plugins reside in their normal locations. -local cloe = require("cloe") - -cloe.setup_plugin { - "minimator", - conf = { - vehicles = { - "default" - } - } -} - -cloe.setup_plugin { - "speedometer", - name = "default_speed" -} - -cloe.setup_plugin { - "speedometer", - name = "dummy_speed" -} - -cloe.setup_plugin { - "basic" -} diff --git a/engine/tests/wip_test_controller_stuck.lua b/engine/tests/wip_test_controller_stuck.lua deleted file mode 100644 index 12c2c7489..000000000 --- a/engine/tests/wip_test_controller_stuck.lua +++ /dev/null @@ -1,37 +0,0 @@ --- Translation from test_engine_stuck_controller.json --- - -local cloe = require("cloe") - -cloe.load_plugin("builtin://nop-controller", "nop") -cloe.load_plugin("demo_stuck") - -cloe.setup_plugin { - plugin = "nop" -} - -cloe.setup_vehicle { - name = "default", - from = { - simulator = "nop", - index = 0 - } -} - -cloe.setup_plugin { - plugin = "demo_stuck", - vehicle = "default", - args = { - progress_per_step = 10000 - } -} - -cloe.setup_simulation { - controller_retry_limit = 100 -} - -cloe.schedule { - { on = "start", run = "log=info: Running nop/demo_stuck test." }, - { on = "start", run = "realtime_factor=-1" }, - { on = "time=60", run = "succeed" } -} diff --git a/engine/tests/wip_test_engine_watchdog.lua b/engine/tests/wip_test_engine_watchdog.lua deleted file mode 100644 index 19b2d9414..000000000 --- a/engine/tests/wip_test_engine_watchdog.lua +++ /dev/null @@ -1,37 +0,0 @@ --- Translation from test_engine_watchdog.json --- - -local cloe = require("cloe") - -cloe.require_version("0.21") -cloe.load_file("wip_config_nop_smoketest.lua") - -cloe.setup_engine { - security = { - enabled_command_action = true - }, - polling_interval = 60000, - watchdog = { - mode = "kill", - default_timeout = 1000 - } -} - -cloe.setup_server { - enabled = false -} - -cloe.schedule { - enabled = cloe.has_feature("cloe-server"), - - { on = "time=45", run = "pause"}, - { - desc = "Insert resume trigger via curl to test the pause-resume behavior.", - on = "pause", - run = { - name = "command", - -- This probably won't work in the future. - command = "echo '{\"event\": \"pause\", \"action\": \"resume\"}' | curl -d @- http://localhost:23456/api/triggers/input" - } - } -} diff --git a/meta/Makefile b/meta/Makefile new file mode 100644 index 000000000..bbe5ce9c9 --- /dev/null +++ b/meta/Makefile @@ -0,0 +1,3 @@ +override BUILD_IN_SOURCE := false + +include ../Makefile.package diff --git a/meta/conanfile.py b/meta/conanfile.py new file mode 100644 index 000000000..4badde3b4 --- /dev/null +++ b/meta/conanfile.py @@ -0,0 +1,64 @@ +# mypy: ignore-errors +# pylint: skip-file + +from pathlib import Path + +from conan import ConanFile +from conan.tools import files, scm + +required_conan_version = ">=1.52.0" + + +class CloeMeta(ConanFile): + name = "cloe-meta" + license = "Apache-2.0" + url = "https://github.com/eclipse/cloe" + description = "Closed-loop automated driving simulation environment" + topics = ["simulation"] + settings = "os", "compiler", "build_type", "arch" + options = { + "with_vtd": [True, False], + "with_engine": [True, False], + } + default_options = { + "with_vtd": False, + "with_engine": True, + + "fable:allow_comments": True, + "engine:server": True, + "engine:lrdb": True, + } + + def set_version(self): + version_file = Path(self.recipe_folder) / "../VERSION" + if version_file.exists(): + self.version = files.load(self, version_file).strip() + else: + git = scm.Git(self, self.recipe_folder) + self.version = git.run("describe --dirty=-dirty")[1:] + + def requirements(self): + def cloe_requires(dep): + self.requires(f"{dep}/{self.version}@cloe/develop") + + cloe_requires("cloe-runtime") + cloe_requires("cloe-models") + cloe_requires("cloe-plugin-basic") + cloe_requires("cloe-plugin-gndtruth-extractor") + cloe_requires("cloe-plugin-minimator") + cloe_requires("cloe-plugin-mocks") + cloe_requires("cloe-plugin-noisy-sensor") + cloe_requires("cloe-plugin-speedometer") + cloe_requires("cloe-plugin-virtue") + if self.options.with_vtd: + cloe_requires("cloe-plugin-vtd") + + if self.options.with_engine: + cloe_requires("cloe-engine") + + # Overrides: + self.requires("fmt/9.1.0", override=True) + self.requires("inja/3.4.0", override=True) + self.requires("nlohmann_json/3.11.2", override=True) + self.requires("incbin/cci.20211107", override=True), + self.requires(f"boost/[>=1.65.0]", override=True) diff --git a/models/CMakeLists.txt b/models/CMakeLists.txt index ddbbef510..a3c2e39ca 100644 --- a/models/CMakeLists.txt +++ b/models/CMakeLists.txt @@ -6,17 +6,17 @@ include(GNUInstallDirs) include(TargetLinting) # Module ------------------------------------------------------------- -set(target cloe-models) -set(alias cloe::models) - -find_package(cloe-runtime REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) +endif() find_package(Eigen3 REQUIRED) find_package(Boost COMPONENTS headers REQUIRED) find_package(sol2 REQUIRED) -message(STATUS "-> Building ${output} library.") -file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp") -add_library(${target} +message(STATUS "-> Building cloe-models library.") +file(GLOB cloe-models_PUBLIC_HEADERS "include/**/*.hpp") +add_library(cloe-models # find src -type f -name "*.cpp" \! -name "*_test.cpp" src/cloe/component/lane_boundary.cpp src/cloe/component/utility/ego_sensor_canon.cpp @@ -25,21 +25,20 @@ add_library(${target} src/cloe/utility/lua_types.cpp # For IDE integration - ${${target}_PUBLIC_HEADERS} + ${cloe-models_PUBLIC_HEADERS} ) -add_library(${alias} ALIAS ${target}) -set_target_properties(${target} PROPERTIES +add_library(cloe::models ALIAS cloe-models) +set_target_properties(cloe-models PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON VERSION ${CLOE_PROJECT_VERSION} ) -set_target_linting(${target}) -target_include_directories(${target} +target_include_directories(cloe-models PUBLIC "$" "$" ) -target_link_libraries(${target} +target_link_libraries(cloe-models PUBLIC cloe::runtime Boost::headers @@ -71,13 +70,13 @@ if(BUILD_TESTING) GTest::gtest_main Boost::boost cloe::runtime - ${target} + cloe-models ) gtest_add_tests(TARGET test-models) endif() # Installation ------------------------------------------------------- -install(TARGETS ${target} +install(TARGETS cloe-models LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE diff --git a/oak/CMakeLists.txt b/oak/CMakeLists.txt index 4c17f1720..6337d954d 100644 --- a/oak/CMakeLists.txt +++ b/oak/CMakeLists.txt @@ -6,37 +6,36 @@ include(GNUInstallDirs) include(TargetLinting) # Library ------------------------------------------------------------ -set(target cloe-oak) -set(alias cloe::oak) - -find_package(cloe-runtime REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) +endif() find_package(oatpp REQUIRED) -file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp") -add_library(${target} +file(GLOB cloe-oak_PUBLIC_HEADERS "include/**/*.hpp") +add_library(cloe-oak # find src -type f -name "*.cpp" \! -name "*_test.cpp" src/oak/registrar.cpp src/oak/server.cpp # For IDE integration - ${${target}_PUBLIC_HEADERS} + ${cloe-oak_PUBLIC_HEADERS} src/oak/request_stub.hpp src/oak/curl.hpp ) -add_library(${alias} ALIAS ${target}) -set_target_linting(${target}) -set_target_properties(${target} PROPERTIES +add_library(cloe::oak ALIAS cloe-oak) +set_target_properties(cloe-oak PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) -target_include_directories(${target} +target_include_directories(cloe-oak PRIVATE "$" PUBLIC "$" "$" ) -target_link_libraries(${target} +target_link_libraries(cloe-oak PUBLIC cloe::runtime oatpp::oatpp @@ -65,13 +64,13 @@ if(BUILD_TESTING) target_link_libraries(test-oak GTest::gtest GTest::gtest_main - ${target} + cloe-oak ) gtest_add_tests(TARGET test-oak) endif() # Installation ------------------------------------------------------- -install(TARGETS ${target} +install(TARGETS cloe-oak LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 000000000..54bd61061 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,42 @@ +# This CMakeLists.txt configures a super-build of all plugins. +# +# It is currently experimental. +# +# This supports two use-cases: +# +# 1. Creating a cloe-plugins-core package containing all plugins. +# 2. Creating a cloe package containing everything from this repo. +# +# Other use-cases are currently not supported. +# + +cmake_minimum_required(VERSION 3.15 FATAL_ERROR) + +if(NOT DEFINED PROJECT_NAME) + project(cloe_plugins_core LANGUAGES CXX) + + # Speed up configuration by only finding Cloe packages once + set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") + if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) + set(CLOE_FIND_PACKAGES OFF FORCE) + endif() + + # Ensure output goes to one place so cloe-launch can find the plugins + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +elseif(NOT ${PROJECT_NAME} STREQUAL "cloe") + message(FATAL_ERROR "Building super-project unequal to cloe not suppoorted.") +endif() + +# Ensure we can test from this level. +include(CTest) + +add_subdirectory(basic) +add_subdirectory(gndtruth_extractor) +add_subdirectory(minimator) +add_subdirectory(mocks) +add_subdirectory(noisy_sensor) +add_subdirectory(speedometer) +add_subdirectory(virtue) diff --git a/plugins/Makefile b/plugins/Makefile new file mode 100644 index 000000000..87c6e44df --- /dev/null +++ b/plugins/Makefile @@ -0,0 +1 @@ +include ../Makefile.package diff --git a/plugins/basic/CMakeLists.txt b/plugins/basic/CMakeLists.txt index 35a6c490f..77f45534c 100644 --- a/plugins/basic/CMakeLists.txt +++ b/plugins/basic/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_basic LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/basic/conanfile.py b/plugins/basic/conanfile.py index c44ba2e9d..a98094785 100644 --- a/plugins/basic/conanfile.py +++ b/plugins/basic/conanfile.py @@ -79,6 +79,6 @@ def package_info(self): self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) - if not self.in_local_cache: + if not self.in_local_cache: # editable mode libdir = os.path.join(self.build_folder, "lib"); self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/conanfile.py b/plugins/conanfile.py new file mode 100644 index 000000000..b69c7862a --- /dev/null +++ b/plugins/conanfile.py @@ -0,0 +1,88 @@ +# mypy: ignore-errors +# pylint: skip-file + +import os +from pathlib import Path + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import cmake, files, scm, env + +required_conan_version = ">=1.52.0" + + +class CloeControllerBasic(ConanFile): + name = "cloe-plugins-core" + url = "https://github.com/eclipse/cloe" + description = "Cloe core plugins" + license = "Apache-2.0" + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "VirtualRunEnv" + no_copy_source = True + provides = [ + "cloe-plugin-basic", + "cloe-plugin-gndtruth-extractor", + "cloe-plugin-minimator", + "cloe-plugin-mocks", + "cloe-plugin-noisy-sensor", + "cloe-plugin-speedometer", + "cloe-plugin-virtue", + ] + exports_sources = [ + "*/src/*", + "*/include/*", + "*/ui/*", + "*/CMakeLists.txt", + ] + + def set_version(self): + version_file = Path(self.recipe_folder) / "../VERSION" + if version_file.exists(): + self.version = files.load(self, version_file).strip() + else: + git = scm.Git(self, self.recipe_folder) + self.version = git.run("describe --dirty=-dirty")[1:] + + def requirements(self): + self.requires(f"cloe-runtime/{self.version}@cloe/develop") + self.requires(f"cloe-models/{self.version}@cloe/develop") + + def build_requirements(self): + self.test_requires("gtest/1.13.0") + + def layout(self): + cmake.cmake_layout(self) + + def generate(self): + tc = cmake.CMakeToolchain(self) + tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True + tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version + tc.cache_variables["TargetLintingExtended"] = True + tc.generate() + + def build(self): + cm = cmake.CMake(self) + if self.should_configure: + cm.configure() + if self.should_build: + cm.build() + if self.should_test: + cm.test() + + def package(self): + cm = cmake.CMake(self) + if self.should_install: + cm.install() + + def package_id(self): + self.info.requires["boost"].full_package_mode() + del self.info.options.pedantic + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", self.name) + self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/gndtruth_extractor/CMakeLists.txt b/plugins/gndtruth_extractor/CMakeLists.txt index ba56fac47..34fd0d717 100644 --- a/plugins/gndtruth_extractor/CMakeLists.txt +++ b/plugins/gndtruth_extractor/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_gndtruth_extractor LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/gndtruth_extractor/conanfile.py b/plugins/gndtruth_extractor/conanfile.py index 96ff71041..2b8674a27 100644 --- a/plugins/gndtruth_extractor/conanfile.py +++ b/plugins/gndtruth_extractor/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -76,3 +77,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", f"both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/gndtruth_extractor/tests/conanfile_default.py b/plugins/gndtruth_extractor/tests/conanfile_default.py deleted file mode 100644 index b567adb56..000000000 --- a/plugins/gndtruth_extractor/tests/conanfile_default.py +++ /dev/null @@ -1,32 +0,0 @@ -from pathlib import Path -from conan import ConanFile - - -class CloeTest(ConanFile): - python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" - python_requires_extend = "cloe-launch-profile.Base" - - default_options = { - "cloe-engine:server": False, - } - - @property - def cloe_launch_env(self): - return { - "CLOE_LOG_LEVEL": "debug", - "CLOE_STRICT_MODE": "1", - "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "../../..", - } - - def set_version(self): - self.version = self.project_version("../../../VERSION") - - def requirements(self): - self.requires(f"cloe-engine/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-basic/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-minimator/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-gndtruth-extractor/{self.version}@cloe/develop") - - if self.options["cloe-engine"].server: - self.requires("boost/[<1.70]", override=True) diff --git a/plugins/minimator/CMakeLists.txt b/plugins/minimator/CMakeLists.txt index 2a06b5db6..372d52a94 100644 --- a/plugins/minimator/CMakeLists.txt +++ b/plugins/minimator/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_minimator LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/minimator/conanfile.py b/plugins/minimator/conanfile.py index 0b3f57f56..16f9a38d5 100644 --- a/plugins/minimator/conanfile.py +++ b/plugins/minimator/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -74,3 +75,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/minimator/tests/conanfile_default.py b/plugins/minimator/tests/conanfile_default.py deleted file mode 100644 index 4c12e3182..000000000 --- a/plugins/minimator/tests/conanfile_default.py +++ /dev/null @@ -1,35 +0,0 @@ -# mypy: ignore-errors -# pylint: skip-file - -from pathlib import Path - -from conan import ConanFile - - -class CloeTest(ConanFile): - python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" - python_requires_extend = "cloe-launch-profile.Base" - - default_options = { - "cloe-engine:server": True, - } - - @property - def cloe_launch_env(self): - return { - "CLOE_LOG_LEVEL": "debug", - "CLOE_STRICT_MODE": "1", - "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "../../..", - } - - def set_version(self): - self.version = self.project_version("../../../VERSION") - - def requirements(self): - self.requires(f"cloe-engine/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-basic/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-minimator/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-noisy-sensor/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-speedometer/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop") diff --git a/plugins/mocks/CMakeLists.txt b/plugins/mocks/CMakeLists.txt index b21f67bb0..d6a357498 100644 --- a/plugins/mocks/CMakeLists.txt +++ b/plugins/mocks/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_mocks LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/mocks/conanfile.py b/plugins/mocks/conanfile.py index 27b2ffebb..39667172e 100644 --- a/plugins/mocks/conanfile.py +++ b/plugins/mocks/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -71,3 +72,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/noisy_sensor/CMakeLists.txt b/plugins/noisy_sensor/CMakeLists.txt index 0245e916d..2fbe1ebef 100644 --- a/plugins/noisy_sensor/CMakeLists.txt +++ b/plugins/noisy_sensor/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_noisy_sensors LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/noisy_sensor/conanfile.py b/plugins/noisy_sensor/conanfile.py index 1ec756da3..395edf292 100644 --- a/plugins/noisy_sensor/conanfile.py +++ b/plugins/noisy_sensor/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -76,3 +77,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/speedometer/CMakeLists.txt b/plugins/speedometer/CMakeLists.txt index d6465a593..6c2873022 100644 --- a/plugins/speedometer/CMakeLists.txt +++ b/plugins/speedometer/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_speedometer LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/speedometer/conanfile.py b/plugins/speedometer/conanfile.py index 9ab5e1eda..e9e0ce661 100644 --- a/plugins/speedometer/conanfile.py +++ b/plugins/speedometer/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -71,3 +72,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/virtue/CMakeLists.txt b/plugins/virtue/CMakeLists.txt index 5cecbc970..036786e75 100644 --- a/plugins/virtue/CMakeLists.txt +++ b/plugins/virtue/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_virtue LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED) + find_package(cloe-models REQUIRED) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/virtue/conanfile.py b/plugins/virtue/conanfile.py index 5066a8cb4..3caf9d691 100644 --- a/plugins/virtue/conanfile.py +++ b/plugins/virtue/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -71,3 +72,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/virtue/tests/conanfile_default.py b/plugins/virtue/tests/conanfile_default.py deleted file mode 100644 index 4c12e3182..000000000 --- a/plugins/virtue/tests/conanfile_default.py +++ /dev/null @@ -1,35 +0,0 @@ -# mypy: ignore-errors -# pylint: skip-file - -from pathlib import Path - -from conan import ConanFile - - -class CloeTest(ConanFile): - python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" - python_requires_extend = "cloe-launch-profile.Base" - - default_options = { - "cloe-engine:server": True, - } - - @property - def cloe_launch_env(self): - return { - "CLOE_LOG_LEVEL": "debug", - "CLOE_STRICT_MODE": "1", - "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "../../..", - } - - def set_version(self): - self.version = self.project_version("../../../VERSION") - - def requirements(self): - self.requires(f"cloe-engine/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-basic/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-minimator/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-noisy-sensor/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-speedometer/{self.version}@cloe/develop") - self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop") diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 906def67e..cf500e0d7 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -8,10 +8,12 @@ set(CLOE_VERSION "0.0.0-undefined" CACHE STRING "Cloe version as MAJOR.MINOR.PAT set(CLOE_VERSION_U32 0 CACHE STRING "Cloe version as (MAJOR<<16)|(MINOR<<8)|PATCH integer") include(GNUInstallDirs) -include(cmake/TargetLinting.cmake) # Library ------------------------------------------------------------- -find_package(fable REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(fable REQUIRED) +endif() find_package(Boost COMPONENTS headers filesystem iostreams system REQUIRED) find_package(spdlog REQUIRED) find_package(inja REQUIRED) @@ -54,7 +56,6 @@ set_target_properties(cloe-runtime PROPERTIES CXX_STANDARD_REQUIRED ON VERSION ${CLOE_VERSION} ) -set_target_linting(cloe-runtime) configure_file(src/cloe/version.hpp.in include/cloe/version.hpp @ONLY) target_include_directories(cloe-runtime PUBLIC diff --git a/runtime/cmake/CloePluginSetup.cmake b/runtime/cmake/CloePluginSetup.cmake index 7d8f6c4a1..e3054898c 100644 --- a/runtime/cmake/CloePluginSetup.cmake +++ b/runtime/cmake/CloePluginSetup.cmake @@ -6,7 +6,7 @@ include(TargetLinting) function(cloe_add_plugin) set(options - NO_LINTING + LINT ) set(one_value_args TARGET # [required] @@ -44,7 +44,7 @@ function(cloe_add_plugin) message(SEND_ERROR "cloe_add_plugin requires property SOURCES to be set") endif() if(NOT DEFINED _ARG_OUTPUT_DIRECTORY) - set(_ARG_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/cloe) + set(_ARG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cloe) endif() # Add the cloe plugin target: @@ -71,7 +71,7 @@ function(cloe_add_plugin) OUTPUT_NAME ${_ARG_OUTPUT_NAME} PREFIX "" ) - if(NOT ${_ARG_NO_LINTING}) + if(${_ARG_LINT}) set_target_linting(${target}) endif() target_compile_options(${target} diff --git a/tests/conanfile_default.py b/tests/conanfile_all.py similarity index 74% rename from tests/conanfile_default.py rename to tests/conanfile_all.py index f02947e98..0b4ac41f7 100644 --- a/tests/conanfile_default.py +++ b/tests/conanfile_all.py @@ -10,14 +10,17 @@ class CloeTest(ConanFile): python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" python_requires_extend = "cloe-launch-profile.Base" + options = { + "with_vtd": [True, False] + } default_options = { - "cloe:with_vtd": False, - "cloe-engine:server": True, + "with_vtd": False } @property def cloe_launch_env(self): return { + "CLOE_ENGINE_WITH_SERVER": "1", "CLOE_LOG_LEVEL": "debug", "CLOE_STRICT_MODE": "1", "CLOE_WRITE_OUTPUT": "0", @@ -29,8 +32,9 @@ def set_version(self): def requirements(self): self.requires(f"cloe/{self.version}@cloe/develop") - if self.options["cloe"].with_vtd: - # These dependencies aren't pulled in by the "cloe" package, + if self.options.with_vtd: + self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop") + # These dependencies aren't pulled in by the "cloe-plugin-vtd" package, # because they are not required to build the package. # We need them to run the tests though. self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable") diff --git a/tests/conanfile_with_boost_1.78.py b/tests/conanfile_split.py similarity index 69% rename from tests/conanfile_with_boost_1.78.py rename to tests/conanfile_split.py index c7986e073..6ffa4d153 100644 --- a/tests/conanfile_with_boost_1.78.py +++ b/tests/conanfile_split.py @@ -10,14 +10,17 @@ class CloeTest(ConanFile): python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" python_requires_extend = "cloe-launch-profile.Base" + options = { + "with_vtd": [True, False] + } default_options = { - "cloe:with_vtd": False, - "cloe-engine:server": True, + "with_vtd": False } @property def cloe_launch_env(self): return { + "CLOE_ENGINE_WITH_SERVER": "1", "CLOE_LOG_LEVEL": "debug", "CLOE_STRICT_MODE": "1", "CLOE_WRITE_OUTPUT": "0", @@ -28,12 +31,11 @@ def set_version(self): self.version = self.project_version("../VERSION") def requirements(self): - self.requires(f"cloe/{self.version}@cloe/develop") - if self.options["cloe"].with_vtd: - # These dependencies aren't pulled in by the "cloe" package, + self.requires(f"cloe-meta/{self.version}@cloe/develop") + if self.options.with_vtd: + self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop") + # These dependencies aren't pulled in by the "cloe-plugin-vtd" package, # because they are not required to build the package. # We need them to run the tests though. self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable") self.requires("vtd/2.2.0@cloe-restricted/stable") - - self.requires("boost/1.78.0", override=True) diff --git a/tests/conanfile_split_without_server.py b/tests/conanfile_split_without_server.py new file mode 100644 index 000000000..9ff6757bc --- /dev/null +++ b/tests/conanfile_split_without_server.py @@ -0,0 +1,43 @@ +# mypy: ignore-errors +# pylint: skip-file + +from pathlib import Path + +from conan import ConanFile + + +class CloeTest(ConanFile): + python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" + python_requires_extend = "cloe-launch-profile.Base" + + options = { + "with_vtd": [True, False] + } + default_options = { + "with_vtd": False, + + "cloe-engine:server": False, + } + + @property + def cloe_launch_env(self): + return { + "CLOE_ENGINE_WITH_SERVER": "1", + "CLOE_LOG_LEVEL": "debug", + "CLOE_STRICT_MODE": "1", + "CLOE_WRITE_OUTPUT": "0", + "CLOE_ROOT": Path(self.recipe_folder) / "..", + } + + def set_version(self): + self.version = self.project_version("../VERSION") + + def requirements(self): + self.requires(f"cloe-meta/{self.version}@cloe/develop") + if self.options.with_vtd: + self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop") + # These dependencies aren't pulled in by the "cloe-plugin-vtd" package, + # because they are not required to build the package. + # We need them to run the tests though. + self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable") + self.requires("vtd/2.2.0@cloe-restricted/stable") diff --git a/plugins/minimator/tests/config_minimator_infinite.json b/tests/config_minimator_infinite.json similarity index 96% rename from plugins/minimator/tests/config_minimator_infinite.json rename to tests/config_minimator_infinite.json index 89e1c8aca..29fdc85b3 100644 --- a/plugins/minimator/tests/config_minimator_infinite.json +++ b/tests/config_minimator_infinite.json @@ -1,7 +1,7 @@ { "version": "4", "include": [ - "${CLOE_ROOT}/tests/controller_basic.json" + "just_controller_basic.json" ], "defaults": { "controllers": [ diff --git a/plugins/minimator/tests/config_minimator_multi_agent_infinite.json b/tests/config_minimator_multi_agent_infinite.json similarity index 100% rename from plugins/minimator/tests/config_minimator_multi_agent_infinite.json rename to tests/config_minimator_multi_agent_infinite.json diff --git a/plugins/minimator/tests/config_minimator_smoketest.json b/tests/config_minimator_smoketest.json similarity index 100% rename from plugins/minimator/tests/config_minimator_smoketest.json rename to tests/config_minimator_smoketest.json diff --git a/tests/config_nop_infinite.json b/tests/config_nop_infinite.json index e29064ef0..d58449bcc 100644 --- a/tests/config_nop_infinite.json +++ b/tests/config_nop_infinite.json @@ -1,8 +1,8 @@ { "version": "4", "include": [ - "controller_virtue.json", - "controller_basic.json" + "just_controller_virtue.json", + "just_controller_basic.json" ], "simulators": [ { diff --git a/tests/config_nop_smoketest.json b/tests/config_nop_smoketest.json index 8ba355399..238708186 100644 --- a/tests/config_nop_smoketest.json +++ b/tests/config_nop_smoketest.json @@ -1,53 +1,12 @@ { "version": "4", "include": [ - "controller_virtue.json", - "controller_basic.json" + "config_nop_infinite.json" ], - "simulators": [ - { - "binding": "nop" - } - ], - "vehicles": [ - { - "name": "default", - "from": { - "simulator": "nop", - "index": 0 - }, - "components": { - "cloe::speedometer": { - "binding": "speedometer", - "name": "default_speed", - "from": "cloe::gndtruth_ego_sensor" - }, - "cloe::default_world_sensor": { - "binding": "noisy_object_sensor", - "name": "noisy_object_sensor", - "from": "cloe::default_world_sensor", - "args": { - "noise": [ - { - "target": "translation", - "distribution": { - "binding": "normal", - "mean": 0.0, - "std_deviation": 0.3 - } - } - ] - } - } - } - } - ], - "server": { "listen": false, "listen_port": 23456 }, - "triggers": [ {"event": "virtue/failure", "action": "fail"}, { diff --git a/tests/controller_basic.json b/tests/controller_basic.json deleted file mode 100644 index ffbb760ac..000000000 --- a/tests/controller_basic.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "version": "4", - - "controllers": [ - { - "binding": "basic", - "vehicle": "default" - } - ], - - "triggers": [ - { - "event": "start", - "action": { - "name": "bundle", - "actions": [ - "basic/hmi=!enable" - ] - } - }, - { "event": "next=1", "action": "basic/hmi=enable" }, - { "event": "time=5", "action": "basic/hmi=resume" }, - { "event": "time=5.5", "action": "basic/hmi=!resume" }, - { - "label": "Push and release basic/hmi=plus", - "event": "time=6", - "action": { - "name": "insert", - "triggers": [ - { "event": "next", "action": "basic/hmi=plus" }, - { "event": "next=1", "action": "basic/hmi=!plus" } - ] - } - } - ] -} diff --git a/tests/controller_virtue.json b/tests/controller_virtue.json deleted file mode 100644 index 15453a5fb..000000000 --- a/tests/controller_virtue.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": "4", - - "controllers": [ - { - "binding": "virtue", - "vehicle": "default" - } - ] -} diff --git a/engine/tests/controller_basic.json b/tests/just_controller_basic.json similarity index 100% rename from engine/tests/controller_basic.json rename to tests/just_controller_basic.json diff --git a/engine/tests/controller_virtue.json b/tests/just_controller_virtue.json similarity index 100% rename from engine/tests/controller_virtue.json rename to tests/just_controller_virtue.json diff --git a/tests/debug_callgrind.json b/tests/option_debug_callgrind.json similarity index 100% rename from tests/debug_callgrind.json rename to tests/option_debug_callgrind.json diff --git a/engine/tests/project.lua b/tests/project.lua similarity index 100% rename from engine/tests/project.lua rename to tests/project.lua diff --git a/engine/tests/report_config.lua b/tests/report_config.lua similarity index 100% rename from engine/tests/report_config.lua rename to tests/report_config.lua diff --git a/tests/setup_bats.bash b/tests/setup_bats.bash index c9f04feaa..093440a72 100644 --- a/tests/setup_bats.bash +++ b/tests/setup_bats.bash @@ -1,5 +1,8 @@ #!/usr/bin/env bats +# All tests are run from within the tests/ directory. +cd "${BATS_TEST_DIRNAME}" + # The path to use whenever we need a temporary registry. Whenever we use this, we # probably want to specify the `--write-output` flag too, otherwise nothing will # be written to the registry. @@ -45,3 +48,15 @@ test_plugin_exists() { cloe-engine usage "${plugin}" &>/dev/null } + +require_program() { + if ! type $1 &>/dev/null; then + skip "required program not present: $1" + fi +} + +require_engine_with_server() { + if ! cloe-engine version | grep -F "server: true" &>/dev/null; then + skip "required engine option not set: server" + fi +} diff --git a/engine/tests/test_engine.bats b/tests/test_engine.bats similarity index 93% rename from engine/tests/test_engine.bats rename to tests/test_engine.bats index 3f5bd8806..e85061d02 100755 --- a/engine/tests/test_engine.bats +++ b/tests/test_engine.bats @@ -1,21 +1,7 @@ #!/usr/bin/env bats -cd "${BATS_TEST_DIRNAME}" -export CLOE_ROOT="${BATS_TEST_DIRNAME}/../.." -load "${CLOE_ROOT}/tests/setup_bats.bash" -load "${CLOE_ROOT}/tests/setup_testname.bash" - -require_program() { - if ! type $1 &>/dev/null; then - skip "required program not present: $1" - fi -} - -require_engine_with_server() { - if ! cloe-engine version | grep -F "server: true" &>/dev/null; then - skip "required engine option not set: server" - fi -} +load setup_bats +load setup_testname @test "$(testname 'Expect schema equality' 'test_engine_json_schema.json' '4d368665-b666-4289-8a7a-b76ca53db688')" { # Note: you will have to update the schema files every time you change the schema, @@ -37,9 +23,9 @@ require_engine_with_server() { # This does not negatively affect the validity of the test. reference_file=test_engine_nop_smoketest_dump.json diff <(cloe-engine dump config_nop_smoketest.json | - sed -r -e 's#"/.*\/.*.conan/data/([^/]+)/.*"#"/.../\1/.../"#' \ - -e '\#\.\.\./cloe-engine/\.\.\.#d' \ - -e "\\#(${HOME-/root}|${CONAN_USER_HOME-/cloe_dev})/.*#d" \ + sed -r -e '#"/.*\/.*.conan/data/([^/]+)/.*"#d' \ + -e '\#\.\.\./cloe-engine/\.\.\.#d' \ + -e "\\#(${HOME-/root}|${CONAN_USER_HOME-/cloe_dev})/.*#d" \ ) \ ${reference_file} } @@ -292,13 +278,13 @@ require_engine_with_server() { } @test "$(testname 'Expect check/run success' 'test_engine_smoketest.json [ts=5ms]' '1a31022c-e20c-4a9e-9373-ad54a3729442')" { - local timestep_stack="${CLOE_ROOT}/tests/option_timestep_5.json" + local timestep_stack="option_timestep_5.json" cloe-engine check test_engine_smoketest.json "${timestep_stack}" cloe-engine run test_engine_smoketest.json "${timestep_stack}" } @test "$(testname 'Expect check/run success' 'test_engine_smoketest.json [ts=60ms]' 'e7957fa0-1145-4458-b665-eec51c1f0da5')" { - local timestep_stack="${CLOE_ROOT}/tests/option_timestep_60.json" + local timestep_stack="option_timestep_60.json" cloe-engine check test_engine_smoketest.json "${timestep_stack}" cloe-engine run test_engine_smoketest.json "${timestep_stack}" } diff --git a/engine/tests/test_engine_bad_logging.json b/tests/test_engine_bad_logging.json similarity index 100% rename from engine/tests/test_engine_bad_logging.json rename to tests/test_engine_bad_logging.json diff --git a/engine/tests/test_engine_curl_succeed.json b/tests/test_engine_curl_succeed.json similarity index 100% rename from engine/tests/test_engine_curl_succeed.json rename to tests/test_engine_curl_succeed.json diff --git a/engine/tests/test_engine_empty.json b/tests/test_engine_empty.json similarity index 100% rename from engine/tests/test_engine_empty.json rename to tests/test_engine_empty.json diff --git a/engine/tests/test_engine_fail_trigger.json b/tests/test_engine_fail_trigger.json similarity index 100% rename from engine/tests/test_engine_fail_trigger.json rename to tests/test_engine_fail_trigger.json diff --git a/engine/tests/test_engine_hook_failure.json b/tests/test_engine_hook_failure.json similarity index 100% rename from engine/tests/test_engine_hook_failure.json rename to tests/test_engine_hook_failure.json diff --git a/engine/tests/test_engine_hook_invalid.json b/tests/test_engine_hook_invalid.json similarity index 100% rename from engine/tests/test_engine_hook_invalid.json rename to tests/test_engine_hook_invalid.json diff --git a/engine/tests/test_engine_hook_noexec.json b/tests/test_engine_hook_noexec.json similarity index 100% rename from engine/tests/test_engine_hook_noexec.json rename to tests/test_engine_hook_noexec.json diff --git a/engine/tests/test_engine_hook_ok.json b/tests/test_engine_hook_ok.json similarity index 100% rename from engine/tests/test_engine_hook_ok.json rename to tests/test_engine_hook_ok.json diff --git a/engine/tests/test_engine_ignore.json b/tests/test_engine_ignore.json similarity index 100% rename from engine/tests/test_engine_ignore.json rename to tests/test_engine_ignore.json diff --git a/engine/tests/test_engine_include_nonexistent.json b/tests/test_engine_include_nonexistent.json similarity index 100% rename from engine/tests/test_engine_include_nonexistent.json rename to tests/test_engine_include_nonexistent.json diff --git a/engine/tests/test_engine_include_self.json b/tests/test_engine_include_self.json similarity index 100% rename from engine/tests/test_engine_include_self.json rename to tests/test_engine_include_self.json diff --git a/engine/tests/test_engine_incomplete.json b/tests/test_engine_incomplete.json similarity index 100% rename from engine/tests/test_engine_incomplete.json rename to tests/test_engine_incomplete.json diff --git a/engine/tests/test_engine_invalid_trigger.json b/tests/test_engine_invalid_trigger.json similarity index 100% rename from engine/tests/test_engine_invalid_trigger.json rename to tests/test_engine_invalid_trigger.json diff --git a/engine/tests/test_engine_json_schema.json b/tests/test_engine_json_schema.json similarity index 95% rename from engine/tests/test_engine_json_schema.json rename to tests/test_engine_json_schema.json index 66bcae948..869b3ebf5 100644 --- a/engine/tests/test_engine_json_schema.json +++ b/tests/test_engine_json_schema.json @@ -252,6 +252,59 @@ ], "type": "object" }, + { + "additionalProperties": false, + "properties": { + "args": { + "additionalProperties": false, + "properties": { + "components": { + "description": "array of components to be extracted", + "items": { + "type": "string" + }, + "type": "array" + }, + "output_file": { + "description": "file path to write groundtruth output to", + "type": "string" + }, + "output_type": { + "description": "type of output file to write", + "enum": [ + "json.bz2", + "json.gz", + "json.zip", + "json", + "msgpack.bz2", + "msgpack.gz", + "msgpack.zip", + "msgpack" + ], + "type": "string" + } + }, + "type": "object" + }, + "binding": { + "const": "gndtruth_extractor", + "description": "name of factory" + }, + "name": { + "description": "globally unique identifier for controller", + "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$", + "type": "string" + }, + "vehicle": { + "description": "vehicle controller is assigned to", + "type": "string" + } + }, + "required": [ + "binding" + ], + "type": "object" + }, { "additionalProperties": false, "properties": { @@ -1083,6 +1136,37 @@ "description": "simulator configuration", "items": { "oneOf": [ + { + "additionalProperties": false, + "properties": { + "args": { + "additionalProperties": false, + "properties": { + "vehicles": { + "description": "list of vehicle names to make available", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, + "binding": { + "const": "minimator", + "description": "name of factory" + }, + "name": { + "description": "globally unique identifier for simulator", + "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$", + "type": "string" + } + }, + "required": [ + "binding" + ], + "type": "object" + }, { "additionalProperties": false, "properties": { diff --git a/engine/tests/test_engine_keep_alive.json b/tests/test_engine_keep_alive.json similarity index 100% rename from engine/tests/test_engine_keep_alive.json rename to tests/test_engine_keep_alive.json diff --git a/engine/tests/test_engine_lua.json b/tests/test_engine_lua.json similarity index 100% rename from engine/tests/test_engine_lua.json rename to tests/test_engine_lua.json diff --git a/engine/tests/test_engine_namespaced_smoketest.json b/tests/test_engine_namespaced_smoketest.json similarity index 100% rename from engine/tests/test_engine_namespaced_smoketest.json rename to tests/test_engine_namespaced_smoketest.json diff --git a/engine/tests/test_engine_no_binding.json b/tests/test_engine_no_binding.json similarity index 100% rename from engine/tests/test_engine_no_binding.json rename to tests/test_engine_no_binding.json diff --git a/engine/tests/test_engine_no_vehicle.json b/tests/test_engine_no_vehicle.json similarity index 100% rename from engine/tests/test_engine_no_vehicle.json rename to tests/test_engine_no_vehicle.json diff --git a/engine/tests/test_engine_nop_smoketest_dump.json b/tests/test_engine_nop_smoketest_dump.json similarity index 96% rename from engine/tests/test_engine_nop_smoketest_dump.json rename to tests/test_engine_nop_smoketest_dump.json index d0ae625ac..157a818ff 100644 --- a/engine/tests/test_engine_nop_smoketest_dump.json +++ b/tests/test_engine_nop_smoketest_dump.json @@ -32,11 +32,6 @@ "path": "${CLOE_SIMULATION_UUID}" }, "plugin_path": [ - "/.../cloe-plugin-basic/.../", - "/.../cloe-plugin-mocks/.../", - "/.../cloe-plugin-noisy-sensor/.../", - "/.../cloe-plugin-speedometer/.../", - "/.../cloe-plugin-virtue/.../" ], "plugins": { "allow_clobber": true, diff --git a/engine/tests/test_engine_optional_trigger.json b/tests/test_engine_optional_trigger.json similarity index 100% rename from engine/tests/test_engine_optional_trigger.json rename to tests/test_engine_optional_trigger.json diff --git a/engine/tests/test_engine_pause.json b/tests/test_engine_pause.json similarity index 100% rename from engine/tests/test_engine_pause.json rename to tests/test_engine_pause.json diff --git a/engine/tests/test_engine_replica_smoketest.bats b/tests/test_engine_replica_smoketest.bats similarity index 93% rename from engine/tests/test_engine_replica_smoketest.bats rename to tests/test_engine_replica_smoketest.bats index c0d19d35f..89db3d87f 100755 --- a/engine/tests/test_engine_replica_smoketest.bats +++ b/tests/test_engine_replica_smoketest.bats @@ -4,10 +4,8 @@ # configuration of a simulation results in roughly the same output # again, i.e., the simulation is reproducible. -cd "${BATS_TEST_DIRNAME}" -export CLOE_ROOT="${BATS_TEST_DIRNAME}/../.." -load "${CLOE_ROOT}/tests/setup_bats.bash" -load "${CLOE_ROOT}/tests/setup_testname.bash" +load setup_bats +load setup_testname teardown() { # Remove the temporary registry. diff --git a/engine/tests/test_engine_replica_smoketest.json b/tests/test_engine_replica_smoketest.json similarity index 100% rename from engine/tests/test_engine_replica_smoketest.json rename to tests/test_engine_replica_smoketest.json diff --git a/engine/tests/test_engine_smoketest.json b/tests/test_engine_smoketest.json similarity index 100% rename from engine/tests/test_engine_smoketest.json rename to tests/test_engine_smoketest.json diff --git a/engine/tests/test_engine_start_stop.json b/tests/test_engine_start_stop.json similarity index 100% rename from engine/tests/test_engine_start_stop.json rename to tests/test_engine_start_stop.json diff --git a/engine/tests/test_engine_sticky_trigger.json b/tests/test_engine_sticky_trigger.json similarity index 100% rename from engine/tests/test_engine_sticky_trigger.json rename to tests/test_engine_sticky_trigger.json diff --git a/engine/tests/test_engine_stuck_controller.json b/tests/test_engine_stuck_controller.json similarity index 100% rename from engine/tests/test_engine_stuck_controller.json rename to tests/test_engine_stuck_controller.json diff --git a/engine/tests/test_engine_stuck_controller_continue.json b/tests/test_engine_stuck_controller_continue.json similarity index 100% rename from engine/tests/test_engine_stuck_controller_continue.json rename to tests/test_engine_stuck_controller_continue.json diff --git a/engine/tests/test_engine_unknown_vehicle.json b/tests/test_engine_unknown_vehicle.json similarity index 100% rename from engine/tests/test_engine_unknown_vehicle.json rename to tests/test_engine_unknown_vehicle.json diff --git a/engine/tests/test_engine_version_absent.json b/tests/test_engine_version_absent.json similarity index 100% rename from engine/tests/test_engine_version_absent.json rename to tests/test_engine_version_absent.json diff --git a/engine/tests/test_engine_version_wrong.json b/tests/test_engine_version_wrong.json similarity index 100% rename from engine/tests/test_engine_version_wrong.json rename to tests/test_engine_version_wrong.json diff --git a/engine/tests/test_engine_watchdog.json b/tests/test_engine_watchdog.json similarity index 100% rename from engine/tests/test_engine_watchdog.json rename to tests/test_engine_watchdog.json diff --git a/plugins/gndtruth_extractor/tests/test_gndtruth.bats b/tests/test_gndtruth.bats similarity index 93% rename from plugins/gndtruth_extractor/tests/test_gndtruth.bats rename to tests/test_gndtruth.bats index 582a5c50a..a5681b801 100755 --- a/plugins/gndtruth_extractor/tests/test_gndtruth.bats +++ b/tests/test_gndtruth.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats -cd "${BATS_TEST_DIRNAME}" -export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.." -load "${CLOE_ROOT}/tests/setup_bats.bash" -load "${CLOE_ROOT}/tests/setup_testname.bash" +load setup_bats +load setup_testname # Usage: FILENAME=$(mktemp_gndtruth_out SUFFIX) # diff --git a/plugins/gndtruth_extractor/tests/config_minimator_smoketest.json b/tests/test_gndtruth_config.json similarity index 89% rename from plugins/gndtruth_extractor/tests/config_minimator_smoketest.json rename to tests/test_gndtruth_config.json index f6e51b69d..dfe60fb3a 100644 --- a/plugins/gndtruth_extractor/tests/config_minimator_smoketest.json +++ b/tests/test_gndtruth_config.json @@ -1,7 +1,7 @@ { "version": "4", "include": [ - "${CLOE_ROOT}/tests/controller_basic.json" + "${CLOE_ROOT}/tests/just_controller_basic.json" ], "simulators": [ { diff --git a/plugins/gndtruth_extractor/tests/test_gndtruth_invalid_file.json b/tests/test_gndtruth_invalid_file.json similarity index 86% rename from plugins/gndtruth_extractor/tests/test_gndtruth_invalid_file.json rename to tests/test_gndtruth_invalid_file.json index 3b27211a7..0aa552d9d 100644 --- a/plugins/gndtruth_extractor/tests/test_gndtruth_invalid_file.json +++ b/tests/test_gndtruth_invalid_file.json @@ -1,7 +1,7 @@ { "version": "4", "include": [ - "config_minimator_smoketest.json" + "test_gndtruth_config.json" ], "controllers": [ { diff --git a/plugins/gndtruth_extractor/tests/test_gndtruth_smoketest.json b/tests/test_gndtruth_smoketest.json similarity index 96% rename from plugins/gndtruth_extractor/tests/test_gndtruth_smoketest.json rename to tests/test_gndtruth_smoketest.json index c57168a79..bc1df7e3b 100644 --- a/plugins/gndtruth_extractor/tests/test_gndtruth_smoketest.json +++ b/tests/test_gndtruth_smoketest.json @@ -1,7 +1,7 @@ { "version": "4", "include": [ - "config_minimator_smoketest.json" + "test_gndtruth_config.json" ], "controllers": [ { diff --git a/plugins/gndtruth_extractor/tests/test_gndtruth_smoketest_output.json b/tests/test_gndtruth_smoketest_output.json similarity index 100% rename from plugins/gndtruth_extractor/tests/test_gndtruth_smoketest_output.json rename to tests/test_gndtruth_smoketest_output.json diff --git a/plugins/gndtruth_extractor/tests/test_gndtruth_smoketest_output.msgpack b/tests/test_gndtruth_smoketest_output.msgpack similarity index 100% rename from plugins/gndtruth_extractor/tests/test_gndtruth_smoketest_output.msgpack rename to tests/test_gndtruth_smoketest_output.msgpack diff --git a/engine/tests/test_lua.bats b/tests/test_lua.bats similarity index 93% rename from engine/tests/test_lua.bats rename to tests/test_lua.bats index b938c65ef..cd8dc2579 100755 --- a/engine/tests/test_lua.bats +++ b/tests/test_lua.bats @@ -1,15 +1,7 @@ #!/usr/bin/env bats -cd "${BATS_TEST_DIRNAME}" -export CLOE_ROOT="${BATS_TEST_DIRNAME}/../.." -load "${CLOE_ROOT}/tests/setup_bats.bash" -load "${CLOE_ROOT}/tests/setup_testname.bash" - -require_program() { - if ! type $1 &>/dev/null; then - skip "required program not present: $1" - fi -} +load setup_bats +load setup_testname @test "$(testname 'Expect success' 'test_lua01_include_json.lua' '224b2b67-1aaf-4ba2-855c-9bf986574e30')" { cloe-engine run test_lua01_include_json.lua diff --git a/engine/tests/test_lua01_include_json.lua b/tests/test_lua01_include_json.lua similarity index 100% rename from engine/tests/test_lua01_include_json.lua rename to tests/test_lua01_include_json.lua diff --git a/engine/tests/test_lua02_schedule.lua b/tests/test_lua02_schedule.lua similarity index 100% rename from engine/tests/test_lua02_schedule.lua rename to tests/test_lua02_schedule.lua diff --git a/engine/tests/test_lua03_schedule_unpin.lua b/tests/test_lua03_schedule_unpin.lua similarity index 100% rename from engine/tests/test_lua03_schedule_unpin.lua rename to tests/test_lua03_schedule_unpin.lua diff --git a/engine/tests/test_lua04_schedule_test.lua b/tests/test_lua04_schedule_test.lua similarity index 100% rename from engine/tests/test_lua04_schedule_test.lua rename to tests/test_lua04_schedule_test.lua diff --git a/engine/tests/test_lua05_apply_stack.lua b/tests/test_lua05_apply_stack.lua similarity index 100% rename from engine/tests/test_lua05_apply_stack.lua rename to tests/test_lua05_apply_stack.lua diff --git a/engine/tests/test_lua06_apply_stack.lua b/tests/test_lua06_apply_stack.lua similarity index 100% rename from engine/tests/test_lua06_apply_stack.lua rename to tests/test_lua06_apply_stack.lua diff --git a/engine/tests/test_lua07_schedule_pause.lua b/tests/test_lua07_schedule_pause.lua similarity index 100% rename from engine/tests/test_lua07_schedule_pause.lua rename to tests/test_lua07_schedule_pause.lua diff --git a/engine/tests/test_lua08_apply_project.lua b/tests/test_lua08_apply_project.lua similarity index 100% rename from engine/tests/test_lua08_apply_project.lua rename to tests/test_lua08_apply_project.lua diff --git a/engine/tests/test_lua09_no_json.lua b/tests/test_lua09_no_json.lua similarity index 100% rename from engine/tests/test_lua09_no_json.lua rename to tests/test_lua09_no_json.lua diff --git a/engine/tests/test_lua10_heavy_cpu.lua b/tests/test_lua10_heavy_cpu.lua similarity index 100% rename from engine/tests/test_lua10_heavy_cpu.lua rename to tests/test_lua10_heavy_cpu.lua diff --git a/engine/tests/test_lua11_serial_tests.lua b/tests/test_lua11_serial_tests.lua similarity index 100% rename from engine/tests/test_lua11_serial_tests.lua rename to tests/test_lua11_serial_tests.lua diff --git a/engine/tests/test_lua12_fail_after_stop.lua b/tests/test_lua12_fail_after_stop.lua similarity index 97% rename from engine/tests/test_lua12_fail_after_stop.lua rename to tests/test_lua12_fail_after_stop.lua index e5dd5c4bf..bcba82bf3 100644 --- a/engine/tests/test_lua12_fail_after_stop.lua +++ b/tests/test_lua12_fail_after_stop.lua @@ -22,7 +22,6 @@ cloe.schedule_test { on = cloe.events.time("5s"), run = function(z) z:expect(true, "TEST-B has been a good test!") - z:assert end } diff --git a/engine/tests/test_lua13_bdd_eval.lua b/tests/test_lua13_bdd_eval.lua similarity index 100% rename from engine/tests/test_lua13_bdd_eval.lua rename to tests/test_lua13_bdd_eval.lua diff --git a/engine/tests/test_lua_api_cloe_system.lua b/tests/test_lua_api_cloe_system.lua similarity index 100% rename from engine/tests/test_lua_api_cloe_system.lua rename to tests/test_lua_api_cloe_system.lua diff --git a/engine/tests/test_lua_api_cloe_typecheck.lua b/tests/test_lua_api_cloe_typecheck.lua similarity index 100% rename from engine/tests/test_lua_api_cloe_typecheck.lua rename to tests/test_lua_api_cloe_typecheck.lua diff --git a/engine/tests/test_lua_error_coroutine.lua b/tests/test_lua_error_coroutine.lua similarity index 100% rename from engine/tests/test_lua_error_coroutine.lua rename to tests/test_lua_error_coroutine.lua diff --git a/engine/tests/test_lua_error_main.lua b/tests/test_lua_error_main.lua similarity index 100% rename from engine/tests/test_lua_error_main.lua rename to tests/test_lua_error_main.lua diff --git a/engine/tests/test_lua_error_schedule.lua b/tests/test_lua_error_schedule.lua similarity index 100% rename from engine/tests/test_lua_error_schedule.lua rename to tests/test_lua_error_schedule.lua diff --git a/engine/tests/test_lua_error_schedule_test.lua b/tests/test_lua_error_schedule_test.lua similarity index 100% rename from engine/tests/test_lua_error_schedule_test.lua rename to tests/test_lua_error_schedule_test.lua diff --git a/engine/tests/test_lua_error_segfault_on_resume.lua b/tests/test_lua_error_segfault_on_resume.lua similarity index 100% rename from engine/tests/test_lua_error_segfault_on_resume.lua rename to tests/test_lua_error_segfault_on_resume.lua diff --git a/plugins/minimator/tests/test_minimator.bats b/tests/test_minimator.bats similarity index 79% rename from plugins/minimator/tests/test_minimator.bats rename to tests/test_minimator.bats index 8699ec68b..b1b6570f8 100755 --- a/plugins/minimator/tests/test_minimator.bats +++ b/tests/test_minimator.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats -cd "${BATS_TEST_DIRNAME}" -export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.." -load "${CLOE_ROOT}/tests/setup_bats.bash" -load "${CLOE_ROOT}/tests/setup_testname.bash" +load setup_bats +load setup_testname @test "$(testname 'Expect check success' 'test_minimator_smoketest.json' 'c7a427e7-eb2b-4ae7-85ec-a35b7540d4aa')" { cloe-engine check test_minimator_smoketest.json @@ -14,13 +12,13 @@ load "${CLOE_ROOT}/tests/setup_testname.bash" } @test "$(testname 'Expect check/run success' 'test_minimator_smoketest.json [ts=5ms]' '57254185-5480-4859-b2a5-6c3a211a22e0')" { - local timestep_stack="${CLOE_ROOT}/tests/option_timestep_5.json" + local timestep_stack="option_timestep_5.json" cloe-engine check test_minimator_smoketest.json "${timestep_stack}" cloe-engine run test_minimator_smoketest.json "${timestep_stack}" } @test "$(testname 'Expect check/run success' 'test_minimator_smoketest.json [ts=60ms]' 'a0d4982f-8c02-4759-bc88-cc30a1ccbbf0')" { - local timestep_stack="${CLOE_ROOT}/tests/option_timestep_60.json" + local timestep_stack="option_timestep_60.json" cloe-engine check test_minimator_smoketest.json "${timestep_stack}" cloe-engine run test_minimator_smoketest.json "${timestep_stack}" } diff --git a/plugins/minimator/tests/test_minimator_multi_agent_smoketest.json b/tests/test_minimator_multi_agent_smoketest.json similarity index 93% rename from plugins/minimator/tests/test_minimator_multi_agent_smoketest.json rename to tests/test_minimator_multi_agent_smoketest.json index b3b2f9e19..26bda0f9f 100644 --- a/plugins/minimator/tests/test_minimator_multi_agent_smoketest.json +++ b/tests/test_minimator_multi_agent_smoketest.json @@ -2,7 +2,7 @@ "version": "4", "include": [ "config_minimator_multi_agent_infinite.json", - "${CLOE_ROOT}/tests/triggers_multi_agent.json" + "triggers_multi_agent.json" ], "server": { "listen": false, diff --git a/plugins/minimator/tests/test_minimator_smoketest.json b/tests/test_minimator_smoketest.json similarity index 100% rename from plugins/minimator/tests/test_minimator_smoketest.json rename to tests/test_minimator_smoketest.json diff --git a/plugins/virtue/tests/test_virtue.bats b/tests/test_virtue.bats similarity index 83% rename from plugins/virtue/tests/test_virtue.bats rename to tests/test_virtue.bats index b9f61b0a2..c4b654bdb 100755 --- a/plugins/virtue/tests/test_virtue.bats +++ b/tests/test_virtue.bats @@ -1,9 +1,7 @@ #!/usr/bin/env bats -cd "${BATS_TEST_DIRNAME}" -export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.." -load "${CLOE_ROOT}/tests/setup_bats.bash" -load "${CLOE_ROOT}/tests/setup_testname.bash" +load setup_bats +load setup_testname @test "$(testname 'Expect check success' 'test_virtue_missing_lanes_fail.json' 'd9072cc3-62f3-4f11-bf9e-b514fea67e4b')" { cloe-engine check test_virtue_missing_lanes_fail.json diff --git a/plugins/virtue/tests/test_virtue_missing_lanes_fail.json b/tests/test_virtue_missing_lanes_fail.json similarity index 92% rename from plugins/virtue/tests/test_virtue_missing_lanes_fail.json rename to tests/test_virtue_missing_lanes_fail.json index fdfbf9297..60be5ba93 100644 --- a/plugins/virtue/tests/test_virtue_missing_lanes_fail.json +++ b/tests/test_virtue_missing_lanes_fail.json @@ -1,7 +1,7 @@ { "version": "4", "include": [ - "${CLOE_ROOT}/tests/config_nop_infinite.json" + "config_nop_infinite.json" ], "defaults": { "controllers": [ diff --git a/plugins/virtue/tests/test_virtue_missing_lanes_pass.json b/tests/test_virtue_missing_lanes_pass.json similarity index 84% rename from plugins/virtue/tests/test_virtue_missing_lanes_pass.json rename to tests/test_virtue_missing_lanes_pass.json index eb76d9f81..55d90d104 100644 --- a/plugins/virtue/tests/test_virtue_missing_lanes_pass.json +++ b/tests/test_virtue_missing_lanes_pass.json @@ -1,7 +1,7 @@ { "version": "4", "include": [ - "${CLOE_ROOT}/plugins/minimator/tests/config_minimator_infinite.json" + "config_minimator_infinite.json" ], "server": { "listen": false