File tree 4 files changed +47
-9
lines changed
4 files changed +47
-9
lines changed 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
72
72
type_test_name = " task_run" ;
73
73
} else if (perf_results->type_of_running == PerfResults::TypeOfRunning::kPipeline ) {
74
74
type_test_name = " pipeline" ;
75
- } else if (perf_results-> type_of_running == PerfResults::TypeOfRunning:: kNone ) {
75
+ } else {
76
76
type_test_name = " none" ;
77
77
}
78
78
Original file line number Diff line number Diff line change @@ -30,6 +30,28 @@ TEST(task_tests, check_int32_t) {
30
30
ASSERT_EQ (static_cast <size_t >(out[0 ]), in.size ());
31
31
}
32
32
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
+
33
55
TEST (task_tests, check_validate_func) {
34
56
// Create data
35
57
std::vector<int32_t > in (20 , 1 );
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
+ #include < thread>
3
4
#include < vector>
4
5
5
6
#include " core/task/include/task.hpp"
6
7
8
+ using namespace std ::chrono_literals;
9
+
7
10
namespace ppc ::test::task {
8
11
9
12
template <class T >
@@ -33,4 +36,15 @@ class TestTask : public ppc::core::Task {
33
36
T *output_{};
34
37
};
35
38
39
+ template <class T >
40
+ class FakeSlowTask : public TestTask <T> {
41
+ public:
42
+ explicit FakeSlowTask (ppc::core::TaskDataPtr perf_task_data) : TestTask<T>(perf_task_data) {}
43
+
44
+ bool RunImpl () override {
45
+ std::this_thread::sleep_for (5000ms);
46
+ return TestTask<T>::RunImpl ();
47
+ }
48
+ };
49
+
36
50
} // namespace ppc::test::task
Original file line number Diff line number Diff line change 1
1
#include " core/task/include/task.hpp"
2
2
3
- #include < gtest/gtest.h>
4
-
5
- #include < chrono>
6
3
#include < cstddef>
4
+ #include < iomanip>
7
5
#include < iostream>
8
6
#include < stdexcept>
9
7
#include < string>
10
- #include < utility>
11
8
12
9
void ppc::core::Task::SetData (TaskDataPtr task_data_ptr) {
13
10
task_data_ptr->state_of_testing = TaskData::StateOfTesting::kFunc ;
@@ -58,13 +55,18 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
58
55
tmp_time_point_ = std::chrono::high_resolution_clock::now ();
59
56
}
60
57
61
- if (str == " post_processing " && task_data->state_of_testing == TaskData::StateOfTesting::kFunc ) {
58
+ if (str == " PostProcessing " && task_data->state_of_testing == TaskData::StateOfTesting::kFunc ) {
62
59
auto end = std::chrono::high_resolution_clock::now ();
63
60
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - tmp_time_point_).count ();
64
61
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_);
62
+ if (current_time < max_test_time_) {
63
+ std::cout << " Test time:" << std::fixed << std::setprecision (10 ) << current_time;
64
+ } else {
65
+ std::stringstream err_msg;
66
+ err_msg << " \n Task execute time need to be: " ;
67
+ err_msg << " time < " << max_test_time_ << " secs.\n " ;
68
+ err_msg << " Original time in secs: " << current_time << ' \n ' ;
69
+ throw std::runtime_error (err_msg.str ().c_str ());
68
70
}
69
71
}
70
72
}
You can’t perform that action at this time.
0 commit comments