Browse Source

Increase wait time for processing loop in unit test to avoid spurious failure on slow CPUs

Signed-off-by: amzn-mike <[email protected]>
amzn-mike 3 years ago
parent
commit
01685443bd

+ 8 - 4
Code/Tools/AssetProcessor/native/unittests/RCcontrollerUnitTests.cpp

@@ -130,6 +130,7 @@ void RCcontrollerUnitTests::PrepareRCController()
 
 
 void RCcontrollerUnitTests::RunRCControllerTests()
 void RCcontrollerUnitTests::RunRCControllerTests()
 {
 {
+    static constexpr int MaxProcessingWaitTimeMs = 60 * 1000; // Wait up to 1 minute.  Give a generous amount of time to allow for slow CPUs
     int jobsInQueueCount = 0;
     int jobsInQueueCount = 0;
     QString platformInQueueCount;
     QString platformInQueueCount;
     bool gotJobsInQueueCall = false;
     bool gotJobsInQueueCall = false;
@@ -543,7 +544,10 @@ void RCcontrollerUnitTests::RunRCControllerTests()
     // on windows, opening a file for reading locks it
     // on windows, opening a file for reading locks it
     // but on other platforms, this is not the case.
     // but on other platforms, this is not the case.
     // we only expect work to begin when we can gain an exclusive lock on this file.
     // we only expect work to begin when we can gain an exclusive lock on this file.
-    UNIT_TEST_EXPECT_FALSE(UnitTestUtils::BlockUntil(beginWork, 500));
+
+    // Use a short wait time here because the test will have to wait this entire time to detect the failure
+    static constexpr int WaitTimeMs = 500;
+    UNIT_TEST_EXPECT_FALSE(UnitTestUtils::BlockUntil(beginWork, WaitTimeMs));
 
 
     // Once we release the file, it should process normally
     // Once we release the file, it should process normally
     lockFileTest.close();
     lockFileTest.close();
@@ -552,7 +556,7 @@ void RCcontrollerUnitTests::RunRCControllerTests()
 #endif
 #endif
 
 
     //Once we release the lock we should see jobStarted and jobFinished
     //Once we release the lock we should see jobStarted and jobFinished
-    UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(jobFinished, 500));
+    UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(jobFinished, MaxProcessingWaitTimeMs));
     UNIT_TEST_EXPECT_TRUE(beginWork);
     UNIT_TEST_EXPECT_TRUE(beginWork);
     UNIT_TEST_EXPECT_TRUE(rcJob.m_DoWorkCalled);
     UNIT_TEST_EXPECT_TRUE(rcJob.m_DoWorkCalled);
 
 
@@ -690,7 +694,7 @@ void RCcontrollerUnitTests::RunRCControllerTests()
     m_rcController.SetDispatchPaused(false);
     m_rcController.SetDispatchPaused(false);
 
 
     m_rcController.DispatchJobs();
     m_rcController.DispatchJobs();
-    UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(allJobsCompleted, 500));
+    UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(allJobsCompleted, MaxProcessingWaitTimeMs));
     UNIT_TEST_EXPECT_TRUE(jobFinishedB);
     UNIT_TEST_EXPECT_TRUE(jobFinishedB);
 
 
     // Now test the use case where we have a cyclic dependency,
     // Now test the use case where we have a cyclic dependency,
@@ -745,7 +749,7 @@ void RCcontrollerUnitTests::RunRCControllerTests()
 
 
     m_rcController.SetDispatchPaused(false);
     m_rcController.SetDispatchPaused(false);
     m_rcController.DispatchJobs();
     m_rcController.DispatchJobs();
-    UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(allJobsCompleted, 500));
+    UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(allJobsCompleted, MaxProcessingWaitTimeMs));
 
 
     // Test case when source file is deleted before it started processing
     // Test case when source file is deleted before it started processing
     {
     {