diff --git a/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs b/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
index 75320de0a2..c414474f86 100644
--- a/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
+++ b/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
@@ -98,12 +98,13 @@ public void DefaultTest()
///
/// Control whether COM should be uninitialized at the end of the process.
/// Set the unload behavior for the test.
+ /// Sets the number of milliseconds to sleep between each work/test iteration.
[Test]
[TestCase(false, UnloadBehavior.AtUninitialize)]
[TestCase(false, UnloadBehavior.Never)]
- [TestCase(true, UnloadBehavior.Allow)]
+ [TestCase(true, UnloadBehavior.Allow, 1000)]
[TestCase(true, UnloadBehavior.Never)]
- public void CLSID_Tests(bool leakCOM, UnloadBehavior unloadBehavior)
+ public void CLSID_Tests(bool leakCOM, UnloadBehavior unloadBehavior, int? workTestSleep = null)
{
this.RunInprocTestbed(new TestbedParameters()
{
@@ -111,6 +112,7 @@ public void CLSID_Tests(bool leakCOM, UnloadBehavior unloadBehavior)
LeakCOM = leakCOM,
UnloadBehavior = unloadBehavior,
Iterations = 10,
+ WorkTestSleepInterval = workTestSleep,
});
}
@@ -175,6 +177,11 @@ private void RunInprocTestbed(TestbedParameters parameters, int timeout = 300000
builtParameters += $"-itr {parameters.Iterations} ";
}
+ if (parameters.WorkTestSleepInterval != null)
+ {
+ builtParameters += $"-work-test-sleep {parameters.WorkTestSleepInterval} ";
+ }
+
var result = TestCommon.RunProcess(this.InprocTestbedPath, this.TargetPackageInformation, builtParameters, null, timeout, true);
Assert.AreEqual(0, result.ExitCode);
}
@@ -195,6 +202,8 @@ private class TestbedParameters
internal string Test { get; init; } = "unload_check";
internal int? Iterations { get; init; } = null;
+
+ internal int? WorkTestSleepInterval { get; init; } = null;
}
}
}
diff --git a/src/ComInprocTestbed/Tests.cpp b/src/ComInprocTestbed/Tests.cpp
index 0291b2a127..8244403f15 100644
--- a/src/ComInprocTestbed/Tests.cpp
+++ b/src/ComInprocTestbed/Tests.cpp
@@ -246,6 +246,11 @@ TestParameters::TestParameters(int argc, const char** argv)
{
SkipClearFactories = true;
}
+ else if ("-work-test-sleep"sv == argv[i])
+ {
+ ADVANCE_ARG_PARAMETER
+ WorkTestSleepInterval = atoi(argv[i]);
+ }
}
}
@@ -259,6 +264,7 @@ void TestParameters::OutputDetails() const
" Unload : " << UnloadBehavior << "\n"
" Expect : " << std::boolalpha << UnloadExpected() << "\n"
" Test : " << TestToRun << "\n"
+ " Sleep : " << WorkTestSleepInterval << "\n"
" Package : " << PackageName << "\n"
" Source : " << SourceName << "\n"
" URL : " << SourceURL << "\n"
diff --git a/src/ComInprocTestbed/Tests.h b/src/ComInprocTestbed/Tests.h
index 1443887202..5e8afc0682 100644
--- a/src/ComInprocTestbed/Tests.h
+++ b/src/ComInprocTestbed/Tests.h
@@ -74,6 +74,7 @@ struct TestParameters
UnloadBehavior UnloadBehavior = UnloadBehavior::Allow;
ActivationType ActivationType = ActivationType::ClassName;
bool SkipClearFactories = false;
+ DWORD WorkTestSleepInterval = 0;
};
// Captures a snapshot of current resource usage.
diff --git a/src/ComInprocTestbed/main.cpp b/src/ComInprocTestbed/main.cpp
index 84cee642d8..50512a2e9a 100644
--- a/src/ComInprocTestbed/main.cpp
+++ b/src/ComInprocTestbed/main.cpp
@@ -31,6 +31,11 @@ int main(int argc, const char** argv) try
winrt::clear_factory_cache();
}
+ if (testParameters.WorkTestSleepInterval)
+ {
+ Sleep(testParameters.WorkTestSleepInterval);
+ }
+
if (test && !test->RunIterationTest())
{
return 4;