diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.clang-tidy | 1 | ||||
-rw-r--r-- | tests/TestClient.hpp | 10 | ||||
-rw-r--r-- | tests/ingen_bench.cpp | 32 | ||||
-rw-r--r-- | tests/ingen_test.cpp | 70 | ||||
-rw-r--r-- | tests/lint/meson.build | 24 | ||||
-rw-r--r-- | tests/meson.build | 37 | ||||
-rw-r--r-- | tests/test_utils.hpp | 4 |
7 files changed, 91 insertions, 87 deletions
diff --git a/tests/.clang-tidy b/tests/.clang-tidy index 7e189145..6c26f23c 100644 --- a/tests/.clang-tidy +++ b/tests/.clang-tidy @@ -10,7 +10,6 @@ Checks: > -cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-union-access, -fuchsia-statically-constructed-objects, - -google-readability-casting, -google-readability-todo, -llvm-header-guard, -readability-function-cognitive-complexity, diff --git a/tests/TestClient.hpp b/tests/TestClient.hpp index b864928e..72265b14 100644 --- a/tests/TestClient.hpp +++ b/tests/TestClient.hpp @@ -17,11 +17,11 @@ #ifndef INGEN_TESTCLIENT_HPP #define INGEN_TESTCLIENT_HPP -#include "ingen/Interface.hpp" -#include "ingen/Log.hpp" -#include "ingen/Message.hpp" -#include "ingen/Status.hpp" -#include "ingen/URI.hpp" +#include <ingen/Interface.hpp> +#include <ingen/Log.hpp> +#include <ingen/Message.hpp> +#include <ingen/Status.hpp> +#include <ingen/URI.hpp> #include <variant> diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp index 82fae78d..ee890401 100644 --- a/tests/ingen_bench.cpp +++ b/tests/ingen_bench.cpp @@ -14,14 +14,14 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "ingen/Atom.hpp" -#include "ingen/Clock.hpp" -#include "ingen/Configuration.hpp" -#include "ingen/EngineBase.hpp" -#include "ingen/Forge.hpp" -#include "ingen/Parser.hpp" -#include "ingen/World.hpp" -#include "ingen/runtime_paths.hpp" +#include <ingen/Atom.hpp> +#include <ingen/Clock.hpp> +#include <ingen/Configuration.hpp> +#include <ingen/EngineBase.hpp> +#include <ingen/Forge.hpp> +#include <ingen/Parser.hpp> +#include <ingen/World.hpp> +#include <ingen/runtime_paths.hpp> #include <chrono> #include <cstdint> @@ -41,7 +41,7 @@ void ingen_try(bool cond, const char* msg) { if (!cond) { - std::cerr << "ingen: Error: " << msg << std::endl; + std::cerr << "ingen: Error: " << msg << "\n"; world.reset(); exit(EXIT_FAILURE); } @@ -68,7 +68,7 @@ run(int argc, char** argv) ingen::Configuration::SESSION, world->forge().String, Atom()); world->load_configuration(argc, argv); } catch (std::exception& e) { - std::cout << "ingen: " << e.what() << std::endl; + std::cout << "ingen: " << e.what() << "\n"; return EXIT_FAILURE; } @@ -76,9 +76,7 @@ run(int argc, char** argv) const Atom& load = world->conf().option("load"); const Atom& out = world->conf().option("output"); if (!load.is_valid() || !out.is_valid()) { - std::cerr << "Usage: ingen_bench --load START_GRAPH --output OUT_FILE" - << std::endl; - + std::cerr << "Usage: ingen_bench --load START_GRAPH --output OUT_FILE\n"; return EXIT_FAILURE; } @@ -90,7 +88,7 @@ run(int argc, char** argv) if (start_graph.empty()) { std::cerr << "error: initial graph '" << static_cast<const char*>(load.get_body()) - << "' does not exist" << std::endl; + << "' does not exist\n"; return EXIT_FAILURE; } @@ -99,7 +97,7 @@ run(int argc, char** argv) "Unable to load server module"); // Initialise engine - ingen_try(bool(world->engine()), + ingen_try(!!world->engine(), "Unable to create engine"); world->engine()->init(48000.0, 4096, 4096); world->engine()->activate(); @@ -107,7 +105,7 @@ run(int argc, char** argv) // Load graph if (!world->parser()->parse_file(*world, *world->interface(), start_graph)) { std::cerr << "error: failed to load initial graph " << start_graph - << std::endl; + << "\n"; return EXIT_FAILURE; } @@ -132,7 +130,7 @@ run(int argc, char** argv) if (ftell(log.get()) == 0) { fprintf(log.get(), "# n_threads\trun_time\treal_time\n"); } - fprintf(log.get(), "%u\t%f\t%f\n", + fprintf(log.get(), "%d\t%f\t%f\n", world->conf().option("threads").get<int32_t>(), static_cast<double>(t_end - t_start) / 1000000.0, (n_test_frames / 48000.0)); diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index b1705dfa..215d20a1 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -16,26 +16,26 @@ #include "TestClient.hpp" -#include "ingen/Atom.hpp" -#include "ingen/AtomForge.hpp" -#include "ingen/AtomReader.hpp" -#include "ingen/Configuration.hpp" -#include "ingen/EngineBase.hpp" -#include "ingen/FilePath.hpp" -#include "ingen/Interface.hpp" -#include "ingen/Parser.hpp" -#include "ingen/Serialiser.hpp" -#include "ingen/Store.hpp" -#include "ingen/URI.hpp" -#include "ingen/URIMap.hpp" -#include "ingen/World.hpp" -#include "ingen/fmt.hpp" -#include "ingen/memory.hpp" -#include "ingen/runtime_paths.hpp" -#include "raul/Path.hpp" -#include "serd/serd.h" -#include "sord/sordmm.hpp" -#include "sratom/sratom.h" +#include <ingen/Atom.hpp> +#include <ingen/AtomForge.hpp> +#include <ingen/AtomReader.hpp> +#include <ingen/Configuration.hpp> +#include <ingen/EngineBase.hpp> +#include <ingen/FilePath.hpp> +#include <ingen/Interface.hpp> +#include <ingen/Parser.hpp> +#include <ingen/Serialiser.hpp> +#include <ingen/Store.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIMap.hpp> +#include <ingen/World.hpp> +#include <ingen/fmt.hpp> +#include <ingen/memory.hpp> +#include <ingen/runtime_paths.hpp> +#include <raul/Path.hpp> +#include <serd/serd.h> +#include <sord/sordmm.hpp> +#include <sratom/sratom.h> #include <chrono> #include <cstdint> @@ -48,6 +48,8 @@ #include <string> #include <utility> +// #define DUMP_EVENTS 1 + namespace ingen::test { namespace { @@ -57,7 +59,7 @@ void ingen_try(bool cond, const char* msg) { if (!cond) { - std::cerr << "ingen: Error: " << msg << std::endl; + std::cerr << "ingen: Error: " << msg << "\n"; world.reset(); exit(EXIT_FAILURE); } @@ -80,7 +82,7 @@ run(int argc, char** argv) world = std::make_unique<World>(nullptr, nullptr, nullptr); world->load_configuration(argc, argv); } catch (const std::exception& e) { - std::cerr << "ingen: " << e.what() << std::endl; + std::cerr << "ingen: " << e.what() << "\n"; return EXIT_FAILURE; } @@ -89,8 +91,7 @@ run(int argc, char** argv) const Atom& execute = world->conf().option("execute"); if (!load.is_valid() || !execute.is_valid()) { std::cerr - << "Usage: ingen_test --load START_GRAPH --execute COMMANDS_FILE" - << std::endl; + << "Usage: ingen_test --load START_GRAPH --execute COMMANDS_FILE\n"; return EXIT_FAILURE; } @@ -100,16 +101,12 @@ run(int argc, char** argv) const FilePath run_path = real_file_path(static_cast<const char*>(execute.get_body())); if (load_path.empty()) { - std::cerr << "error: initial graph '" << load_path << "' does not exist" - << std::endl; - + std::cerr << "error: initial graph '" << load_path << "' does not exist\n"; return EXIT_FAILURE; } if (run_path.empty()) { - std::cerr << "error: command file '" << run_path << "' does not exist" - << std::endl; - + std::cerr << "error: command file '" << run_path << "' does not exist\n"; return EXIT_FAILURE; } @@ -118,16 +115,14 @@ run(int argc, char** argv) "Unable to load server module"); // Initialise engine - ingen_try(bool(world->engine()), + ingen_try(!!world->engine(), "Unable to create engine"); world->engine()->init(48000.0, 4096, 4096); world->engine()->activate(); // Load graph if (!world->parser()->parse_file(*world, *world->interface(), load_path)) { - std::cerr << "error: failed to load initial graph " << load_path - << std::endl; - + std::cerr << "error: failed to load initial graph " << load_path << "\n"; return EXIT_FAILURE; } world->engine()->flush_events(std::chrono::milliseconds(20)); @@ -178,9 +173,9 @@ run(int argc, char** argv) forge.clear(); forge.read(*world->rdf_world(), cmds->c_obj(), subject.c_obj()); -#if 0 +#ifdef DUMP_EVENTS const LV2_Atom* atom = forge.atom(); - cerr << "READ " << atom->size << " BYTES" << endl; + cerr << "READ " << atom->size << " BYTES\n"; cerr << sratom_to_turtle( sratom, &world->uri_map().urid_unmap_feature()->urid_unmap, @@ -189,6 +184,7 @@ run(int argc, char** argv) #endif if (!atom_reader.write(forge.atom(), n_events + 1)) { + delete cmds; return EXIT_FAILURE; } @@ -249,7 +245,7 @@ main(int argc, char** argv) return ingen::test::run(argc, argv); } catch (const std::exception& e) { - std::cerr << "ingen: " << e.what() << std::endl; + std::cerr << "ingen: " << e.what() << "\n"; return EXIT_FAILURE; } } diff --git a/tests/lint/meson.build b/tests/lint/meson.build new file mode 100644 index 00000000..c641cbaa --- /dev/null +++ b/tests/lint/meson.build @@ -0,0 +1,24 @@ +# Copyright 2019-2024 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later + +if not meson.is_subproject() + # Check code with cppcheck + cppcheck = find_program('cppcheck', required: false) + if cppcheck.found() + compdb_path = join_paths(ingen_build_root, 'compile_commands.json') + suppress_path = join_paths(ingen_src_root, '.suppress.cppcheck') + test( + 'cppcheck', + cppcheck, + args: [ + '--cppcheck-build-dir=' + meson.current_build_dir(), + '--enable=warning,style,performance,portability', + '--error-exitcode=1', + '--project=' + compdb_path, + '--suppressions-list=' + suppress_path, + '-q', + ], + suite: 'code', + ) + endif +endif diff --git a/tests/meson.build b/tests/meson.build index 50b78624..1637230b 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,26 +1,6 @@ # Copyright 2019-2022 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later -############## -# Unit Tests # -############## - -unit_tests = [ -] - -foreach test : unit_tests - test( - test, - executable( - test, - files('tst_@0@.cpp'.format(test)), - cpp_args: cpp_suppressions + platform_defines, - dependencies: [ingen_dep], - ), - suite: 'unit', - ) -endforeach - ##################### # Integration Tests # ##################### @@ -93,10 +73,11 @@ test_env = environment( default_value: lv2dir, internal: 'plugindir', pkgconfig: 'plugindir', - ) + ), ], ), - }) + }, +) foreach test : integration_tests test( @@ -104,8 +85,16 @@ foreach test : integration_tests ingen_test, env: test_env, args: [ - '--load', empty_manifest, - '--execute', files(test + '.ttl'), + ['--load', empty_manifest], + ['--execute', files(test + '.ttl')], ], ) endforeach + +######## +# Lint # +######## + +if get_option('lint') + subdir('lint') +endif diff --git a/tests/test_utils.hpp b/tests/test_utils.hpp index e595b7c8..4c358739 100644 --- a/tests/test_utils.hpp +++ b/tests/test_utils.hpp @@ -14,13 +14,11 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "ingen/fmt.hpp" +#include <ingen/fmt.hpp> #include <iostream> #include <string> -// IWYU pragma: no_include "ingen/FilePath.hpp" - #define EXPECT_TRUE(value) \ do { \ if (!(value)) { \ |