Skip to content

Commit

Permalink
Fix hang in TestBA shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
robmen committed Feb 29, 2024
1 parent 60ec7ff commit 3b776f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
12 changes: 8 additions & 4 deletions src/test/burn/TestBA/TestBA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected override void OnStartup(StartupEventArgs args)
if (this.action == LaunchAction.Help)
{
this.Log("This is a BA for automated testing");
this.Engine.Quit(0);
this.ShutdownUiThread(0);
return;
}

Expand Down Expand Up @@ -199,10 +199,15 @@ protected override void Run()
this.Engine.Quit(exitCode);
}

private void ShutdownUiThread()
private void ShutdownUiThread(int? exitCode = null)
{
try
{
if (exitCode.HasValue)
{
this.result = exitCode.Value;
}

this.dummyWindow?.Invoke(new Action(Application.ExitThread));
}
catch (Exception e)
Expand Down Expand Up @@ -585,8 +590,7 @@ protected override void OnApplyComplete(ApplyCompleteEventArgs args)
// Output what the privileges are now.
this.Log("After elevation: WixBundleElevated = {0}", this.Engine.GetVariableNumeric("WixBundleElevated"));

this.result = args.Status;
this.ShutdownUiThread();
this.ShutdownUiThread(args.Status);
}

protected override void OnUnregisterBegin(UnregisterBeginEventArgs args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,18 @@ class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions

hr = BalGetRelatedBundleVariable(wzBundleId, STRING_VARIABLE, &wzValue);

ExitOnFailure(hr, "Failed to get related bundle string variable.");

if (wzValue)
{
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: AString = %ws", wzValue);
}
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: AString = %ws, Error: 0x%x", wzValue, hr);

hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue);

if (wzValue)
{
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: ANumber = %ws", wzValue);
}
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: ANumber = %ws, Error: 0x%x", wzValue, hr);

hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel);
LExit:

ReleaseStr(wzValue);
return hr;
}

private:


Expand Down
4 changes: 1 addition & 3 deletions src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Fragment>
<BootstrapperApplication Id="DncAlwaysPrereq" SourceFile="!(bindpath.dncx86)\TestBA.exe" Secondary="true">
<BootstrapperApplication Id="DncAlwaysPrereq" SourceFile="!(bindpath.dncx86)\TestBA.exe">
<Payload SourceFile="!(bindpath.dncx86)\TestBA.deps.json" />
<Payload SourceFile="!(bindpath.dncx86)\TestBA.dll" />
<Payload SourceFile="!(bindpath.dncx86)\TestBA.runtimeconfig.json" />
<Payload SourceFile="!(bindpath.dncx86)\mbanative.dll" />
<Payload SourceFile="!(bindpath.dncx86)\WixToolset.Mba.Core.dll" />
<Payload SourceFile="$(var.PrereqBaf.TargetPath)" bal:BAFunctions="yes" />

<bal:WixPrerequisiteBootstrapperApplication />
</BootstrapperApplication>
</Fragment>

Expand Down

0 comments on commit 3b776f6

Please sign in to comment.