-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Optimize the WSLA unit tests #14107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize the WSLA unit tests #14107
Conversation
| static inline auto Type = LxMessageWSLAError; | ||
| MESSAGE_HEADER Header; | ||
| int Errno; | ||
| int Errno{}; |
There was a problem hiding this comment.
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
There was a problem hiding this 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
defaultSessionand 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
{}inlxinitshared.hto 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, butCreateSession()still duplicates the same CoCreateInstance + COM impersonation setup. Consider usingOpenSessionManager()insideCreateSession()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); |
There was a problem hiding this comment.
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
test/windows/WSLATests.cpp
Outdated
| } | ||
|
|
||
| wil::com_ptr<IWSLASession> CreateSession(const WSLA_SESSION_SETTINGS& sessionSettings = GetDefaultSessionSettings(), WSLASessionFlags Flags = WSLASessionFlagsNone) | ||
| auto CloseTestSession() |
There was a problem hiding this comment.
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?
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
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed