Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Provide our own main() for unit-tests.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 5 Feb 2019 13:01:13 +0000 (14:01 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 5 Feb 2019 13:08:27 +0000 (14:08 +0100)
The goal is to be able to use the --log=... command line parameters.

src/kernel/resource/profile/trace_mgr_test.cpp
src/xbt/unit-tests_main.cpp [new file with mode: 0644]
tools/cmake/Tests.cmake

index d09af5e..de942e2 100644 (file)
@@ -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. */
 
 /* 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"
 
 #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 (file)
index 0000000..3900999
--- /dev/null
@@ -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);
+}
index 8ef455f..107579e 100644 (file)
@@ -121,7 +121,8 @@ IF(SIMGRID_HAVE_LUA)
 ENDIF()
 
 # New tests should use the Catch Framework
 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
                 src/xbt/config_test.cpp
                 src/xbt/dict_test.cpp
                 src/xbt/dynar_test.cpp