-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8c5734
commit 871b27b
Showing
5 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
17 changes: 17 additions & 0 deletions
17
test/end_to_end/do_all/calls/preventing/simple_3/src/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
all: clean prog | ||
|
||
prog: code.o | ||
$(CXX) -o prog code.o $(CXXFLAGS) | ||
|
||
code.o: | ||
$(CXX) -c -S -emit-llvm -o code.ll code.cpp $(CXXFLAGS) | ||
rm -rf .discopop | ||
$(CXX) -c -o code.o code.cpp $(CXXFLAGS) | ||
|
||
clean: | ||
rm -rf .discopop | ||
rm -rf src/.discopop | ||
find . -not -name code.cpp -not -name Makefile -not -path **/FileMapping.txt -delete | ||
|
||
veryclean: clean | ||
rm -f FileMapping.txt |
32 changes: 32 additions & 0 deletions
32
test/end_to_end/do_all/calls/preventing/simple_3/src/code.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdlib.h> | ||
|
||
void not_prevent_doall(double* tmp, int i){ | ||
int z = i + tmp[i]; | ||
} | ||
|
||
void prevent_doall(double* tmp, int i){ | ||
for(int j = 0; j < 10; j++){ // wo w | ||
tmp[j] = i; | ||
} | ||
} | ||
|
||
int main(int argc, const char* argv[]) { | ||
static int n = 10; | ||
double *x = (double *) malloc(n * sizeof(double)); | ||
// Initialize x, y | ||
for(int i = 0; i < n; ++i){ | ||
x[i] = i; | ||
} | ||
|
||
// not parallelizable | ||
for(int i = 0; i < n; ++i){ | ||
prevent_doall(x, i); | ||
} | ||
|
||
// parallelizable | ||
for(int i = 0; i < n; ++i){ | ||
not_prevent_doall(x, i); | ||
} | ||
free(x); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import copy | ||
import os | ||
import pathlib | ||
import unittest | ||
|
||
import jsonpickle | ||
|
||
from discopop_library.result_classes.DetectionResult import DetectionResult | ||
from test.utils.existence.existence_utils import check_patterns_for_FN, check_patterns_for_FP | ||
from test.utils.subprocess_wrapper.command_execution_wrapper import run_cmd | ||
from test.utils.validator_classes.DoAllInfoForValidation import DoAllInfoForValidation | ||
|
||
from discopop_library.ConfigProvider.config_provider import run as run_config_provider | ||
from discopop_library.ConfigProvider.ConfigProviderArguments import ConfigProviderArguments | ||
|
||
|
||
class TestMethods(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(self): | ||
current_dir = pathlib.Path(__file__).parent.resolve() | ||
dp_build_dir = run_config_provider( | ||
ConfigProviderArguments( | ||
return_dp_build_dir=True, | ||
return_dp_source_dir=False, | ||
return_llvm_bin_dir=False, | ||
return_full_config=False, | ||
return_version_string=False, | ||
) | ||
) | ||
|
||
env_vars = dict(os.environ) | ||
|
||
src_dir = os.path.join(current_dir, "src") | ||
os.chdir(src_dir) | ||
|
||
# create FileMapping | ||
cmd = os.path.join(dp_build_dir, "scripts", "dp-fmap") | ||
run_cmd(cmd, src_dir, env_vars) | ||
|
||
# build | ||
env_vars["CC"] = os.path.join(dp_build_dir, "scripts", "CC_wrapper.sh") | ||
env_vars["CXX"] = os.path.join(dp_build_dir, "scripts", "CXX_wrapper.sh") | ||
env_vars["DP_PROJECT_ROOT_DIR"] = src_dir | ||
cmd = "make" | ||
run_cmd(cmd, src_dir, env_vars) | ||
|
||
# execute instrumented program | ||
run_cmd("./prog", src_dir, env_vars) | ||
# execute DiscoPoP analysis | ||
|
||
cwd = os.path.join(src_dir, ".discopop") | ||
cmd = "discopop_explorer --enable-patterns doall,reduction" | ||
run_cmd(cmd, cwd, env_vars) | ||
|
||
self.src_dir = src_dir | ||
self.env_vars = env_vars | ||
|
||
test_output_file = os.path.join(self.src_dir, ".discopop", "explorer", "detection_result_dump.json") | ||
# load detection results | ||
with open(test_output_file, "r") as f: | ||
tmp_str = f.read() | ||
self.test_output: DetectionResult = jsonpickle.decode(tmp_str) | ||
|
||
@classmethod | ||
def tearDownClass(self): | ||
run_cmd("make veryclean", self.src_dir, self.env_vars) | ||
|
||
def test(self): | ||
for pattern_type in self.test_output.patterns.__dict__: | ||
amount_of_identified_patterns = len(self.test_output.patterns.__dict__[pattern_type]) | ||
if pattern_type == "do_all": | ||
expected_lines = ["1:17", "1:8", "1:27"] | ||
with self.subTest("check for FP"): | ||
res, msg = check_patterns_for_FP( | ||
self, | ||
pattern_type, | ||
copy.deepcopy(expected_lines), | ||
self.test_output.patterns.__dict__[pattern_type], | ||
) | ||
self.assertTrue(res, msg) | ||
with self.subTest("check for FN"): | ||
res, msg = check_patterns_for_FN( | ||
self, | ||
pattern_type, | ||
copy.deepcopy(expected_lines), | ||
self.test_output.patterns.__dict__[pattern_type], | ||
) | ||
self.assertTrue(res, msg) | ||
else: | ||
self.assertEqual(amount_of_identified_patterns, 0) |