From 2d8a2890b671657e4e492e54685deaf9246cdc81 Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:22:31 +0200 Subject: [PATCH 1/5] CI: Test with address sanitizer --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c1d7183b..8dd968990 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: export CC=/usr/bin/clang export CXX=/usr/bin/clang++ fi - ./setup.sh + KASSIOPEIA_CUSTOM_CMAKE_ARGS="-DENABLE_SANITIZE_ADDRESSES=ON" ./setup.sh shell: bash - name: Launch environment and run tests @@ -72,7 +72,8 @@ jobs: root-core root-io-xmlparser root-minuit2 root-spectrum root-genvector \ vtk vtk-qt \ boost-devel fftw-devel gsl-devel hdf5-devel libomp-devel liburing-devel libxml2-devel log4cxx-devel \ - ocl-icd-devel openmpi-devel openssl-devel sqlite-devel vtk-devel zlib-devel + ocl-icd-devel openmpi-devel openssl-devel sqlite-devel vtk-devel zlib-devel \ + libasan - name: Build code run: | if ${{ matrix.use_clang }}; then @@ -81,7 +82,7 @@ jobs: export CC=/usr/bin/clang export CXX=/usr/bin/clang++ fi - ./setup.sh + KASSIOPEIA_CUSTOM_CMAKE_ARGS="-DENABLE_SANITIZE_ADDRESSES=ON" ./setup.sh shell: bash - name: Launch environment and run tests From 850a8886e947f8eb71d8c8a112dd81b66273eb45 Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:35:12 +0200 Subject: [PATCH 2/5] UnitTestKGeoBag: Fix segfault --- UnitTest/KGeoBag/Source/Shapes.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UnitTest/KGeoBag/Source/Shapes.cxx b/UnitTest/KGeoBag/Source/Shapes.cxx index 3c32abd90..7555e6d0c 100644 --- a/UnitTest/KGeoBag/Source/Shapes.cxx +++ b/UnitTest/KGeoBag/Source/Shapes.cxx @@ -196,8 +196,8 @@ TEST_F(KGeoBagShapeTest, KGBox) tSurface3->SetP0(KThreeVector(0.1, 0.2, 0.3)); tSurface3->SetP1(KThreeVector(1., 2., 3.)); - EXPECT_EQ(tSurface2->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface2->GetP1(), KThreeVector(1., 2., 3.)); + EXPECT_EQ(tSurface3->GetP0(), KThreeVector(0.1, 0.2, 0.3)); + EXPECT_EQ(tSurface3->GetP1(), KThreeVector(1., 2., 3.)); tSurface3->SetX0(1.1); tSurface3->SetX1(2.1); @@ -212,8 +212,8 @@ TEST_F(KGeoBagShapeTest, KGBox) tSurface3->SetP0(KThreeVector(0.1, 0.2, 0.3)); tSurface3->SetP1(KThreeVector(1., 2., 3.)); - EXPECT_EQ(tSurface2->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface2->GetP1(), KThreeVector(1., 2., 3.)); + EXPECT_EQ(tSurface3->GetP0(), KThreeVector(0.1, 0.2, 0.3)); + EXPECT_EQ(tSurface3->GetP1(), KThreeVector(1., 2., 3.)); delete tSurface3; } From 7a5bf49bd7c33fc52971d5465bf2b4885af2b2d9 Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:09:16 +0200 Subject: [PATCH 3/5] UnitTest: Remove unused file, fix previous commit --- UnitTest/KGeoBag/Source/Shapes.cxx | 226 --------------------- UnitTest/KGeoBag/Source/Shapes_Volumes.cxx | 8 +- 2 files changed, 4 insertions(+), 230 deletions(-) delete mode 100644 UnitTest/KGeoBag/Source/Shapes.cxx diff --git a/UnitTest/KGeoBag/Source/Shapes.cxx b/UnitTest/KGeoBag/Source/Shapes.cxx deleted file mode 100644 index 7555e6d0c..000000000 --- a/UnitTest/KGeoBag/Source/Shapes.cxx +++ /dev/null @@ -1,226 +0,0 @@ -/** - * Unit testing for KGeoBag shape classes - * @author J. Behrens, N. Trost - * - * This file contains a unit tests for most of KGeoBag's shape classes. - * All tests should be grouped together in a meaningful way, and should use - * a fixture class which is derived from TimeoutTest. Please keep unit tests - * as simple as possible (think of a minimal example of how to use a certain - * class). It is a good idea to also include a death-test for each class. - * - * See the official GoogleTest pages for more info: - * https://code.google.com/p/googletest/wiki/Primer - * https://code.google.com/p/googletest/wiki/AdvancedGuide - */ - -#include "Shapes.h" - -#include "KGAnnulusSurface.hh" - -using namespace KGeoBag; - - -///////////////////////////////////////////////////////////////////////////// -// Shapes Unit Testing -///////////////////////////////////////////////////////////////////////////// - -TEST_F(KGeoBagShapeTest, KGAnnulusSurface) -{ - KGAnnulusSurface* tSurface = new KGAnnulusSurface(); - - tSurface->Z(2.); - tSurface->R1(0.5); - tSurface->R2(1.); - - tSurface->AreaInitialize(); - - EXPECT_EQ(tSurface->Z(), 2.); - EXPECT_EQ(tSurface->R1(), 0.5); - EXPECT_EQ(tSurface->R2(), 1.); - - delete tSurface; -} - -TEST_F(KGeoBagShapeTest, KGAnnulusSurface_AreaAbove) -{ - KGAnnulusSurface* tSurface = new KGAnnulusSurface(); - - tSurface->Z(2.); - tSurface->R1(0.5); - tSurface->R2(1.); - - tSurface->AreaInitialize(); - - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0.5, 0.5, 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-0.5, -0.5, 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-0.5, 0.5, 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0.5, -0.5, 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0.7, 0., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., 0.7, 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-0.7, 0., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., -0.7, 3.))); - - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(1., 1., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-1., -1., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-1., 1., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(1., -1., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(1.4, 0., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., 1.4, 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-1.4, 0., 3.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., -1.4, 3.))); - - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.5, 0.5, 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.5, -0.5, 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.5, 0.5, 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.5, -0.5, 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.7, 0., 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0., 0.7, 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.7, 0., 1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0., -0.7, 1.))); - - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.5, 0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.5, -0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.5, 0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.5, -0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.7, 0., -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0., 0.7, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.7, 0., -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0., -0.7, -1.))); - - delete tSurface; - - tSurface = new KGAnnulusSurface(); - - tSurface->Z(0.); - tSurface->R1(0.5); - tSurface->R2(1.); - - tSurface->AreaInitialize(); - - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0.5, 0.5, 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-0.5, -0.5, 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-0.5, 0.5, 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0.5, -0.5, 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0.7, 0., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., 0.7, 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-0.7, 0., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., -0.7, 1.))); - - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(1., 1., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-1., -1., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-1., 1., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(1., -1., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(1.4, 0., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., 1.4, 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(-1.4, 0., 1.))); - EXPECT_TRUE(tSurface->AreaAbove(KThreeVector(0., -1.4, 1.))); - - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.5, 0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.5, -0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.5, 0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.5, -0.5, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0.7, 0., -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0., 0.7, -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(-0.7, 0., -1.))); - EXPECT_FALSE(tSurface->AreaAbove(KThreeVector(0., -0.7, -1.))); - - delete tSurface; -} - -TEST_F(KGeoBagShapeTest, KGAnnulusSurface_AreaNormal) -{ - KGAnnulusSurface* tSurface = new KGAnnulusSurface(); - - tSurface->Z(2.); - tSurface->R1(0.5); - tSurface->R2(1.); - - tSurface->AreaInitialize(); - - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.5, 0.5, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(-0.5, -0.5, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.5, 0.5, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.5, -0.5, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.7, 0.0, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.0, 0.7, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(-0.7, 0.0, 3.)), KThreeVector(0., 0., 1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.0, -0.7, 3.)), KThreeVector(0., 0., 1.)); - - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.5, 0.5, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(-0.5, -0.5, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.5, 0.5, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.5, -0.5, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.7, 0.0, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.0, 0.7, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(-0.7, 0.0, 1.)), KThreeVector(0., 0., -1.)); - EXPECT_EQ(tSurface->AreaNormal(KThreeVector(0.0, -0.7, 1.)), KThreeVector(0., 0., -1.)); - - delete tSurface; -} - -TEST_F(KGeoBagShapeTest, KGAnnulusSurface_AbovePoint) -{ - KGAnnulusSurface* tSurface = new KGAnnulusSurface(); - - tSurface->Z(2.); - tSurface->R1(0.5); - tSurface->R2(1.); - - tSurface->AreaInitialize(); - - EXPECT_VECTOR_NEAR(tSurface->AreaPoint(KThreeVector(0.5, 0.5, 3.)), KThreeVector(0.5, 0.5, 2.)); - EXPECT_VECTOR_NEAR(tSurface->AreaPoint(KThreeVector(0.5, 0.5, 1.)), KThreeVector(0.5, 0.5, 2.)); - - delete tSurface; -} - -////////////////////////////////////////////////////////////////////////////// - -TEST_F(KGeoBagShapeTest, KGBox) -{ - KGBox* tSurface1 = new KGBox(0.1, 1., 0.2, 2., 0.3, 3.); - - EXPECT_EQ(tSurface1->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface1->GetP1(), KThreeVector(1., 2., 3.)); - - delete tSurface1; - - KGBox* tSurface2 = new KGBox(KThreeVector(0.1, 0.2, 0.3), KThreeVector(1., 2., 3.)); - - EXPECT_EQ(tSurface2->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface2->GetP1(), KThreeVector(1., 2., 3.)); - - delete tSurface2; - - KGBox tSurface3 = new KGBox(); - tSurface3->SetP0(KThreeVector(0.1, 0.2, 0.3)); - tSurface3->SetP1(KThreeVector(1., 2., 3.)); - - EXPECT_EQ(tSurface3->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface3->GetP1(), KThreeVector(1., 2., 3.)); - - tSurface3->SetX0(1.1); - tSurface3->SetX1(2.1); - tSurface3->SetY0(2.2); - tSurface3->SetY1(3.1); - tSurface3->SetZ0(3.3); - tSurface3->SetZ1(4.1); - - EXPECT_EQ(tSurface3->GetP0(), KThreeVector(1.1, 2.2, 3.3)); - EXPECT_EQ(tSurface3->GetP1(), KThreeVector(2.1, 3.1, 4.1)); - - tSurface3->SetP0(KThreeVector(0.1, 0.2, 0.3)); - tSurface3->SetP1(KThreeVector(1., 2., 3.)); - - EXPECT_EQ(tSurface3->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface3->GetP1(), KThreeVector(1., 2., 3.)); - - delete tSurface3; -} - - -////////////////////////////////////////////////////////////////////////////// -// DEATH TESTS /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST(KGeoBagShapeDeathTest, KGAnnulusSurface) {} diff --git a/UnitTest/KGeoBag/Source/Shapes_Volumes.cxx b/UnitTest/KGeoBag/Source/Shapes_Volumes.cxx index 3f1fb8751..d5c74c6cb 100644 --- a/UnitTest/KGeoBag/Source/Shapes_Volumes.cxx +++ b/UnitTest/KGeoBag/Source/Shapes_Volumes.cxx @@ -44,8 +44,8 @@ TEST_F(KGeoBagShapeTest, KGBox) tSurface3->SetP0(KThreeVector(0.1, 0.2, 0.3)); tSurface3->SetP1(KThreeVector(1., 2., 3.)); - EXPECT_EQ(tSurface2->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface2->GetP1(), KThreeVector(1., 2., 3.)); + EXPECT_EQ(tSurface3->GetP0(), KThreeVector(0.1, 0.2, 0.3)); + EXPECT_EQ(tSurface3->GetP1(), KThreeVector(1., 2., 3.)); tSurface3->SetX0(1.1); tSurface3->SetX1(2.1); @@ -60,8 +60,8 @@ TEST_F(KGeoBagShapeTest, KGBox) tSurface3->SetP0(KThreeVector(0.1, 0.2, 0.3)); tSurface3->SetP1(KThreeVector(1., 2., 3.)); - EXPECT_EQ(tSurface2->GetP0(), KThreeVector(0.1, 0.2, 0.3)); - EXPECT_EQ(tSurface2->GetP1(), KThreeVector(1., 2., 3.)); + EXPECT_EQ(tSurface3->GetP0(), KThreeVector(0.1, 0.2, 0.3)); + EXPECT_EQ(tSurface3->GetP1(), KThreeVector(1., 2., 3.)); delete tSurface3; } From d901a1347f6efe90d04450eab3c6d7d972d35c0c Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:46:12 +0200 Subject: [PATCH 4/5] CI: Disable leak detection We have too many memory leaks at the moment for this to be helpful. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8dd968990..3be12c201 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,7 @@ jobs: - name: Launch environment and run tests run: | - source root/bin/thisroot.sh && source install/bin/kasperenv.sh && UnitTestKasper + source root/bin/thisroot.sh && source install/bin/kasperenv.sh && ASAN_OPTIONS=detect_leaks=0 UnitTestKasper shell: bash fedora_37: @@ -87,5 +87,5 @@ jobs: - name: Launch environment and run tests run: | - source install/bin/kasperenv.sh && UnitTestKasper + source install/bin/kasperenv.sh && ASAN_OPTIONS=detect_leaks=0 UnitTestKasper shell: bash From b826b29460b0056b12cb3833c79d52deb14c8ddd Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:17:38 +0200 Subject: [PATCH 5/5] Documentation: Minor spelling fix --- .../gh-pages/source/configuring_simulation_statements.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/gh-pages/source/configuring_simulation_statements.rst b/Documentation/gh-pages/source/configuring_simulation_statements.rst index 0cd8fbbb1..93eba5ec5 100644 --- a/Documentation/gh-pages/source/configuring_simulation_statements.rst +++ b/Documentation/gh-pages/source/configuring_simulation_statements.rst @@ -149,7 +149,7 @@ Both examples together will yield the output:: [INITIALIZATION NORMAL MESSAGE] This is a test message. Instead of showing normal messages, it is also possible to show a warning or an error message. An error message will -terminate the prgogram, so it is most useful in combination with the conditional expressions described below: +terminate the program, so it is most useful in combination with the conditional expressions described below: .. code-block:: xml