Skip to content

Conversation

@OneBlue
Copy link
Collaborator

@OneBlue OneBlue commented Jan 24, 2026

Summary of the Pull Request

This change updates the WSLA test logic to reuse the same session whenever possible, significantly speeding up the tests

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@OneBlue OneBlue requested a review from a team as a code owner January 24, 2026 02:49
Copilot AI review requested due to automatic review settings January 24, 2026 02:49
static inline auto Type = LxMessageWSLAError;
MESSAGE_HEADER Header;
int Errno;
int Errno{};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While testing this, I discovered an uninitialized field in the WSLA_PROCESS_EXITED message, which could incorrectly report that a process was signaled.

Moving forward, let's just always initialize all message fields to prevent this

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to speed up WSLA Windows unit tests by reusing a single default WSLA session across test methods, reducing repeated VM/session initialization overhead.

Changes:

  • Introduces a long-lived defaultSession and refactors many tests to reuse it instead of creating per-test sessions.
  • Adds session/settings helpers (GetDefaultSessionSettings(...), OpenSessionManager(), CloseTestSession()) and extends process-output helpers with optional timeouts.
  • Initializes several WSLA message struct fields to {} in lxinitshared.h to avoid uninitialized data.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
test/windows/WSLATests.cpp Reworks test setup and many test cases to reuse a default session; adds helper utilities and timeout support.
src/shared/inc/lxinitshared.h Adds default member initialization for various WSLA message fields.
Comments suppressed due to low confidence (1)

test/windows/WSLATests.cpp:137

  • OpenSessionManager() was introduced, but CreateSession() still duplicates the same CoCreateInstance + COM impersonation setup. Consider using OpenSessionManager() inside CreateSession() to keep session-manager initialization consistent and reduce duplicated logic.
    wil::com_ptr<IWSLASession> CreateSession(const WSLA_SESSION_SETTINGS& sessionSettings, WSLASessionFlags Flags = WSLASessionFlagsNone)
    {
        wil::com_ptr<IWSLASessionManager> sessionManager;
        VERIFY_SUCCEEDED(CoCreateInstance(__uuidof(WSLASessionManager), nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&sessionManager)));
        wsl::windows::common::security::ConfigureForCOMImpersonation(sessionManager.get());

{
// TODO: refactor this to avoid using wsl config
static wsl::core::Config config(nullptr);
wsl::core::Config config(nullptr);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing all VM's to try to use the same IP address. We should refactor this in the long run, but for now fixed by making sure that configs aren't shared accross sessions

}

wil::com_ptr<IWSLASession> CreateSession(const WSLA_SESSION_SETTINGS& sessionSettings = GetDefaultSessionSettings(), WSLASessionFlags Flags = WSLASessionFlagsNone)
auto CloseTestSession()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this creates a new line, should this be called ResetTestSession?

@OneBlue OneBlue merged commit 70148b7 into feature/wsl-for-apps Jan 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants