From 6c3a14afc8c2d1678e14d3d9efd1ef87d54ac450 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 24 Jul 2017 16:37:13 +0200 Subject: [PATCH] . --- CMakeLists.txt | 3 +- bin/unittests.sh | 11 ++++ iwir/coderepo/if01.properties | 9 ++++ iwir/coderepo/if01/atomic1.code | 3 ++ iwir/coderepo/if01/atomic1.properties | 4 ++ iwir/coderepo/if01/atomic2.code | 16 ++++++ iwir/coderepo/if01/atomic2.properties | 4 ++ iwir/coderepo/if01/atomic3.code | 16 ++++++ iwir/coderepo/if01/atomic3.properties | 4 ++ iwir/coderepo/if01/includes.code | 2 + iwir/coderepo/if01/wfInput.code | 47 +++++++++++++++++ iwir/coderepo/if01/wfOutput.code | 63 ++++++++++++++++++++++ iwir/coderepo/if1/wfInput.code | 10 +++- iwir/if01.iwir | 76 +++++++++++++++++++++++++++ 14 files changed, 266 insertions(+), 2 deletions(-) create mode 100755 iwir/coderepo/if01.properties create mode 100755 iwir/coderepo/if01/atomic1.code create mode 100755 iwir/coderepo/if01/atomic1.properties create mode 100755 iwir/coderepo/if01/atomic2.code create mode 100755 iwir/coderepo/if01/atomic2.properties create mode 100755 iwir/coderepo/if01/atomic3.code create mode 100755 iwir/coderepo/if01/atomic3.properties create mode 100755 iwir/coderepo/if01/includes.code create mode 100755 iwir/coderepo/if01/wfInput.code create mode 100755 iwir/coderepo/if01/wfOutput.code create mode 100644 iwir/if01.iwir diff --git a/CMakeLists.txt b/CMakeLists.txt index 720f30f..5e81f29 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ ADD_DEFINITIONS( -std=c++11 -DSPARSELU_SKIP_BOTS_MAIN ) function(add_wfr_utest utest_name add_inc) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${utest_name}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${utest_name}/${utest_name}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${utest_name}/${utest_name}.h - COMMAND ${IWIR2WFR_EXE} -i ${IWIR_DIR}/${utest_name}.iwir -o ${CMAKE_CURRENT_BINARY_DIR}/${utest_name}/${utest_name} -skipmain -printir -repoconfig ${REPO_DIR}/${utest_name}.properties + COMMAND ${IWIR2WFR_EXE} -i ${IWIR_DIR}/${utest_name}.iwir -o ${CMAKE_CURRENT_BINARY_DIR}/${utest_name}/${utest_name} -printir -repoconfig ${REPO_DIR}/${utest_name}.properties DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${utest_name} ) add_executable(${utest_name}.bin ${CMAKE_CURRENT_BINARY_DIR}/${utest_name}/${utest_name}.cpp ${ARGN}) @@ -74,6 +74,7 @@ endfunction() add_wfr_utest(for1 "") add_wfr_utest(foreach1 "") add_wfr_utest(if1 "") +#add_wfr_utest(if01 "") add_wfr_utest(if2 "") add_wfr_utest(pfor1 "") add_wfr_utest(pforeach1 "") diff --git a/bin/unittests.sh b/bin/unittests.sh index 75967e1..cece03e 100755 --- a/bin/unittests.sh +++ b/bin/unittests.sh @@ -29,6 +29,7 @@ exec_test() { echo -n -e "$PROLOG" let TOTAL_COUNT=$TOTAL_COUNT+1 + #echo LD_LIBRARY_PATH=$LIBRARY_PATH timeout $TIMELIMIT ./$BINARY OUTPUT=$(LD_LIBRARY_PATH=$LIBRARY_PATH timeout $TIMELIMIT ./$BINARY 1>/dev/null 2>&1) CODE=$? RESULT="" @@ -78,6 +79,16 @@ exec_test 10 "$BIN_BASE/while1/while1.bin --early-evaluation" exec_test 10 "$BIN_BASE/while1/while1.bin --late-evaluation" exec_test 10 "$BIN_BASE/if1/if1.bin --early-evaluation" exec_test 10 "$BIN_BASE/if1/if1.bin --late-evaluation" +exec_test 10 "$BIN_BASE/if1/if1.bin --early-evaluation --if1 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --late-evaluation --if1 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --early-evaluation --if2 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --late-evaluation --if2 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --early-evaluation --if3 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --late-evaluation --if3 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --early-evaluation --if4 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --late-evaluation --if4 false" +exec_test 10 "$BIN_BASE/if1/if1.bin --early-evaluation --ifall false" +exec_test 10 "$BIN_BASE/if1/if1.bin --late-evaluation --ifall false" exec_test 10 "$BIN_BASE/if2/if2.bin --early-evaluation" exec_test 10 "$BIN_BASE/if2/if2.bin --late-evaluation" #exec_test 30 "$BIN_BASE/wavefront/wavefront.bin --early-evaluation" diff --git a/iwir/coderepo/if01.properties b/iwir/coderepo/if01.properties new file mode 100755 index 0000000..31af5dc --- /dev/null +++ b/iwir/coderepo/if01.properties @@ -0,0 +1,9 @@ + +wfinput=if01/wfInput.code +wfoutput=if01/wfOutput.code +includes=if01/includes.code + +atomicTask.0=if01/atomic1.properties +atomicTask.1=if01/atomic2.properties +atomicTask.2=if01/atomic3.properties + diff --git a/iwir/coderepo/if01/atomic1.code b/iwir/coderepo/if01/atomic1.code new file mode 100755 index 0000000..954b493 --- /dev/null +++ b/iwir/coderepo/if01/atomic1.code @@ -0,0 +1,3 @@ + sout->if1condOut.setValue(sin->if1cond.getValue()); + sout->if1ValueOut.setValue(sin->if1Value.getValue()); + \ No newline at end of file diff --git a/iwir/coderepo/if01/atomic1.properties b/iwir/coderepo/if01/atomic1.properties new file mode 100755 index 0000000..f069424 --- /dev/null +++ b/iwir/coderepo/if01/atomic1.properties @@ -0,0 +1,4 @@ + +name=AtomicActivity1 +entries=1 +entry.0=atomic1.code diff --git a/iwir/coderepo/if01/atomic2.code b/iwir/coderepo/if01/atomic2.code new file mode 100755 index 0000000..f946234 --- /dev/null +++ b/iwir/coderepo/if01/atomic2.code @@ -0,0 +1,16 @@ + std::cout << "AtomicActivity2:" << std::endl + << "\tif1cond: " << sin->if1cond.getValue() << std::endl + << "\tif1value: " << sin->if1Value.getValue() << std::endl; + if (!sin->if1cond.getValue()) { + #include + std::stringstream ss; + ss << "Test Failure: if1cond [" << sin->if1cond.getValue() << "] is not true."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (sin->if1Value.getValue() != -1) { + #include + std::stringstream ss; + ss << "Test Failure: if1Value [" << sin->if1Value.getValue() << "] is not -1."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + sout->if1ValueOut.setValue(2); diff --git a/iwir/coderepo/if01/atomic2.properties b/iwir/coderepo/if01/atomic2.properties new file mode 100755 index 0000000..5cba370 --- /dev/null +++ b/iwir/coderepo/if01/atomic2.properties @@ -0,0 +1,4 @@ + +name=AtomicActivity2 +entries=1 +entry.0=atomic2.code diff --git a/iwir/coderepo/if01/atomic3.code b/iwir/coderepo/if01/atomic3.code new file mode 100755 index 0000000..bcc16c7 --- /dev/null +++ b/iwir/coderepo/if01/atomic3.code @@ -0,0 +1,16 @@ + std::cout << "AtomicActivity3:" << std::endl + << "\tif1cond: " << sin->if1Cond.getValue() << std::endl + << "\tif1value: " << sin->if1Value.getValue() << std::endl; + if (sin->if1Cond.getValue()) { + #include + std::stringstream ss; + ss << "Test Failure: if1cond [" << sin->if1Cond.getValue() << "] is not false."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (sin->if1Value.getValue() != -1) { + #include + std::stringstream ss; + ss << "Test Failure: if1Value [" << sin->if1Value.getValue() << "] is not -1."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + sout->if1ValueOut.setValue(3); diff --git a/iwir/coderepo/if01/atomic3.properties b/iwir/coderepo/if01/atomic3.properties new file mode 100755 index 0000000..9863629 --- /dev/null +++ b/iwir/coderepo/if01/atomic3.properties @@ -0,0 +1,4 @@ + +name=AtomicActivity3 +entries=1 +entry.0=atomic3.code diff --git a/iwir/coderepo/if01/includes.code b/iwir/coderepo/if01/includes.code new file mode 100755 index 0000000..ea1a2da --- /dev/null +++ b/iwir/coderepo/if01/includes.code @@ -0,0 +1,2 @@ +#include +#include \ No newline at end of file diff --git a/iwir/coderepo/if01/wfInput.code b/iwir/coderepo/if01/wfInput.code new file mode 100755 index 0000000..13fc6ec --- /dev/null +++ b/iwir/coderepo/if01/wfInput.code @@ -0,0 +1,47 @@ + + bool isHelp = false; + bool if1Cond = true; + bool if2Cond = true; + bool if3Cond = true; + bool if4Cond = true; + boost::program_options::options_description opts("if1 Options"); + opts.add_options() + ("help", "Print help message.") + ("if1", boost::program_options::value(), "if1 condition") + ("if2", boost::program_options::value(), "if2 condition") + ("if3", boost::program_options::value(), "if3 condition") + ("if4", boost::program_options::value(), "if4 condition"); + boost::program_options::variables_map vm; + auto parsed = boost::program_options::command_line_parser(argc, argv).options(opts).allow_unregistered().run(); + boost::program_options::store(parsed, vm); + boost::program_options::notify(vm); + if (vm.count("help")) { + std::cerr << opts << std::endl; + isHelp = true; + } else { + if (vm.count("if1")) { + if1Cond = vm["if1"].as(); + } + if (vm.count("if2")) { + if2Cond = vm["if2"].as(); + } + if (vm.count("if3")) { + if3Cond = vm["if3"].as(); + } + if (vm.count("if4")) { + if4Cond = vm["if4"].as(); + } + std::cerr << "if1 = " << if1Cond << std::endl; + std::cerr << "if2 = " << if2Cond << std::endl; + std::cerr << "if3 = " << if3Cond << std::endl; + std::cerr << "if4 = " << if4Cond << std::endl; + } + wfInput.if1cond.setValue(if1Cond); + wfInput.if2cond.setValue(if2Cond); + wfInput.if3cond.setValue(if3Cond); + wfInput.if4cond.setValue(if4Cond); + wfInput.if1Value.setValue(-1); + wfInput.if2Value.setValue(-1); + wfInput.if3Value.setValue(-1); + wfInput.if4Value.setValue(-1); + \ No newline at end of file diff --git a/iwir/coderepo/if01/wfOutput.code b/iwir/coderepo/if01/wfOutput.code new file mode 100755 index 0000000..06190f5 --- /dev/null +++ b/iwir/coderepo/if01/wfOutput.code @@ -0,0 +1,63 @@ + std::cout << "wfOutput:" << std::endl + << "\tisOk1: " << wfOutput.isOk1.getValue() << std::endl + << "\tisOk2: " << wfOutput.isOk2.getValue() << std::endl + << "\tif1valueOut: " << wfOutput.if1valueOut.getValue() << std::endl + << "\tif2valueOut: " << wfOutput.if2ValueOut.getValue() << std::endl + << "\tif3valueOut: " << wfOutput.if3ValueOut.getValue() << std::endl + << "\tif4valueOut: " << wfOutput.if4ValueOut.getValue() << std::endl; + if (wfOutput.isOk1.getValue() != true) { + #include + std::stringstream ss; + ss << "Test Failure: isOk1 [" << wfOutput.isOk1.getValue() << "] is not true."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (wfOutput.isOk2.getValue() != true) { + #include + std::stringstream ss; + ss << "Test Failure: isOk2 [" << wfOutput.isOk2.getValue() << "] is not true."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (wfInput.if1cond.getValue() && wfOutput.if1valueOut.getValue() != 2) { + #include + std::stringstream ss; + ss << "Test Failure: if1valueOut [" << wfOutput.if1valueOut.getValue() << "] is not 2."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } else if (!wfInput.if1cond.getValue() && wfOutput.if1valueOut.getValue() != 3) { + #include + std::stringstream ss; + ss << "Test Failure: if1valueOut [" << wfOutput.if1valueOut.getValue() << "] is not 3."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (wfInput.if2cond.getValue() && wfOutput.if2ValueOut.getValue() != 4) { + #include + std::stringstream ss; + ss << "Test Failure: if2valueOut [" << wfOutput.if2ValueOut.getValue() << "] is not 4."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } else if (!wfInput.if2cond.getValue() && wfOutput.if2ValueOut.getValue() != -1) { + #include + std::stringstream ss; + ss << "Test Failure: if2valueOut [" << wfOutput.if2ValueOut.getValue() << "] is not -1."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (wfInput.if3cond.getValue() && wfOutput.if3ValueOut.getValue() != -1) { + #include + std::stringstream ss; + ss << "Test Failure: if3valueOut [" << wfOutput.if3ValueOut.getValue() << "] is not -1."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } else if (!wfInput.if3cond.getValue() && wfOutput.if3ValueOut.getValue() != 6) { + #include + std::stringstream ss; + ss << "Test Failure: if3valueOut [" << wfOutput.if3ValueOut.getValue() << "] is not 6."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } + if (wfInput.if4cond.getValue() && wfOutput.if4ValueOut.getValue() != 7) { + #include + std::stringstream ss; + ss << "Test Failure: if4valueOut [" << wfOutput.if4ValueOut.getValue() << "] is not 7."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } else if (!wfInput.if4cond.getValue() && wfOutput.if4ValueOut.getValue() != -1) { + #include + std::stringstream ss; + ss << "Test Failure: if4valueOut [" << wfOutput.if4ValueOut.getValue() << "] is not -1."; + throw wfr::exception::wfr_fatal_error(ss.str()); + } diff --git a/iwir/coderepo/if1/wfInput.code b/iwir/coderepo/if1/wfInput.code index 13fc6ec..7b8f122 100755 --- a/iwir/coderepo/if1/wfInput.code +++ b/iwir/coderepo/if1/wfInput.code @@ -10,7 +10,8 @@ ("if1", boost::program_options::value(), "if1 condition") ("if2", boost::program_options::value(), "if2 condition") ("if3", boost::program_options::value(), "if3 condition") - ("if4", boost::program_options::value(), "if4 condition"); + ("if4", boost::program_options::value(), "if4 condition") + ("ifall", boost::program_options::value(), "all if conditions"); boost::program_options::variables_map vm; auto parsed = boost::program_options::command_line_parser(argc, argv).options(opts).allow_unregistered().run(); boost::program_options::store(parsed, vm); @@ -31,6 +32,13 @@ if (vm.count("if4")) { if4Cond = vm["if4"].as(); } + if (vm.count("ifall")) { + auto val = vm["ifall"].as(); + if1Cond = val; + if2Cond = val; + if3Cond = val; + if4Cond = val; + } std::cerr << "if1 = " << if1Cond << std::endl; std::cerr << "if2 = " << if2Cond << std::endl; std::cerr << "if3 = " << if3Cond << std::endl; diff --git a/iwir/if01.iwir b/iwir/if01.iwir new file mode 100644 index 0000000..385bfd2 --- /dev/null +++ b/iwir/if01.iwir @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + if1cond = true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file