-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/cgmerge2_tool' into 'devel'
CMerge2 See merge request tuda-sc/projects/metacg!189
- Loading branch information
Showing
52 changed files
with
3,084 additions
and
38 deletions.
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
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
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
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
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
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
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
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,12 @@ | ||
set(PROJECT_NAME CallgraphMergeIntegrationTest) | ||
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-target) | ||
|
||
add_executable(mergetester MergeTester.cpp) | ||
target_include_directories(mergetester PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>) | ||
target_link_libraries(mergetester PUBLIC metacg::metacg) | ||
|
||
add_json(mergetester) | ||
add_spdlog_libraries(mergetester) | ||
add_config_include(mergetester) | ||
|
||
add_test(NAME mergeTests COMMAND mergetester) |
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,73 @@ | ||
#!/usr/bin/env bash | ||
|
||
timeStamp=$(date +%s) | ||
: ${CI_CONCURRENT_ID:=$timeStamp} | ||
|
||
mkdir -p log | ||
|
||
build_dir=build | ||
generate_gt=0 | ||
|
||
function merge { | ||
fail=0 | ||
tc=$1 | ||
|
||
ipcgTaFile="${tc}_a.ipcg" | ||
ipcgTbFile="${tc}_b.ipcg" | ||
gtCombFile="${tc}_both.gtmcg" | ||
|
||
combFile=${tc}_both-${CI_CONCURRENT_ID}.ipcg | ||
|
||
${PWD}/../../../../${build_dir}/graph/test/integration/CallgraphMerge/mergetester ./input/${ipcgTaFile} ./input/${ipcgTbFile} ./input/${gtCombFile} ./input/${combFile} >>log/testrun.log 2>&1 | ||
mErr=$? | ||
|
||
if [ ${generate_gt} -eq 1 ]; then | ||
mv combFile gtCombFile | ||
fi | ||
|
||
if [ ${mErr} -ne 0 ]; then | ||
fail=$((fail + 1)) | ||
echo "Failure for file: $combFile. Keeping generated file for inspection" | ||
fi | ||
|
||
return $fail | ||
} | ||
|
||
while getopts ":b:h" opt; do | ||
case $opt in | ||
b) | ||
if [ -z $OPTARG ]; then | ||
echo "no build directory given, assuming \"build\"" | ||
fi | ||
build_dir=$OPTARG | ||
;; | ||
h) | ||
echo "use -b to provide a build directory NAME" | ||
echo "use -h to print this help" | ||
exit 0 | ||
;; | ||
g) | ||
echo "Regenerating ground truth files" | ||
generate_gt=1 | ||
;; | ||
\?) | ||
echo "Invalid option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
echo "Running integration test for CallgraphMerge" | ||
|
||
tests=(0042 0043 0044 0050 0053 0060) | ||
fails=0 | ||
|
||
for tc in "${tests[@]}"; do | ||
echo "Running test ${tc}" | ||
# Input files | ||
merge ${tc} | ||
fail=$? | ||
fails=$((fails + fail)) | ||
done | ||
echo "Test failures: $fails" | ||
exit $fails |
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,76 @@ | ||
|
||
#include "MCGManager.h" | ||
#include "io/VersionTwoMCGReader.h" | ||
#include "io/VersionTwoMCGWriter.h" | ||
|
||
#include "metadata/BuiltinMD.h" | ||
|
||
#include <filesystem> | ||
#include <iostream> | ||
|
||
bool check(nlohmann::json testGraph, nlohmann::json groundTruth) { | ||
for (auto& elem : groundTruth.at("_CG")) { | ||
for (auto& member : elem) { | ||
if (member.is_array()) { | ||
std::sort(member.begin(), member.end()); | ||
} | ||
} | ||
} | ||
|
||
for (auto& elem : testGraph.at("_CG")) { | ||
for (auto& member : elem) { | ||
if (member.is_array()) { | ||
std::sort(member.begin(), member.end()); | ||
} | ||
} | ||
} | ||
|
||
return groundTruth.at("_CG") == testGraph.at("_CG"); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
if (argc != 5) { | ||
std::cerr << "Usage: " << argv[0] << " cg_a.ipcg cg_b.ipcg groundtruth.gtmcg result.ipcg" << std::endl; | ||
return -1; | ||
} | ||
|
||
std::cout << "Running test for " << argv[1] << " merged with " << argv[2] << " == " << argv[3] << std::endl; | ||
|
||
const std::string inputA(argv[1]); | ||
const std::string inputB(argv[2]); | ||
const std::string inputGroundTruth(argv[3]); | ||
const std::string outputFile(argv[4]); | ||
|
||
auto& mcgManager = metacg::graph::MCGManager::get(); | ||
|
||
metacg::io::FileSource fsA(inputA); | ||
metacg::io::FileSource fsB(inputB); | ||
|
||
metacg::io::VersionTwoMetaCGReader mcgReaderA(fsA); | ||
metacg::io::VersionTwoMetaCGReader mcgReaderB(fsB); | ||
|
||
mcgManager.addToManagedGraphs("cg_a", mcgReaderA.read()); | ||
mcgManager.addToManagedGraphs("cg_b", mcgReaderB.read()); | ||
|
||
metacg::io::VersionTwoMCGWriter mcgWriter; | ||
mcgManager.mergeIntoActiveGraph(); | ||
|
||
metacg::io::JsonSink jsonSink; | ||
mcgWriter.writeActiveGraph(jsonSink); | ||
|
||
nlohmann::json groundtruthJson; | ||
std::ifstream groundtruthFile(inputGroundTruth); | ||
groundtruthFile >> groundtruthJson; | ||
|
||
// If both are equal, we are done | ||
if (check(groundtruthJson, jsonSink.getJson())) { | ||
return 0; | ||
} | ||
// Keep file for inspection | ||
std::ofstream file; | ||
file.open(outputFile); | ||
file << jsonSink.getJson().dump(4); | ||
file.close(); | ||
std::cout << "Test failure: Keeping wrong results for inspection" << std::endl; | ||
return 1; | ||
} |
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,3 @@ | ||
int foo() { return 42; } | ||
|
||
int baz() { return foo(); } |
Oops, something went wrong.