From 6a04725375d75975fd853eaf36d4a5d40c5a3ec2 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 5 Feb 2019 14:01:13 +0100 Subject: [PATCH] Provide our own main() for unit-tests. The goal is to be able to use the --log=... command line parameters. --- src/kernel/resource/profile/trace_mgr_test.cpp | 3 +-- src/xbt/unit-tests_main.cpp | 16 ++++++++++++++++ tools/cmake/Tests.cmake | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/xbt/unit-tests_main.cpp diff --git a/src/kernel/resource/profile/trace_mgr_test.cpp b/src/kernel/resource/profile/trace_mgr_test.cpp index d09af5ee79..de942e2e03 100644 --- a/src/kernel/resource/profile/trace_mgr_test.cpp +++ b/src/kernel/resource/profile/trace_mgr_test.cpp @@ -3,8 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file -#include "src/include/catch.hpp" +#include "catch.hpp" #include "simgrid/kernel/resource/Resource.hpp" #include "src/kernel/resource/profile/trace_mgr.hpp" diff --git a/src/xbt/unit-tests_main.cpp b/src/xbt/unit-tests_main.cpp new file mode 100644 index 0000000000..390099964d --- /dev/null +++ b/src/xbt/unit-tests_main.cpp @@ -0,0 +1,16 @@ +/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#define CATCH_CONFIG_RUNNER // we supply our own main() + +#include "catch.hpp" + +#include "xbt/log.h" + +int main(int argc, char* argv[]) +{ + xbt_log_init(&argc, argv); + return Catch::Session().run(argc, argv); +} diff --git a/tools/cmake/Tests.cmake b/tools/cmake/Tests.cmake index 8ef455fcd4..107579e647 100644 --- a/tools/cmake/Tests.cmake +++ b/tools/cmake/Tests.cmake @@ -121,7 +121,8 @@ IF(SIMGRID_HAVE_LUA) ENDIF() # New tests should use the Catch Framework -set(UNIT_TESTS src/kernel/resource/profile/trace_mgr_test.cpp +set(UNIT_TESTS src/xbt/unit-tests_main.cpp + src/kernel/resource/profile/trace_mgr_test.cpp src/xbt/config_test.cpp src/xbt/dict_test.cpp src/xbt/dynar_test.cpp -- 2.20.1