File tree Expand file tree Collapse file tree 6 files changed +50
-12
lines changed Expand file tree Collapse file tree 6 files changed +50
-12
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class FakePerfTask : public TestTask<T> {
4343 explicit FakePerfTask (ppc::core::TaskDataPtr perf_task_data) : TestTask<T>(perf_task_data) {}
4444
4545 bool RunImpl () override {
46- std::this_thread::sleep_for (std::chrono::milliseconds ( 21000 ));
46+ std::this_thread::sleep_for (std::chrono::seconds ( 11 ));
4747 return TestTask<T>::RunImpl ();
4848 }
4949};
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ void ppc::core::Perf::PrintPerfStatistic(const std::shared_ptr<PerfResults>& per
7272 type_test_name = " task_run" ;
7373 } else if (perf_results->type_of_running == PerfResults::TypeOfRunning::kPipeline ) {
7474 type_test_name = " pipeline" ;
75- } else if (perf_results-> type_of_running == PerfResults::TypeOfRunning:: kNone ) {
75+ } else {
7676 type_test_name = " none" ;
7777 }
7878
Original file line number Diff line number Diff line change @@ -30,6 +30,28 @@ TEST(task_tests, check_int32_t) {
3030 ASSERT_EQ (static_cast <size_t >(out[0 ]), in.size ());
3131}
3232
33+ TEST (task_tests, check_int32_t_slow) {
34+ // Create data
35+ std::vector<int32_t > in (20 , 1 );
36+ std::vector<int32_t > out (1 , 0 );
37+
38+ // Create TaskData
39+ auto task_data = std::make_shared<ppc::core::TaskData>();
40+ task_data->inputs .emplace_back (reinterpret_cast <uint8_t *>(in.data ()));
41+ task_data->inputs_count .emplace_back (in.size ());
42+ task_data->outputs .emplace_back (reinterpret_cast <uint8_t *>(out.data ()));
43+ task_data->outputs_count .emplace_back (out.size ());
44+
45+ // Create Task
46+ ppc::test::task::FakeSlowTask<int32_t > test_task (task_data);
47+ bool is_valid = test_task.Validation ();
48+ ASSERT_EQ (is_valid, true );
49+ test_task.PreProcessing ();
50+ test_task.Run ();
51+ ASSERT_ANY_THROW (test_task.PostProcessing ());
52+ ASSERT_EQ (static_cast <size_t >(out[0 ]), in.size ());
53+ }
54+
3355TEST (task_tests, check_validate_func) {
3456 // Create data
3557 std::vector<int32_t > in (20 , 1 );
Original file line number Diff line number Diff line change 11#pragma once
22
3+ #include < chrono>
4+ #include < thread>
35#include < vector>
46
57#include " core/task/include/task.hpp"
@@ -33,4 +35,15 @@ class TestTask : public ppc::core::Task {
3335 T *output_{};
3436};
3537
38+ template <class T >
39+ class FakeSlowTask : public TestTask <T> {
40+ public:
41+ explicit FakeSlowTask (ppc::core::TaskDataPtr perf_task_data) : TestTask<T>(perf_task_data) {}
42+
43+ bool RunImpl () override {
44+ std::this_thread::sleep_for (std::chrono::seconds (2 ));
45+ return TestTask<T>::RunImpl ();
46+ }
47+ };
48+
3649} // namespace ppc::test::task
Original file line number Diff line number Diff line change 11#include " core/task/include/task.hpp"
22
3- #include < gtest/gtest.h>
4-
5- #include < chrono>
63#include < cstddef>
4+ #include < iomanip>
75#include < iostream>
6+ #include < sstream>
87#include < stdexcept>
98#include < string>
10- #include < utility>
119
1210void ppc::core::Task::SetData (TaskDataPtr task_data_ptr) {
1311 task_data_ptr->state_of_testing = TaskData::StateOfTesting::kFunc ;
@@ -58,13 +56,18 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
5856 tmp_time_point_ = std::chrono::high_resolution_clock::now ();
5957 }
6058
61- if (str == " post_processing " && task_data->state_of_testing == TaskData::StateOfTesting::kFunc ) {
59+ if (str == " PostProcessing " && task_data->state_of_testing == TaskData::StateOfTesting::kFunc ) {
6260 auto end = std::chrono::high_resolution_clock::now ();
6361 auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - tmp_time_point_).count ();
6462 auto current_time = static_cast <double >(duration) * 1e-9 ;
65- if (current_time > max_test_time_) {
66- std::cerr << " Current test work more than " << max_test_time_ << " secs: " << current_time << ' \n ' ;
67- EXPECT_TRUE (current_time < max_test_time_);
63+ if (current_time < max_test_time_) {
64+ std::cout << " Test time:" << std::fixed << std::setprecision (10 ) << current_time;
65+ } else {
66+ std::stringstream err_msg;
67+ err_msg << " \n Task execute time need to be: " ;
68+ err_msg << " time < " << max_test_time_ << " secs.\n " ;
69+ err_msg << " Original time in secs: " << current_time << ' \n ' ;
70+ throw std::runtime_error (err_msg.str ().c_str ());
6871 }
6972 }
7073}
Original file line number Diff line number Diff line change @@ -109,8 +109,8 @@ def run_core(self):
109109 self .__run_exec (f"{ self .valgrind_cmd } { self .work_dir / 'core_func_tests' } { self .__get_gtest_settings (1 )} " )
110110 self .__run_exec (f"{ self .valgrind_cmd } { self .work_dir / 'ref_func_tests' } { self .__get_gtest_settings (1 )} " )
111111
112- self .__run_exec (f"{ self .work_dir / 'core_func_tests' } { self .__get_gtest_settings (3 )} " )
113- self .__run_exec (f"{ self .work_dir / 'ref_func_tests' } { self .__get_gtest_settings (3 )} " )
112+ self .__run_exec (f"{ self .work_dir / 'core_func_tests' } { self .__get_gtest_settings (1 )} " )
113+ self .__run_exec (f"{ self .work_dir / 'ref_func_tests' } { self .__get_gtest_settings (1 )} " )
114114
115115 def run_processes (self , additional_mpi_args ):
116116 if os .environ .get ("CLANG_BUILD" ) == "1" :
You can’t perform that action at this time.
0 commit comments