Skip to content
Closed
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
build
out
mpich
cmake-build-release*
cmake-build-debug*
cmake-build-*
.idea/
.vs/
.vscode/
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 @@ -66,7 +66,7 @@ void ppc::core::Perf::print_perf_statistic(const std::shared_ptr<PerfResults>& p
type_test_name = "task_run";
} else if (perfResults->type_of_running == PerfResults::TypeOfRunning::PIPELINE) {
type_test_name = "pipeline";
} else if (perfResults->type_of_running == PerfResults::TypeOfRunning::NONE) {
} 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 @@ -27,6 +27,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 taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t *>(in.data()));
taskData->inputs_count.emplace_back(in.size());
taskData->outputs.emplace_back(reinterpret_cast<uint8_t *>(out.data()));
taskData->outputs_count.emplace_back(out.size());

// Create Task
ppc::test::task::FakeSlowTask<int32_t> testTask(taskData);
bool isValid = testTask.validation();
ASSERT_EQ(isValid, true);
testTask.pre_processing();
testTask.run();
ASSERT_ANY_THROW(testTask.post_processing());
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
14 changes: 14 additions & 0 deletions modules/core/task/func_tests/test_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#include <gtest/gtest.h>

#include <memory>
#include <thread>
#include <vector>

#include "core/task/include/task.hpp"

using namespace std::chrono_literals;

namespace ppc::test::task {

template <class T>
Expand Down Expand Up @@ -37,6 +40,17 @@ class TestTask : public ppc::core::Task {
T *output_{};
};

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

bool run_impl() override {
std::this_thread::sleep_for(5000ms);
return TestTask<T>::run_impl();
}
};

} // namespace ppc::test::task

#endif // MODULES_CORE_TESTS_TEST_TASK_HPP_
16 changes: 12 additions & 4 deletions modules/core/task/src/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <gtest/gtest.h>

#include <iomanip>
#include <stdexcept>
#include <utility>

Expand Down Expand Up @@ -36,7 +37,9 @@ bool ppc::core::Task::post_processing() {
}

void ppc::core::Task::internal_order_test(const std::string& str) {
if (!functions_order.empty() && str == functions_order.back() && str == "run") return;
if (!functions_order.empty() && str == functions_order.back() && str == "run") {
return;
}

functions_order.push_back(str);

Expand All @@ -56,9 +59,14 @@ void ppc::core::Task::internal_order_test(const std::string& str) {
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 << std::endl;
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 << std::endl;
throw std::runtime_error(err_msg.str().c_str());
}
}
}
Expand Down
Loading