LCOV - code coverage report
Current view: top level - UTests - testInsertion.cpp (source / functions) Hit Total Coverage
Test: Coverage example Lines: 33 35 94.3 %
Date: 2021-12-02 17:21:05 Functions: 8 8 100.0 %

          Line data    Source code
       1             : ///////////////////////////////////////////////////////////////////////////
       2             : // Spetabaru - Berenger Bramas MPCDF - 2017
       3             : // Under LGPL Licence, please you must read the LICENCE file.
       4             : ///////////////////////////////////////////////////////////////////////////
       5             : 
       6             : #include "UTester.hpp"
       7             : #include "utestUtils.hpp"
       8             : 
       9             : #include "Data/SpDataAccessMode.hpp"
      10             : #include "Utils/SpUtils.hpp"
      11             : #include "Utils/SpArrayView.hpp"
      12             : #include "Utils/SpArrayAccessor.hpp"
      13             : 
      14             : #include "Task/SpTask.hpp"
      15             : #include "Legacy/SpRuntime.hpp"
      16             : 
      17             : class TestInsertion : public UTester< TestInsertion > {
      18             :     using Parent = UTester< TestInsertion >;
      19             :     
      20             :     template <SpSpeculativeModel Spm>
      21           3 :     void Test(){
      22           6 :         SpRuntime<Spm> runtime;
      23             : 
      24           3 :         runtime.setSpeculationTest([](const int /*inNbReadyTasks*/, const SpProbability& /*inProbability*/) -> bool{
      25           0 :             return true;
      26             :         });
      27             :         
      28           3 :         int a=0, b=0, c=0, d=0;
      29             : 
      30           3 :         std::promise<bool> promise1;
      31             : 
      32          55 :         runtime.task(SpWrite(a), [&promise1](int& param_a){
      33           3 :             param_a = 1;
      34           3 :             promise1.get_future().get();
      35             :         });
      36             : 
      37          38 :         runtime.task(SpRead(a), SpPotentialWrite(b), []([[maybe_unused]] const int& a_param, [[maybe_unused]] int&) -> bool{
      38           3 :             return false;
      39             :         });
      40             : 
      41           6 :         runtime.task(SpRead(b), SpPotentialWrite(c), [](const int& param_b, [[maybe_unused]] int&) -> bool {
      42           3 :             bool res = false;
      43           3 :             if(param_b != 0) {
      44           0 :                 res = true;
      45             :             }
      46           3 :             return res;
      47             :         });
      48             :         
      49           9 :         runtime.task(SpRead(c), SpWrite(d), [](const int& param_c, int&param_d){
      50           3 :             if(param_c == 0) {
      51           3 :                 param_d = 1;
      52             :             }
      53             :         });
      54             :         
      55           9 :         runtime.task(SpRead(d), [this](const int& param_d) {
      56           3 :             UASSERTEEQUAL(param_d, 1);
      57             :         });
      58             :         
      59           3 :         promise1.set_value(true);
      60             : 
      61           3 :         runtime.waitAllTasks();
      62           3 :         runtime.stopAllThreads();
      63             : 
      64           3 :         runtime.generateDot("/tmp/testIns" + std::to_string(static_cast<int>(Spm)) + ".dot");
      65           3 :     }
      66             :     
      67           1 :     void Test1() { Test<SpSpeculativeModel::SP_MODEL_1>(); }
      68           1 :     void Test2() { Test<SpSpeculativeModel::SP_MODEL_2>(); }
      69           1 :     void Test3() { Test<SpSpeculativeModel::SP_MODEL_3>(); }
      70             : 
      71           1 :     void SetTests() {
      72           1 :         Parent::AddTest(&TestInsertion::Test1, "Basic insertion test for model 1");
      73           1 :         Parent::AddTest(&TestInsertion::Test2, "Basic insertion test for model 2");
      74           1 :         Parent::AddTest(&TestInsertion::Test3, "Basic insertion test for model 3");
      75           1 :     }
      76             : };
      77             : 
      78             : // You must do this
      79           1 : TestClass(TestInsertion)
      80             : 
      81             : 

Generated by: LCOV version 1.14