Skip to content

Commit

Permalink
added unit-test directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cpt-harlock committed Jan 23, 2025
1 parent d2886df commit 3132172
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions unit-test/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Mpi hello world program
//#include "mpe_log.h"
#include <stdio.h>
#include <mpi.h>

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;
}

0 comments on commit 3132172

Please sign in to comment.