From d81014757cb8b4ab3e619c4fca5206e9875a510a Mon Sep 17 00:00:00 2001 From: "thomas.dilasser" <thomas.dilasser@ensiie.fr> Date: Sat, 20 Oct 2018 20:49:20 +0200 Subject: [PATCH] added directory containing test files In order to add a new test, .c file has to be added to tests/ and a new target should be added in the Makefile --- Makefile | 19 ++++++++--- main.c => tests/main_pragma_test.c | 0 prog_test.c => tests/pragma_test.c | 2 +- prog_test.h => tests/pragma_test.h | 0 tests/simple_test1.c | 41 +++++++++++++++++++++++ tests/simple_test2.c | 45 +++++++++++++++++++++++++ tests/split_bloc.c | 54 ++++++++++++++++++++++++++++++ 7 files changed, 156 insertions(+), 5 deletions(-) rename main.c => tests/main_pragma_test.c (100%) rename prog_test.c => tests/pragma_test.c (95%) rename prog_test.h => tests/pragma_test.h (100%) create mode 100644 tests/simple_test1.c create mode 100644 tests/simple_test2.c create mode 100755 tests/split_bloc.c diff --git a/Makefile b/Makefile index d3924d0..498429c 100755 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ -all: plugin +all: TEST1 TEST2 TEST3 TEST4 + +TEST1=./tests/simple_test1.c +TEST2=./tests/simple_test2.c +TEST3=./tests/split_bloc.c +TEST4=./tests/pragma_test.c -FILE=main.c prog_test.c PLUGIN=plugin.cpp CXX=g++_810 CC=gcc_810 @@ -15,8 +19,14 @@ CFLAGS=-g -O3 libplugin.so: $(PLUGIN) $(CXX) $(PLUGIN_FLAGS) -o $@ $< -plugin: libplugin.so prog_test.c - $(MPICC) prog_test.c $(CFLAGS) -o $@ -fplugin=./$< +TEST1: libplugin.so $(TEST1) + $(MPICC) $(TEST1) $(CFLAGS) -o $@ -fplugin=./$< +TEST2: libplugin.so $(TEST2) + $(MPICC) $(TEST2) $(CFLAGS) -o $@ -fplugin=./$< +TEST3: libplugin.so $(TEST3) + $(MPICC) $(TEST3) $(CFLAGS) -o $@ -fplugin=./$< +TEST4: libplugin.so $(TEST4) + $(MPICC) $(TEST4) $(CFLAGS) -o $@ -fplugin=./$< %.pdf: %.dot dot -Tpdf $< -o $@ @@ -24,6 +34,7 @@ plugin: libplugin.so prog_test.c clean: rm -rf *.pgr *.pdf plugin rm -rf libplugin.so *.dot plugin + rm -rf TEST* clean_all: clean rm -rf libplugin.so *.dot plugin diff --git a/main.c b/tests/main_pragma_test.c similarity index 100% rename from main.c rename to tests/main_pragma_test.c diff --git a/prog_test.c b/tests/pragma_test.c similarity index 95% rename from prog_test.c rename to tests/pragma_test.c index 8e5bbfa..dbbfd9d 100755 --- a/prog_test.c +++ b/tests/pragma_test.c @@ -3,7 +3,7 @@ * \brief TEST PLUGIN */ #include <stdio.h> -#include "prog_test.h" +#include "pragma_test.h" #pragma instrumente function mock1 #pragma instrumente function mock2 diff --git a/prog_test.h b/tests/pragma_test.h similarity index 100% rename from prog_test.h rename to tests/pragma_test.h diff --git a/tests/simple_test1.c b/tests/simple_test1.c new file mode 100644 index 0000000..07ffcc8 --- /dev/null +++ b/tests/simple_test1.c @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <mpi.h> + +void mpi_call(int c) +{ + MPI_Barrier(MPI_COMM_WORLD); + + if(c<10) + { + printf("je suis dans le if (c=%d)\n", c); + } + else + { + printf("je suis dans le else (c=%d)\n", c); + } +} + + +int main(int argc, char * argv[]) +{ + MPI_Init(&argc, &argv); + + int i; + int a = 2; + int b = 3; + int c=0; + + for(i=0; i<10; i++) + { + + mpi_call(c); + c+= (a+b); + } + + printf("c=%d\n", c); + + MPI_Finalize(); + return 1; +} diff --git a/tests/simple_test2.c b/tests/simple_test2.c new file mode 100644 index 0000000..ee2edf0 --- /dev/null +++ b/tests/simple_test2.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <mpi.h> + +void mpi_call(int c) +{ + MPI_Barrier(MPI_COMM_WORLD); + + if(c<10) + { + printf("je suis dans le if (c=%d)\n", c); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); + + } + else + { + printf("je suis dans le else (c=%d)\n", c); + MPI_Barrier(MPI_COMM_WORLD); + } +} + + +int main(int argc, char * argv[]) +{ + MPI_Init(&argc, &argv); + + int i; + int a = 2; + int b = 3; + int c=0; + + for(i=0; i<10; i++) + { + + mpi_call(c); + c+= (a+b); + } + + printf("c=%d\n", c); + + MPI_Finalize(); + return 1; +} diff --git a/tests/split_bloc.c b/tests/split_bloc.c new file mode 100755 index 0000000..cf8758f --- /dev/null +++ b/tests/split_bloc.c @@ -0,0 +1,54 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <mpi.h> + + +int main(int argc, char * argv[]) +{ + MPI_Init(&argc, &argv); + + int i; + int a = 2; + int b = 3; + int c=0; + + for(i=0; i<10; i++) + { + + MPI_Barrier(MPI_COMM_WORLD); + + if(c<10) + { + printf("je suis dans le if (c=%d)\n", c); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); + if(c <5) + { + a = a*a +1; + } + else + { + c = c*3; + if(c <20) + { + return c; + } + } + + } + else + { + printf("je suis dans le else (c=%d)\n", c); + MPI_Barrier(MPI_COMM_WORLD); + return 1; + } + c+= (a+b); + printf("fin du for\n"); + } + + printf("c=%d\n", c); + + MPI_Finalize(); + return 1; +} -- GitLab