From 3132172ab2824a0ac0a9ea365c7c15b994adbd4f Mon Sep 17 00:00:00 2001 From: cpt-harlock Date: Thu, 23 Jan 2025 11:14:24 +0100 Subject: [PATCH] added unit-test directory --- unit-test/CMakeLists.txt | 9 +++++++++ unit-test/hello.c | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 unit-test/CMakeLists.txt create mode 100644 unit-test/hello.c diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt new file mode 100644 index 0000000..2b92c1c --- /dev/null +++ b/unit-test/CMakeLists.txt @@ -0,0 +1,9 @@ +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=leak") +add_executable(hello hello.c) +target_link_libraries(hello ${MPI_LIBRARIES}) +target_include_directories(hello PRIVATE ${MPI_INCLUDE_PATH}) +# find executable path +# add test to run the executable with mpirun +#add_test(NAME Unit-test COMMAND "srun" "${CMAKE_BINARY_DIR}/unit-test/hello") +add_test(NAME Unit-test COMMAND "mpirun" "${CMAKE_BINARY_DIR}/unit-test/hello") +set_property(TEST Unit-test PROPERTY ENVIRONMENT LD_PRELOAD=/leonardo/home/userinternal/amonteru/countdown/build/src/libcntd.so) diff --git a/unit-test/hello.c b/unit-test/hello.c new file mode 100644 index 0000000..a46e0c2 --- /dev/null +++ b/unit-test/hello.c @@ -0,0 +1,19 @@ +// Mpi hello world program +//#include "mpe_log.h" +#include +#include + +int main() { + int rank, size; + int event1, event2; + + MPI_Init(NULL, NULL); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + printf("Hello world from rank %d of %d\n", rank, size); + + MPI_Finalize(); + return 0; +}