MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / TEST_F

Function TEST_F

tests/unit/threading.cpp:23–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21class NegativeThreading : public VkLayerTest {};
22
23TEST_F(NegativeThreading, CommandBufferCollision) {
24 m_errorMonitor->SetDesiredError("THREADING ERROR");
25 m_errorMonitor->SetAllowedFailureMsg("THREADING ERROR"); // Ignore any extra threading errors found beyond the first one
26
27 RETURN_IF_SKIP(Init());
28 InitRenderTarget();
29
30 // Test takes magnitude of time longer for profiles and slows down testing
31 if (IsPlatformMockICD()) {
32 GTEST_SKIP() << "Test not supported by MockICD";
33 }
34
35 // Calls AllocateCommandBuffers
36 vkt::CommandBuffer commandBuffer(*m_device, m_command_pool);
37
38 commandBuffer.Begin();
39
40 vkt::Event event(*m_device);
41 VkResult err;
42
43 err = vk::ResetEvent(device(), event);
44 ASSERT_EQ(VK_SUCCESS, err);
45
46 ThreadTestData data;
47 data.commandBuffer = commandBuffer;
48 data.event = event;
49 std::atomic<bool> bailout{false};
50 data.bailout = &bailout;
51 m_errorMonitor->SetBailout(data.bailout);
52
53 // First do some correct operations using multiple threads.
54 // Add many entries to command buffer from another thread.
55 std::thread thread1(AddToCommandBuffer, &data);
56 // Make non-conflicting calls from this thread at the same time.
57 for (int i = 0; i < 1000 /* Initially 80000 to make machine miserable */; i++) {
58 uint32_t count;
59 vk::EnumeratePhysicalDevices(instance(), &count, NULL);
60 }
61 thread1.join();
62
63 // Then do some incorrect operations using multiple threads.
64 // Add many entries to command buffer from another thread.
65 std::thread thread2(AddToCommandBuffer, &data);
66 // Add many entries to command buffer from this thread at the same time.
67 AddToCommandBuffer(&data);
68
69 thread2.join();
70 commandBuffer.End();
71
72 m_errorMonitor->SetBailout(NULL);
73
74 m_errorMonitor->VerifyFound();
75}
76
77TEST_F(NegativeThreading, UpdateDescriptorCollision) {
78 TEST_DESCRIPTION("Two threads updating the same descriptor set, expected to generate a threading error");

Callers

nothing calls this directly

Calls 10

ResetEventFunction · 0.85
EnumeratePhysicalDevicesFunction · 0.85
AddToCommandBufferFunction · 0.85
UpdateDescriptorFunction · 0.85
SetDesiredErrorMethod · 0.80
SetAllowedFailureMsgMethod · 0.80
SetBailoutMethod · 0.80
BeginMethod · 0.45
EndMethod · 0.45
VerifyFoundMethod · 0.45

Tested by

no test coverage detected