diff --git a/interception/faros.py b/interception/faros.py index e76ce85..9ca87e8 100755 --- a/interception/faros.py +++ b/interception/faros.py @@ -3,9 +3,12 @@ import subprocess import sys import os +import pathlib from colors import * -sys.path.append('../../..') +FILE_PATH = str(pathlib.Path(__file__).parent.absolute()) +#sys.path.append('../../..') +sys.path.append(FILE_PATH+'/../') from libs.faros import faroslib as faros INTERCEPT_LIB = os.path.dirname(os.path.abspath(__file__))+"/intercept.so" diff --git a/interception/tests/test_cmake/test_cmake.py b/interception/tests/test_cmake/test_cmake.py index 0f8d805..6616c43 100755 --- a/interception/tests/test_cmake/test_cmake.py +++ b/interception/tests/test_cmake/test_cmake.py @@ -34,7 +34,7 @@ def test_1(): if file.endswith(".yaml"): count +=1 - assert count==3 + assert count==5 if __name__ == '__main__': test_1() diff --git a/interception/tests/test_compile_single_file/Makefile b/interception/tests/test_compile_single_file/Makefile index b2818e0..4b6c577 100644 --- a/interception/tests/test_compile_single_file/Makefile +++ b/interception/tests/test_compile_single_file/Makefile @@ -6,4 +6,4 @@ all: $(CC) -o main $(OP) main.c clean: - rm -rf *.o main *.yaml + rm -rf *.o main *.yaml report diff --git a/interception/tests/test_mpi_openmp/Makefile b/interception/tests/test_mpi_openmp/Makefile index a9f2267..619c1d3 100644 --- a/interception/tests/test_mpi_openmp/Makefile +++ b/interception/tests/test_mpi_openmp/Makefile @@ -8,4 +8,4 @@ all: $(CC) $(LINK) -o main main.o clean: - rm -rf *.o main *.yaml + rm -rf *.o main *.yaml report diff --git a/interception/tests/test_report_generated/Makefile b/interception/tests/test_report_generated/Makefile new file mode 100644 index 0000000..b68ebe7 --- /dev/null +++ b/interception/tests/test_report_generated/Makefile @@ -0,0 +1,11 @@ + +CC = clang +OP = -g -O3 -fopenmp +LINK = -fopenmp + +all: + $(CC) -c $(OP) main.c + $(CC) $(LINK) -o main main.o + +clean: + rm -rf *.o main *.yaml ./report diff --git a/interception/tests/test_report_generated/main.c b/interception/tests/test_report_generated/main.c new file mode 100644 index 0000000..2742480 --- /dev/null +++ b/interception/tests/test_report_generated/main.c @@ -0,0 +1,23 @@ + +#include + +#if defined(_OPENMP) +#include +#endif + +int main() { + +#if defined(_OPENMP) + omp_set_num_threads(4); +#endif + +#pragma omp parallel + { +#if defined(_OPENMP) + printf("Thread ID: %d\n", omp_get_thread_num()); +#endif + } + + printf("Done!\n"); + return 0; +} diff --git a/interception/tests/test_report_generated/test_report_generated.py b/interception/tests/test_report_generated/test_report_generated.py new file mode 100755 index 0000000..fee20f5 --- /dev/null +++ b/interception/tests/test_report_generated/test_report_generated.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import subprocess +import os +import sys + +def setup_module(module): + THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + os.chdir(THIS_DIR) + +def teardown_module(module): + cmd = ["make clean"] + cmdOutput = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + +def run_command(cmd): + try: + cmdOutput = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + except subprocess.CalledProcessError as e: + print(e.output) + exit() + +def test_1(): + # --- compile code --- + cmd = ["../../faros make"] + run_command(cmd) + + # --- run code --- + cmd = ["./main"] + run_command(cmd) + + assert os.path.isfile('./main.opt.yaml') + assert os.path.isfile('./report/html-output/index.html') diff --git a/interception/tests/test_simple_openmp/Makefile b/interception/tests/test_simple_openmp/Makefile index b0ebfbe..b68ebe7 100644 --- a/interception/tests/test_simple_openmp/Makefile +++ b/interception/tests/test_simple_openmp/Makefile @@ -8,4 +8,4 @@ all: $(CC) $(LINK) -o main main.o clean: - rm -rf *.o main *.yaml + rm -rf *.o main *.yaml ./report