Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/core/perf/func_tests/test_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FakePerfTask : public TestTask<T> {
explicit FakePerfTask(ppc::core::TaskDataPtr perf_task_data) : TestTask<T>(perf_task_data) {}

bool RunImpl() override {
std::this_thread::sleep_for(std::chrono::milliseconds(21000));
std::this_thread::sleep_for(std::chrono::seconds(11));
return TestTask<T>::RunImpl();
}
};
Expand Down
2 changes: 1 addition & 1 deletion modules/core/perf/src/perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void ppc::core::Perf::PrintPerfStatistic(const std::shared_ptr<PerfResults>& per
type_test_name = "task_run";
} else if (perf_results->type_of_running == PerfResults::TypeOfRunning::kPipeline) {
type_test_name = "pipeline";
} else if (perf_results->type_of_running == PerfResults::TypeOfRunning::kNone) {
} else {
type_test_name = "none";
}

Expand Down
22 changes: 22 additions & 0 deletions modules/core/task/func_tests/task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ TEST(task_tests, check_int32_t) {
ASSERT_EQ(static_cast<size_t>(out[0]), in.size());
}

TEST(task_tests, check_int32_t_slow) {
// Create data
std::vector<int32_t> in(20, 1);
std::vector<int32_t> out(1, 0);

// Create TaskData
auto task_data = std::make_shared<ppc::core::TaskData>();
task_data->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
task_data->inputs_count.emplace_back(in.size());
task_data->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
task_data->outputs_count.emplace_back(out.size());

// Create Task
ppc::test::task::FakeSlowTask<int32_t> test_task(task_data);
bool is_valid = test_task.Validation();
ASSERT_EQ(is_valid, true);
test_task.PreProcessing();
test_task.Run();
ASSERT_ANY_THROW(test_task.PostProcessing());
ASSERT_EQ(static_cast<size_t>(out[0]), in.size());
}

TEST(task_tests, check_validate_func) {
// Create data
std::vector<int32_t> in(20, 1);
Expand Down
13 changes: 13 additions & 0 deletions modules/core/task/func_tests/test_task.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <chrono>
#include <thread>
#include <vector>

#include "core/task/include/task.hpp"
Expand Down Expand Up @@ -33,4 +35,15 @@ class TestTask : public ppc::core::Task {
T *output_{};
};

template <class T>
class FakeSlowTask : public TestTask<T> {
public:
explicit FakeSlowTask(ppc::core::TaskDataPtr perf_task_data) : TestTask<T>(perf_task_data) {}

bool RunImpl() override {
std::this_thread::sleep_for(std::chrono::seconds(2));
return TestTask<T>::RunImpl();
}
};

} // namespace ppc::test::task
19 changes: 11 additions & 8 deletions modules/core/task/src/task.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include "core/task/include/task.hpp"

#include <gtest/gtest.h>

#include <chrono>
#include <cstddef>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <utility>

void ppc::core::Task::SetData(TaskDataPtr task_data_ptr) {
task_data_ptr->state_of_testing = TaskData::StateOfTesting::kFunc;
Expand Down Expand Up @@ -58,13 +56,18 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
tmp_time_point_ = std::chrono::high_resolution_clock::now();
}

if (str == "post_processing" && task_data->state_of_testing == TaskData::StateOfTesting::kFunc) {
if (str == "PostProcessing" && task_data->state_of_testing == TaskData::StateOfTesting::kFunc) {
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - tmp_time_point_).count();
auto current_time = static_cast<double>(duration) * 1e-9;
if (current_time > max_test_time_) {
std::cerr << "Current test work more than " << max_test_time_ << " secs: " << current_time << '\n';
EXPECT_TRUE(current_time < max_test_time_);
if (current_time < max_test_time_) {
std::cout << "Test time:" << std::fixed << std::setprecision(10) << current_time;
} else {
std::stringstream err_msg;
err_msg << "\nTask execute time need to be: ";
err_msg << "time < " << max_test_time_ << " secs.\n";
err_msg << "Original time in secs: " << current_time << '\n';
throw std::runtime_error(err_msg.str().c_str());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def run_core(self):
self.__run_exec(f"{self.valgrind_cmd} {self.work_dir / 'core_func_tests'} {self.__get_gtest_settings(1)}")
self.__run_exec(f"{self.valgrind_cmd} {self.work_dir / 'ref_func_tests'} {self.__get_gtest_settings(1)}")

self.__run_exec(f"{self.work_dir / 'core_func_tests'} {self.__get_gtest_settings(3)}")
self.__run_exec(f"{self.work_dir / 'ref_func_tests'} {self.__get_gtest_settings(3)}")
self.__run_exec(f"{self.work_dir / 'core_func_tests'} {self.__get_gtest_settings(1)}")
self.__run_exec(f"{self.work_dir / 'ref_func_tests'} {self.__get_gtest_settings(1)}")

def run_processes(self, additional_mpi_args):
if os.environ.get("CLANG_BUILD") == "1":
Expand Down
Loading