Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,21 @@ public void DefaultTest()
/// </summary>
/// <param name="leakCOM">Control whether COM should be uninitialized at the end of the process.</param>
/// <param name="unloadBehavior">Set the unload behavior for the test.</param>
/// <param name="workTestSleep">Sets the number of milliseconds to sleep between each work/test iteration.</param>
[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()
{
ActivationType = ActivationType.CoCreateInstance,
LeakCOM = leakCOM,
UnloadBehavior = unloadBehavior,
Iterations = 10,
WorkTestSleepInterval = workTestSleep,
});
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}
}
}
6 changes: 6 additions & 0 deletions src/ComInprocTestbed/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}

Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/ComInprocTestbed/Tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/ComInprocTestbed/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down