diff options
Diffstat (limited to 'tests/test_command_queue.h')
-rw-r--r-- | tests/test_command_queue.h | 60 |
1 files changed, 8 insertions, 52 deletions
diff --git a/tests/test_command_queue.h b/tests/test_command_queue.h index 2f0f62f5c8..f0d4569942 100644 --- a/tests/test_command_queue.h +++ b/tests/test_command_queue.h @@ -127,20 +127,20 @@ public: int func1_count = 0; - void func1(Transform t) { + void func1(Transform3D t) { func1_count++; } - void func2(Transform t, float f) { + void func2(Transform3D t, float f) { func1_count++; } - void func3(Transform t1, Transform t2, Transform t3, Transform t4, Transform t5, Transform t6) { + void func3(Transform3D t1, Transform3D t2, Transform3D t3, Transform3D t4, Transform3D t5, Transform3D t6) { func1_count++; } - Transform func1r(Transform t) { + Transform3D func1r(Transform3D t) { func1_count++; return t; } - Transform func2r(Transform t, float f) { + Transform3D func2r(Transform3D t, float f) { func1_count++; return t; } @@ -156,7 +156,7 @@ public: command_queue.flush_all(); } for (int i = 0; i < message_count_to_read; i++) { - command_queue.wait_and_flush_one(); + command_queue.wait_and_flush(); } message_count_to_read = 0; @@ -175,8 +175,8 @@ public: during_writing = false; writer_threadwork.thread_wait_for_work(); while (!exit_threads) { - Transform tr; - Transform otr; + Transform3D tr; + Transform3D otr; float f = 1; during_writing = true; for (int i = 0; i < message_types_to_write.size(); i++) { @@ -276,50 +276,6 @@ TEST_CASE("[CommandQueue] Test Queue Basics") { ProjectSettings::get_singleton()->property_get_revert(COMMAND_QUEUE_SETTING)); } -TEST_CASE("[CommandQueue] Test Waiting at Queue Full") { - const char *COMMAND_QUEUE_SETTING = "memory/limits/command_queue/multithreading_queue_size_kb"; - ProjectSettings::get_singleton()->set_setting(COMMAND_QUEUE_SETTING, 1); - SharedThreadState sts; - sts.init_threads(); - - int msgs_to_add = 24; // a queue of size 1kB fundamentally cannot fit 24 matrices. - for (int i = 0; i < msgs_to_add; i++) { - sts.add_msg_to_write(SharedThreadState::TEST_MSG_FUNC1_TRANSFORM); - } - sts.writer_threadwork.main_start_work(); - // If we call main_wait_for_done, we will deadlock. So instead... - sts.message_count_to_read = 1; - sts.reader_threadwork.main_start_work(); - sts.reader_threadwork.main_wait_for_done(); - CHECK_MESSAGE(sts.func1_count == 1, - "Reader should have read one message"); - CHECK_MESSAGE(sts.during_writing, - "Writer thread should still be blocked on writing."); - sts.message_count_to_read = msgs_to_add - 3; - sts.reader_threadwork.main_start_work(); - sts.reader_threadwork.main_wait_for_done(); - CHECK_MESSAGE(sts.func1_count >= msgs_to_add - 3, - "Reader should have read most messages"); - sts.writer_threadwork.main_wait_for_done(); - CHECK_MESSAGE(sts.during_writing == false, - "Writer thread should no longer be blocked on writing."); - sts.message_count_to_read = 2; - sts.reader_threadwork.main_start_work(); - sts.reader_threadwork.main_wait_for_done(); - sts.message_count_to_read = -1; - sts.reader_threadwork.main_start_work(); - sts.reader_threadwork.main_wait_for_done(); - CHECK_MESSAGE(sts.func1_count == msgs_to_add, - "Reader should have read all messages"); - - sts.destroy_threads(); - - CHECK_MESSAGE(sts.func1_count == msgs_to_add, - "Reader should have read no additional messages after join"); - ProjectSettings::get_singleton()->set_setting(COMMAND_QUEUE_SETTING, - ProjectSettings::get_singleton()->property_get_revert(COMMAND_QUEUE_SETTING)); -} - TEST_CASE("[CommandQueue] Test Queue Wrapping to same spot.") { const char *COMMAND_QUEUE_SETTING = "memory/limits/command_queue/multithreading_queue_size_kb"; ProjectSettings::get_singleton()->set_setting(COMMAND_QUEUE_SETTING, 1); |