Fix image leaks in the tests causing failures in "WslcSdkTests::ImageProgressCallback" (#40888)
* Save state * Save state
Blue committed
Jun 24, 2026 at 12:20 UTC
9361ff01f3b193bcf41cf77434e8fd20f4080f08
2 files changed
+10
test/windows/WslcSdkTests.cpp
+6
@@ -2299,6 +2299,9 @@ class WslcSdkTests
2299
2300
auto image = std::format("{}/hello-world:latest", registryAddress);
2301
2302
+ auto imageCleanup = wil::scope_exit_log(
2303
+ WI_DIAGNOSTICS_INFO, [&]() { LOG_IF_FAILED(WslcDeleteSessionImage(m_defaultSession, image.c_str(), nullptr)); });
2304
+
2305
// Pulling with credentials should succeed.
2306
{
2307
WslcPullImageOptions opts{};
@@ -2353,6 +2356,9 @@ class WslcSdkTests
2356
2357
auto image = std::format("{}/hello-world:latest", registryAddress);
2358
2359
+ auto imageCleanup = wil::scope_exit_log(
2360
+ WI_DIAGNOSTICS_INFO, [&]() { LOG_IF_FAILED(WslcDeleteSessionImage(m_defaultSession, image.c_str(), nullptr)); });
2361
+
2362
// Delete the image locally so the pull is a real pull.
2363
WslcDeleteSessionImage(m_defaultSession, image.c_str(), nullptr);
2364
test/windows/WslcSdkWinRTTests.cpp
+4
@@ -1596,6 +1596,8 @@ class WslcSdkWinRtTests
1596
1597
const auto image = winrt::to_hstring(std::format("{}/hello-world:latest", registryAddress));
1598
1599
+ auto cleanup = SCOPE_CLEANUP(m_defaultSession.DeleteImage(image));
1600
+
1601
// Positive: pulling with correct credentials must succeed.
1602
{
1603
auto opts = WSLCSDK::PullImageOptions(image);
@@ -1628,6 +1630,8 @@ class WslcSdkWinRtTests
1630
1631
const auto image = winrt::to_hstring(std::format("{}/hello-world:latest", registryAddress));
1632
1633
+ auto imageCleanup = SCOPE_CLEANUP(m_defaultSession.DeleteImage(image));
1634
+
1635
// Delete the image locally so the pull is a real network pull.
1636
IGNORE_ERRORS(m_defaultSession.DeleteImage(image));
1637