Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: gpu/ipc/service/gpu_channel_unittest.cc

Issue 2814843002: gpu: GPU service scheduler. (Closed)
Patch Set: Do not allow HIGH priority contexts by unprivileged clients. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/ipc/service/gpu_channel_unittest.cc
diff --git a/gpu/ipc/service/gpu_channel_unittest.cc b/gpu/ipc/service/gpu_channel_unittest.cc
index e76f2dbf44766dd68413cb14c7dd694f0aaf98ce..1a082d781b0ecfa92cf484fc1e9ff22b9a3079b7 100644
--- a/gpu/ipc/service/gpu_channel_unittest.cc
+++ b/gpu/ipc/service/gpu_channel_unittest.cc
@@ -141,21 +141,20 @@ TEST_F(GpuChannelTest, IncompatibleStreamIds) {
EXPECT_FALSE(stub);
}
-TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) {
+TEST_F(GpuChannelTest, HighPriorityStreamsDisallowed) {
int32_t kClientId = 1;
bool is_gpu_host = false;
GpuChannel* channel = CreateChannel(kClientId, is_gpu_host);
ASSERT_TRUE(channel);
- // Create first context.
+ // REAL_TIME priority is disallowed.
int32_t kRouteId = 1;
int32_t kStreamId = 1;
- GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME;
GPUCreateCommandBufferConfig init_params;
init_params.surface_handle = kNullSurfaceHandle;
init_params.share_group_id = MSG_ROUTING_NONE;
init_params.stream_id = kStreamId;
- init_params.stream_priority = kStreamPriority;
+ init_params.stream_priority = GpuStreamPriority::REAL_TIME;
init_params.attribs = gles2::ContextCreationAttribHelper();
init_params.active_url = GURL();
bool result = false;
@@ -164,37 +163,50 @@ TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) {
init_params, kRouteId, GetSharedHandle(), &result,
&capabilities));
EXPECT_FALSE(result);
+ EXPECT_FALSE(channel->LookupCommandBuffer(kRouteId));
- GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId);
- EXPECT_FALSE(stub);
+ // HIGH priority is also disallowed.
+ init_params.stream_priority = GpuStreamPriority::HIGH;
+ HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer(
+ init_params, kRouteId, GetSharedHandle(), &result,
+ &capabilities));
+ EXPECT_FALSE(result);
+ EXPECT_FALSE(channel->LookupCommandBuffer(kRouteId));
}
-TEST_F(GpuChannelTest, RealTimeStreamsAllowed) {
+TEST_F(GpuChannelTest, HighPriorityStreamsAllowed) {
int32_t kClientId = 1;
bool is_gpu_host = true;
GpuChannel* channel = CreateChannel(kClientId, is_gpu_host);
ASSERT_TRUE(channel);
- // Create first context.
- int32_t kRouteId = 1;
- int32_t kStreamId = 1;
- GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME;
+ // REAL_TIME priority is allowed.
+ int32_t kRouteId1 = 1;
GPUCreateCommandBufferConfig init_params;
init_params.surface_handle = kNullSurfaceHandle;
init_params.share_group_id = MSG_ROUTING_NONE;
- init_params.stream_id = kStreamId;
- init_params.stream_priority = kStreamPriority;
+ init_params.stream_id = 1;
+ init_params.stream_priority = GpuStreamPriority::REAL_TIME;
init_params.attribs = gles2::ContextCreationAttribHelper();
init_params.active_url = GURL();
bool result = false;
gpu::Capabilities capabilities;
HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer(
- init_params, kRouteId, GetSharedHandle(), &result,
+ init_params, kRouteId1, GetSharedHandle(), &result,
&capabilities));
EXPECT_TRUE(result);
+ EXPECT_TRUE(channel->LookupCommandBuffer(kRouteId1));
- GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId);
- EXPECT_TRUE(stub);
+ // HIGH priority is allowed.
+ int32_t kRouteId2 = 2;
+ init_params.stream_id = 2;
+ init_params.stream_priority = GpuStreamPriority::HIGH;
+ result = false;
+ HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer(
+ init_params, kRouteId2, GetSharedHandle(), &result,
+ &capabilities));
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(channel->LookupCommandBuffer(kRouteId2));
}
TEST_F(GpuChannelTest, CreateFailsIfSharedContextIsLost) {

Powered by Google App Engine
This is Rietveld 408576698