|
1 | 1 | /* |
2 | | - * Copyright (C) 2018-2020 Intel Corporation |
| 2 | + * Copyright (C) 2018-2021 Intel Corporation |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | * |
@@ -1175,6 +1175,180 @@ HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadWhenSettingFlagProgress |
1175 | 1175 | EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue"))); |
1176 | 1176 | } |
1177 | 1177 |
|
| 1178 | +HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadBeforeWalkerOnlyWhenSettingFlagProgressThenFunctionAsksOnceForConfirmation) { |
| 1179 | + DebugManagerStateRestore restore; |
| 1180 | + DebugManager.flags.PauseOnEnqueue.set(0); |
| 1181 | + DebugManager.flags.PauseOnGpuMode.set(0); |
| 1182 | + testing::internal::CaptureStdout(); |
| 1183 | + int32_t executionStamp = 0; |
| 1184 | + auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); |
| 1185 | + |
| 1186 | + uint32_t confirmationCounter = 0; |
| 1187 | + |
| 1188 | + mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() { |
| 1189 | + EXPECT_EQ(0u, confirmationCounter); |
| 1190 | + EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress); |
| 1191 | + confirmationCounter++; |
| 1192 | + }; |
| 1193 | + |
| 1194 | + pDevice->resetCommandStreamReceiver(mockCSR); |
| 1195 | + |
| 1196 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation; |
| 1197 | + |
| 1198 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation) |
| 1199 | + ; |
| 1200 | + |
| 1201 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1202 | + |
| 1203 | + EXPECT_EQ(1u, confirmationCounter); |
| 1204 | + |
| 1205 | + auto output = testing::internal::GetCapturedStdout(); |
| 1206 | + EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Press enter to start workload"))); |
| 1207 | + EXPECT_THAT(output, testing::Not(testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue")))); |
| 1208 | +} |
| 1209 | + |
| 1210 | +HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadAfterWalkerOnlyWhenSettingFlagProgressThenFunctionAsksOnceForConfirmation) { |
| 1211 | + DebugManagerStateRestore restore; |
| 1212 | + DebugManager.flags.PauseOnEnqueue.set(0); |
| 1213 | + DebugManager.flags.PauseOnGpuMode.set(1); |
| 1214 | + testing::internal::CaptureStdout(); |
| 1215 | + int32_t executionStamp = 0; |
| 1216 | + auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); |
| 1217 | + |
| 1218 | + uint32_t confirmationCounter = 0; |
| 1219 | + |
| 1220 | + mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() { |
| 1221 | + EXPECT_EQ(0u, confirmationCounter); |
| 1222 | + EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress); |
| 1223 | + confirmationCounter++; |
| 1224 | + }; |
| 1225 | + |
| 1226 | + pDevice->resetCommandStreamReceiver(mockCSR); |
| 1227 | + |
| 1228 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1229 | + |
| 1230 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation) |
| 1231 | + ; |
| 1232 | + |
| 1233 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1234 | + |
| 1235 | + EXPECT_EQ(1u, confirmationCounter); |
| 1236 | + |
| 1237 | + auto output = testing::internal::GetCapturedStdout(); |
| 1238 | + EXPECT_THAT(output, testing::Not(testing::HasSubstr(std::string("Debug break: Press enter to start workload")))); |
| 1239 | + EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue"))); |
| 1240 | +} |
| 1241 | + |
| 1242 | +HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadOnEachEnqueueWhenSettingFlagProgressThenFunctionAsksMultipleTimesForConfirmation) { |
| 1243 | + DebugManagerStateRestore restore; |
| 1244 | + DebugManager.flags.PauseOnEnqueue.set(-2); |
| 1245 | + testing::internal::CaptureStdout(); |
| 1246 | + int32_t executionStamp = 0; |
| 1247 | + auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); |
| 1248 | + |
| 1249 | + uint32_t confirmationCounter = 0; |
| 1250 | + |
| 1251 | + mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() { |
| 1252 | + if (confirmationCounter == 0) { |
| 1253 | + EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress); |
| 1254 | + confirmationCounter++; |
| 1255 | + } else if (confirmationCounter == 1) { |
| 1256 | + EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress); |
| 1257 | + confirmationCounter++; |
| 1258 | + } else if (confirmationCounter == 2) { |
| 1259 | + EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress); |
| 1260 | + confirmationCounter++; |
| 1261 | + } else if (confirmationCounter == 3) { |
| 1262 | + EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress); |
| 1263 | + confirmationCounter++; |
| 1264 | + DebugManager.flags.PauseOnEnqueue.set(-1); |
| 1265 | + } |
| 1266 | + }; |
| 1267 | + |
| 1268 | + pDevice->resetCommandStreamReceiver(mockCSR); |
| 1269 | + |
| 1270 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation; |
| 1271 | + |
| 1272 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation) |
| 1273 | + ; |
| 1274 | + |
| 1275 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1276 | + |
| 1277 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation) |
| 1278 | + ; |
| 1279 | + |
| 1280 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation; |
| 1281 | + |
| 1282 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation) |
| 1283 | + ; |
| 1284 | + |
| 1285 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1286 | + |
| 1287 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation) |
| 1288 | + ; |
| 1289 | + |
| 1290 | + EXPECT_EQ(4u, confirmationCounter); |
| 1291 | + |
| 1292 | + auto output = testing::internal::GetCapturedStdout(); |
| 1293 | + EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Press enter to start workload"))); |
| 1294 | + EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue"))); |
| 1295 | +} |
| 1296 | + |
| 1297 | +HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadOnEachBlitWhenSettingFlagProgressThenFunctionAsksMultipleTimesForConfirmation) { |
| 1298 | + DebugManagerStateRestore restore; |
| 1299 | + DebugManager.flags.PauseOnBlitCopy.set(-2); |
| 1300 | + testing::internal::CaptureStdout(); |
| 1301 | + int32_t executionStamp = 0; |
| 1302 | + auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); |
| 1303 | + |
| 1304 | + uint32_t confirmationCounter = 0; |
| 1305 | + |
| 1306 | + mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() { |
| 1307 | + if (confirmationCounter == 0) { |
| 1308 | + EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress); |
| 1309 | + confirmationCounter++; |
| 1310 | + } else if (confirmationCounter == 1) { |
| 1311 | + EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress); |
| 1312 | + confirmationCounter++; |
| 1313 | + } else if (confirmationCounter == 2) { |
| 1314 | + EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress); |
| 1315 | + confirmationCounter++; |
| 1316 | + } else if (confirmationCounter == 3) { |
| 1317 | + EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress); |
| 1318 | + confirmationCounter++; |
| 1319 | + DebugManager.flags.PauseOnBlitCopy.set(-1); |
| 1320 | + } |
| 1321 | + }; |
| 1322 | + |
| 1323 | + pDevice->resetCommandStreamReceiver(mockCSR); |
| 1324 | + |
| 1325 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation; |
| 1326 | + |
| 1327 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation) |
| 1328 | + ; |
| 1329 | + |
| 1330 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1331 | + |
| 1332 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation) |
| 1333 | + ; |
| 1334 | + |
| 1335 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation; |
| 1336 | + |
| 1337 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation) |
| 1338 | + ; |
| 1339 | + |
| 1340 | + *mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation; |
| 1341 | + |
| 1342 | + while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation) |
| 1343 | + ; |
| 1344 | + |
| 1345 | + EXPECT_EQ(4u, confirmationCounter); |
| 1346 | + |
| 1347 | + auto output = testing::internal::GetCapturedStdout(); |
| 1348 | + EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Press enter to start workload"))); |
| 1349 | + EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue"))); |
| 1350 | +} |
| 1351 | + |
1178 | 1352 | HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadWhenTerminatingAtFirstStageThenFunctionEndsCorrectly) { |
1179 | 1353 | DebugManagerStateRestore restore; |
1180 | 1354 | DebugManager.flags.PauseOnEnqueue.set(0); |
|
0 commit comments