Skip to content

PackageManager tests: wait for activated app to exit; verify RemovePackage result - #6678

Merged
Kyaw Thant (kythant) merged 3 commits into
release/dev/monobuildfrom
user/kythant/foundation-pkgmgr-inuse-testfix
Aug 11, 2026
Merged

Kyaw Thant (kythant) merged 3 commits into
release/dev/monobuildfrom
user/kythant/foundation-pkgmgr-inuse-testfix

Conversation

@kythant

Copy link
Copy Markdown
Contributor

Problem

WinAppSDK-Test-Foundation has regressed sharply — from mostly-green in June to almost always red by August. Nearly every failing run reduces to the PackageManager suite on the x86/x64 images: PackageDeploymentManagerTests_* fail in a cascade with HRESULT 0x80073D02 (ERROR_PACKAGES_IN_USE) — "the package could not be installed because resources it modifies are currently in use."

Root cause: IsPackageRegistrationPending_Pending and IsPackageRegistrationPendingForUser_Pending activate the Test.PackageManager.M.Black app via IApplicationActivationManager::ActivateApplication, then signal it to exit with SetEvent, but never wait for the process to actually terminate. The app keeps its package in use, so the next class's upgrade (M.Black 1.2.3.4 → M.Blacker 2.4.6.8) races the still-running app and fails with 0x80073D02, cascading ClassSetup/ClassCleanup failures across the rest of the suite. The retry added in #6519 fires but genuinely exhausts, because the package is truly still held.

Separately, the shared RemovePackage() helper checked if (!deploymentResult). The DeploymentResult WinRT object is never null, so that branch never fired and every removal failure was silently ignored — leaving packages behind to break the next test's install.

Change

  1. Wait for the activated app to exit. In both _Pending methods, open a SYNCHRONIZE handle to the app right after ActivateApplication, then wil::handle_wait on it after SetEvent. Mirrors the existing pattern in test/AccessControlTests/APITests.cpp, and guarantees the package is released before the next (un)install.
  2. Actually check the removal result. RemovePackage() now uses VERIFY_SUCCEEDED(deploymentResult.ExtendedErrorCode()) instead of the always-false null check.

Validation

Built Foundation from this branch and ran the Foundation TAEF matrix against it across two independent runs:

  • The PackageDeploymentManagerTests 0x80073D02 cascade dropped from 256 failures → 0.
  • RemovePackage() now surfaces removal errors instead of swallowing them; every call in the run logged success (0x0), so the stricter check introduced no new failures.

Follow-up to #6519 (LRP MSIX install-race retries).

…ckage result

IsPackageRegistrationPending_Pending / ...ForUser_Pending activate the M.Black app then signal it to exit but never wait for the process to terminate, so the app keeps its package in use and the next class's Black 1.2.3.4 -> 2.4.6.8 upgrade races it with 0x80073D02 ERROR_PACKAGES_IN_USE, cascading failures across the PackageManager suite. Open a handle to the app process and wait for exit after SetEvent (mirrors AccessControlTests/APITests.cpp).

Also fix RemovePackage(): it checked 'if (!deploymentResult)' (the WinRT result object is never null) so removal failures were silently ignored; verify ExtendedErrorCode() instead.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

…as success

RemovePackage() is an 'ensure absent' cleanup used in many suites' ClassInit (AccessControl::APITests, Deployment::APITests, PackagedTests, OAuth2, ABForward), often on a package that isn't installed. The strict VERIFY_SUCCEEDED added in this PR failed those calls with 0x80073CF1 (ERROR_INSTALL_PACKAGE_NOT_FOUND, 'the current user does not have that package installed'), breaking ClassInit and cascading ~169 failures across the matrix (including downstream 0x800706BE test-host teardown when the framework the out-of-proc host needs never got (re)installed). 'Not installed' is the desired end state of a removal, so treat it as success while still surfacing genuine removal errors like ERROR_PACKAGES_IN_USE.
@kythant
Kyaw Thant (kythant) force-pushed the user/kythant/foundation-pkgmgr-inuse-testfix branch from 45b2692 to c91639b Compare August 10, 2026 18:55
@kythant

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@kythant
Kyaw Thant (kythant) marked this pull request as ready for review August 10, 2026 23:27
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@kythant
Kyaw Thant (kythant) merged commit afe3066 into release/dev/monobuild Aug 11, 2026
49 checks passed
@kythant
Kyaw Thant (kythant) deleted the user/kythant/foundation-pkgmgr-inuse-testfix branch August 11, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants