错误处理
This commit is contained in:
@@ -52,7 +52,7 @@ TEST(external_operation_test, completion_before_subscription_is_delivered_once)
|
||||
|
||||
int completion_count{};
|
||||
operation.on_complete([&](External_Operation_Completion completion) {
|
||||
EXPECT_EQ(completion.error, External_Operation_Error::none);
|
||||
EXPECT_EQ(completion.result, External_Operation_Result::none);
|
||||
EXPECT_FALSE(completion.exception);
|
||||
++completion_count;
|
||||
});
|
||||
@@ -84,8 +84,8 @@ TEST(render_graph_runtime_test, reusable_topology_executes_multiple_frames) {
|
||||
++execution_count.at(index);
|
||||
return Node_Execution_Result::completed();
|
||||
};
|
||||
EXPECT_EQ(runtime.execute({}, execute_node), renderive::render_graph::detail::Render_Graph_Execution_Error::none);
|
||||
EXPECT_EQ(runtime.execute({}, execute_node), renderive::render_graph::detail::Render_Graph_Execution_Error::none);
|
||||
EXPECT_EQ(runtime.execute({}, execute_node), renderive::render_graph::detail::Render_Graph_Execution_Result::none);
|
||||
EXPECT_EQ(runtime.execute({}, execute_node), renderive::render_graph::detail::Render_Graph_Execution_Result::none);
|
||||
EXPECT_EQ(execution_count[0], 2U);
|
||||
EXPECT_EQ(execution_count[1], 2U);
|
||||
}
|
||||
@@ -110,14 +110,14 @@ TEST(render_graph_runtime_test,
|
||||
return Node_Execution_Result::completed();
|
||||
};
|
||||
|
||||
auto graph_error = renderive::render_graph::detail::Render_Graph_Execution_Error::none;
|
||||
auto graph_error = renderive::render_graph::detail::Render_Graph_Execution_Result::none;
|
||||
std::thread execution([&] { graph_error = runtime.execute(slots, execute_node); });
|
||||
submit_started.wait(false, std::memory_order_acquire);
|
||||
EXPECT_FALSE(publish_executed.load(std::memory_order_acquire));
|
||||
EXPECT_TRUE(source.complete());
|
||||
execution.join();
|
||||
|
||||
EXPECT_EQ(graph_error, renderive::render_graph::detail::Render_Graph_Execution_Error::none);
|
||||
EXPECT_EQ(graph_error, renderive::render_graph::detail::Render_Graph_Execution_Result::none);
|
||||
EXPECT_TRUE(publish_executed.load(std::memory_order_acquire));
|
||||
EXPECT_EQ(execution_storage[0].status, Node_Execution_Status::complete);
|
||||
EXPECT_EQ(execution_storage[1].status, Node_Execution_Status::complete);
|
||||
@@ -181,7 +181,7 @@ TEST(render_graph_runtime_test,
|
||||
return Node_Execution_Result::external(source.operation());
|
||||
};
|
||||
|
||||
auto graph_error = renderive::render_graph::detail::Render_Graph_Execution_Error::none;
|
||||
auto graph_error = renderive::render_graph::detail::Render_Graph_Execution_Result::none;
|
||||
std::thread execution([&] { graph_error = runtime.execute({}, execute_node); });
|
||||
external_started.wait(false, std::memory_order_acquire);
|
||||
renderive::scheduling::detail::OneTBB_Runtime::instance().enqueue([&] {
|
||||
@@ -198,7 +198,7 @@ TEST(render_graph_runtime_test,
|
||||
}
|
||||
EXPECT_TRUE(source.complete());
|
||||
execution.join();
|
||||
EXPECT_EQ(graph_error, renderive::render_graph::detail::Render_Graph_Execution_Error::none);
|
||||
EXPECT_EQ(graph_error, renderive::render_graph::detail::Render_Graph_Execution_Result::none);
|
||||
}
|
||||
|
||||
TEST(external_operation_test, cancellation_is_terminal_and_delivered_once) {
|
||||
@@ -215,7 +215,7 @@ TEST(external_operation_test, cancellation_is_terminal_and_delivered_once) {
|
||||
++completion_count;
|
||||
});
|
||||
EXPECT_EQ(completion_count, 1);
|
||||
EXPECT_EQ(completion.error, External_Operation_Error::cancelled);
|
||||
EXPECT_EQ(completion.result, External_Operation_Result::cancelled);
|
||||
EXPECT_FALSE(completion.exception);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ TEST(external_operation_test, deadline_cancels_pending_operation) {
|
||||
ASSERT_TRUE(condition.wait_for(lock, std::chrono::seconds(1),
|
||||
[&] { return completed; }));
|
||||
}
|
||||
EXPECT_EQ(completion.error, External_Operation_Error::deadline_exceeded);
|
||||
EXPECT_EQ(completion.result, External_Operation_Result::deadline_exceeded);
|
||||
EXPECT_FALSE(completion.exception);
|
||||
EXPECT_EQ(operation.status(), External_Operation_Status::cancelled);
|
||||
}
|
||||
@@ -253,7 +253,7 @@ TEST(render_graph_runtime_test,
|
||||
auto slots = execution_slots(*plan, execution_storage);
|
||||
std::atomic<bool> submit_started{};
|
||||
std::atomic<bool> publish_executed{};
|
||||
auto graph_error = renderive::render_graph::detail::Render_Graph_Execution_Error::none;
|
||||
auto graph_error = renderive::render_graph::detail::Render_Graph_Execution_Result::none;
|
||||
|
||||
renderive::render_graph::detail::Render_Graph_Runtime runtime(*plan);
|
||||
const auto execute_node = [&](std::size_t index, Node_Execution_Metrics*) {
|
||||
@@ -273,7 +273,7 @@ TEST(render_graph_runtime_test,
|
||||
runtime.cancel_pending();
|
||||
execution.join();
|
||||
|
||||
EXPECT_EQ(graph_error, renderive::render_graph::detail::Render_Graph_Execution_Error::cancelled);
|
||||
EXPECT_EQ(graph_error, renderive::render_graph::detail::Render_Graph_Execution_Result::cancelled);
|
||||
EXPECT_FALSE(publish_executed.load(std::memory_order_acquire));
|
||||
EXPECT_EQ(execution_storage[0].status, Node_Execution_Status::cancelled);
|
||||
EXPECT_EQ(source.operation().status(), External_Operation_Status::cancelled);
|
||||
@@ -292,7 +292,7 @@ TEST(render_graph_runtime_test, idle_cancellation_does_not_arm_next_execution) {
|
||||
executed.fetch_add(1, std::memory_order_relaxed);
|
||||
return Node_Execution_Result::completed();
|
||||
}),
|
||||
renderive::render_graph::detail::Render_Graph_Execution_Error::none);
|
||||
renderive::render_graph::detail::Render_Graph_Execution_Result::none);
|
||||
|
||||
EXPECT_EQ(executed.load(std::memory_order_relaxed), 2);
|
||||
EXPECT_EQ(execution_storage[0].status, Node_Execution_Status::complete);
|
||||
@@ -316,7 +316,7 @@ TEST(external_operation_test, completion_commit_precedes_completion_notification
|
||||
std::atomic<int> published{};
|
||||
int observed{};
|
||||
operation.on_complete([&](External_Operation_Completion completion) {
|
||||
EXPECT_EQ(completion.error, External_Operation_Error::none);
|
||||
EXPECT_EQ(completion.result, External_Operation_Result::none);
|
||||
EXPECT_FALSE(completion.exception);
|
||||
observed = published.load(std::memory_order_acquire);
|
||||
});
|
||||
@@ -338,7 +338,7 @@ TEST(external_operation_test, completion_commit_failure_fails_operation) {
|
||||
});
|
||||
|
||||
EXPECT_TRUE(source.complete([] { throw std::runtime_error("publish failed"); }));
|
||||
EXPECT_EQ(completion.error, External_Operation_Error::none);
|
||||
EXPECT_EQ(completion.result, External_Operation_Result::none);
|
||||
ASSERT_TRUE(completion.exception);
|
||||
EXPECT_THROW(std::rethrow_exception(completion.exception), std::runtime_error);
|
||||
EXPECT_EQ(operation.status(), External_Operation_Status::failed);
|
||||
|
||||
Reference in New Issue
Block a user