-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathWslcSdkTests.cpp
More file actions
2024 lines (1641 loc) · 90.4 KB
/
WslcSdkTests.cpp
File metadata and controls
2024 lines (1641 loc) · 90.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*++
Copyright (c) Microsoft. All rights reserved.
Module Name:
WslcSdkTests.cpp
Abstract:
This file contains test cases for the WSLC SDK.
--*/
#include "precomp.h"
#include "Common.h"
#include "wslcsdk.h"
#include "wslc_schema.h"
#include "e2e/WSLCExecutor.h"
#include <optional>
extern std::wstring g_testDataPath;
extern bool g_fastTestRun;
using namespace std::chrono_literals;
namespace {
//
// RAII guards for opaque WSLC handle types.
//
void CloseSession(WslcSession session)
{
if (session)
{
WslcTerminateSession(session);
WslcReleaseSession(session);
}
}
using UniqueSession = wil::unique_any<WslcSession, decltype(CloseSession), CloseSession>;
void ReleaseSession(WslcSession session)
{
if (session)
{
WslcReleaseSession(session);
}
}
using UniqueSessionRef = wil::unique_any<WslcSession, decltype(ReleaseSession), ReleaseSession>;
void CloseContainer(WslcContainer container)
{
if (container)
{
WslcStopContainer(container, WSLC_SIGNAL_SIGKILL, 0, nullptr);
WslcDeleteContainer(container, WSLC_DELETE_CONTAINER_FLAG_NONE, nullptr);
WslcReleaseContainer(container);
}
}
using UniqueContainer = wil::unique_any<WslcContainer, decltype(CloseContainer), CloseContainer>;
void CloseProcess(WslcProcess process)
{
if (process)
{
WslcReleaseProcess(process);
}
}
using UniqueProcess = wil::unique_any<WslcProcess, decltype(CloseProcess), CloseProcess>;
struct ProcessOutput
{
std::string stdoutOutput;
std::string stderrOutput;
};
ProcessOutput WaitForProcessOutput(WslcProcess process, std::chrono::milliseconds timeout = 2min)
{
// Borrow the exit-event handle (lifetime tied to the process object; do NOT close it).
HANDLE exitEvent = nullptr;
THROW_IF_FAILED(WslcGetProcessExitEvent(process, &exitEvent));
// Acquire stdout / stderr pipe handles (caller owns these).
wil::unique_handle ownedStdout;
THROW_IF_FAILED(WslcGetProcessIOHandle(process, WSLC_PROCESS_IO_HANDLE_STDOUT, &ownedStdout));
wil::unique_handle ownedStderr;
THROW_IF_FAILED(WslcGetProcessIOHandle(process, WSLC_PROCESS_IO_HANDLE_STDERR, &ownedStderr));
// Read stdout / stderr concurrently so that full pipe buffers do not stall the process.
ProcessOutput output;
wsl::windows::common::relay::MultiHandleWait io;
io.AddHandle(std::make_unique<wsl::windows::common::relay::ReadHandle>(
std::move(ownedStdout), [&](const auto& buffer) { output.stdoutOutput.append(buffer.data(), buffer.size()); }));
io.AddHandle(std::make_unique<wsl::windows::common::relay::ReadHandle>(
std::move(ownedStderr), [&](const auto& buffer) { output.stderrOutput.append(buffer.data(), buffer.size()); }));
auto timeoutTime = std::chrono::steady_clock::now() + timeout;
io.Run(timeout);
auto remaining = timeoutTime - std::chrono::steady_clock::now();
if (remaining < 0ns)
{
remaining = {};
}
// Check that the process exits within the timeout.
THROW_HR_IF(
HRESULT_FROM_WIN32(WAIT_TIMEOUT),
WaitForSingleObject(exitEvent, static_cast<DWORD>(std::chrono::duration_cast<std::chrono::milliseconds>(remaining).count())) != WAIT_OBJECT_0);
return output;
}
//
// Runs a container with the given argv, waits up to timeoutMs for it to exit,
// and returns the captured stdout / stderr output.
//
ProcessOutput RunContainerAndCapture(WslcSession session, const WslcContainerSettings& containerSettings, std::chrono::milliseconds timeout = 2min)
{
// Create and start the container.
UniqueContainer container;
THROW_IF_FAILED(WslcCreateContainer(session, &containerSettings, &container, nullptr));
THROW_IF_FAILED(WslcStartContainer(container.get(), WSLC_CONTAINER_START_FLAG_ATTACH, nullptr));
// Acquire the init process handle.
UniqueProcess process;
THROW_IF_FAILED(WslcGetContainerInitProcess(container.get(), &process));
return WaitForProcessOutput(process.get());
}
ProcessOutput RunContainerAndCapture(
WslcSession session,
const char* image,
const std::vector<const char*>& argv,
WslcContainerFlags flags = WSLC_CONTAINER_FLAG_NONE,
const char* name = nullptr,
std::chrono::milliseconds timeout = 2min,
std::optional<WslcContainerNetworkingMode> networkingMode = std::nullopt)
{
// Build process settings.
WslcProcessSettings procSettings;
THROW_IF_FAILED(WslcInitProcessSettings(&procSettings));
if (!argv.empty())
{
THROW_IF_FAILED(WslcSetProcessSettingsCmdLine(&procSettings, argv.data(), argv.size()));
}
// Build container settings.
WslcContainerSettings containerSettings;
THROW_IF_FAILED(WslcInitContainerSettings(image, &containerSettings));
THROW_IF_FAILED(WslcSetContainerSettingsInitProcess(&containerSettings, &procSettings));
THROW_IF_FAILED(WslcSetContainerSettingsFlags(&containerSettings, flags));
if (name)
{
THROW_IF_FAILED(WslcSetContainerSettingsName(&containerSettings, name));
}
if (networkingMode.has_value())
{
THROW_IF_FAILED(WslcSetContainerSettingsNetworkingMode(&containerSettings, *networkingMode));
}
return RunContainerAndCapture(session, containerSettings, timeout);
}
} // namespace
class WslcSdkTests
{
WSLC_TEST_CLASS(WslcSdkTests)
wil::unique_mta_usage_cookie m_mtaCookie;
WSADATA m_wsadata;
std::filesystem::path m_storagePath;
WslcSession m_defaultSession = nullptr;
static inline auto c_testSessionName = L"wslc-test";
void LoadTestImage(std::string_view imageName)
{
std::filesystem::path imagePath = GetTestImagePath(imageName);
THROW_IF_FAILED(WslcLoadSessionImageFromFile(m_defaultSession, imagePath.c_str(), nullptr, nullptr));
}
TEST_CLASS_SETUP(TestClassSetup)
{
THROW_IF_FAILED(CoIncrementMTAUsage(&m_mtaCookie));
THROW_IF_WIN32_ERROR(WSAStartup(MAKEWORD(2, 2), &m_wsadata));
// Use the same storage path as WSLC runtime tests to reduce pull overhead.
m_storagePath = std::filesystem::current_path() / "test-storage";
// Build session settings using the WSLC SDK.
WslcSessionSettings sessionSettings;
VERIFY_SUCCEEDED(WslcInitSessionSettings(c_testSessionName, m_storagePath.c_str(), &sessionSettings));
VERIFY_SUCCEEDED(WslcSetSessionSettingsCpuCount(&sessionSettings, 4));
VERIFY_SUCCEEDED(WslcSetSessionSettingsMemory(&sessionSettings, 2048));
VERIFY_SUCCEEDED(WslcSetSessionSettingsTimeout(&sessionSettings, 30 * 1000));
WslcVhdRequirements vhdReqs{};
vhdReqs.sizeInBytes = 4096ull * 1024 * 1024; // 4 GB
vhdReqs.type = WSLC_VHD_TYPE_DYNAMIC;
VERIFY_SUCCEEDED(WslcSetSessionSettingsVhd(&sessionSettings, &vhdReqs));
VERIFY_SUCCEEDED(WslcCreateSession(&sessionSettings, &m_defaultSession, nullptr));
// Pull images required by the tests (no-op if already present).
for (const char* image : {"debian:latest", "python:3.12-alpine"})
{
LoadTestImage(image);
}
return true;
}
TEST_CLASS_CLEANUP(TestClassCleanup)
{
if (m_defaultSession)
{
WslcTerminateSession(m_defaultSession);
WslcReleaseSession(m_defaultSession);
m_defaultSession = nullptr;
}
// Preserve the VHD in fast-run mode so subsequent runs skip image pulling.
if (!g_fastTestRun && !m_storagePath.empty())
{
std::error_code error;
std::filesystem::remove_all(m_storagePath, error);
if (error)
{
LogError("Failed to cleanup storage path %ws: %hs", m_storagePath.c_str(), error.message().c_str());
}
}
return true;
}
// -----------------------------------------------------------------------
// Session tests
// -----------------------------------------------------------------------
WSLC_TEST_METHOD(CreateSession)
{
std::filesystem::path extraStorage = m_storagePath / "wslc-extra-session-storage";
WslcSessionSettings sessionSettings;
VERIFY_SUCCEEDED(WslcInitSessionSettings(L"wslc-extra-session", extraStorage.c_str(), &sessionSettings));
VERIFY_SUCCEEDED(WslcSetSessionSettingsCpuCount(&sessionSettings, 2));
VERIFY_SUCCEEDED(WslcSetSessionSettingsMemory(&sessionSettings, 1024));
VERIFY_SUCCEEDED(WslcSetSessionSettingsTimeout(&sessionSettings, 30 * 1000));
WslcVhdRequirements vhdReqs{};
vhdReqs.sizeInBytes = 1024ull * 1024 * 1024; // 1 GB
vhdReqs.type = WSLC_VHD_TYPE_DYNAMIC;
VERIFY_SUCCEEDED(WslcSetSessionSettingsVhd(&sessionSettings, &vhdReqs));
UniqueSession session;
VERIFY_SUCCEEDED(WslcCreateSession(&sessionSettings, &session, nullptr));
VERIFY_IS_NOT_NULL(session.get());
// Null output pointer must fail.
VERIFY_ARE_EQUAL(WslcCreateSession(&sessionSettings, nullptr, nullptr), E_POINTER);
// Null settings pointer must fail.
UniqueSession session2;
VERIFY_ARE_EQUAL(WslcCreateSession(nullptr, &session2, nullptr), E_POINTER);
}
WSLC_TEST_METHOD(GetCliSession)
{
// Null output pointer must fail.
VERIFY_ARE_EQUAL(WslcGetCliSession(nullptr, nullptr), E_POINTER);
// Ensure no CLI session is running.
WSLCE2ETests::RunWslc(L"session terminate");
// WslcGetCliSession must return ERROR_NOT_FOUND when no CLI session exists.
UniqueSessionRef notFoundSession;
VERIFY_ARE_EQUAL(WslcGetCliSession(¬FoundSession, nullptr), HRESULT_FROM_WIN32(ERROR_NOT_FOUND));
VERIFY_IS_NULL(notFoundSession.get());
// Start the CLI session by running a wslc command.
auto result = WSLCE2ETests::RunWslc(L"container list");
VERIFY_ARE_EQUAL(result.ExitCode.value(), (DWORD)0);
// Now WslcGetCliSession should find the running CLI session.
UniqueSessionRef foundSession;
VERIFY_SUCCEEDED(WslcGetCliSession(&foundSession, nullptr));
VERIFY_IS_NOT_NULL(foundSession.get());
}
WSLC_TEST_METHOD(TerminationCallbackViaTerminate)
{
std::promise<WslcSessionTerminationReason> promise;
auto callback = [](WslcSessionTerminationReason reason, PVOID context) {
auto* p = static_cast<std::promise<WslcSessionTerminationReason>*>(context);
p->set_value(reason);
};
std::filesystem::path extraStorage = m_storagePath / "wslc-termcb-term-storage";
WslcSessionSettings sessionSettings;
VERIFY_SUCCEEDED(WslcInitSessionSettings(L"wslc-termcb-term-test", extraStorage.c_str(), &sessionSettings));
VERIFY_SUCCEEDED(WslcSetSessionSettingsTimeout(&sessionSettings, 30 * 1000));
VERIFY_SUCCEEDED(WslcSetSessionSettingsTerminationCallback(&sessionSettings, callback, &promise));
UniqueSession session;
VERIFY_SUCCEEDED(WslcCreateSession(&sessionSettings, &session, nullptr));
// Terminating the session should trigger a graceful shutdown and fire the callback.
VERIFY_SUCCEEDED(WslcTerminateSession(session.get()));
auto future = promise.get_future();
VERIFY_ARE_EQUAL(future.wait_for(std::chrono::seconds(30)), std::future_status::ready);
VERIFY_ARE_EQUAL(future.get(), WSLC_SESSION_TERMINATION_REASON_SHUTDOWN);
}
WSLC_TEST_METHOD(TerminationCallbackViaRelease)
{
std::promise<WslcSessionTerminationReason> promise;
auto callback = [](WslcSessionTerminationReason reason, PVOID context) {
auto* p = static_cast<std::promise<WslcSessionTerminationReason>*>(context);
p->set_value(reason);
};
std::filesystem::path extraStorage = m_storagePath / "wslc-termcb-release-storage";
WslcSessionSettings sessionSettings;
VERIFY_SUCCEEDED(WslcInitSessionSettings(L"wslc-termcb-release-test", extraStorage.c_str(), &sessionSettings));
VERIFY_SUCCEEDED(WslcSetSessionSettingsTimeout(&sessionSettings, 30 * 1000));
VERIFY_SUCCEEDED(WslcSetSessionSettingsTerminationCallback(&sessionSettings, callback, &promise));
UniqueSession session;
VERIFY_SUCCEEDED(WslcCreateSession(&sessionSettings, &session, nullptr));
// Releasing the session should trigger a graceful shutdown and fire the callback.
VERIFY_SUCCEEDED(WslcReleaseSession(session.get()));
// Calling WslcSessionRelease will destroy the session
session.release();
auto future = promise.get_future();
VERIFY_ARE_EQUAL(future.wait_for(std::chrono::seconds(30)), std::future_status::ready);
VERIFY_ARE_EQUAL(future.get(), WSLC_SESSION_TERMINATION_REASON_SHUTDOWN);
}
// -----------------------------------------------------------------------
// Image tests
// -----------------------------------------------------------------------
WSLC_TEST_METHOD(PullImage)
{
// Positive: pull a well-known image.
{
WslcPullImageOptions opts{};
opts.uri = "hello-world:linux";
wil::unique_cotaskmem_string errorMsg;
HRESULT pullResult = WslcPullSessionImage(m_defaultSession, &opts, &errorMsg);
// Skip test if error is due to rate limit.
if (pullResult == E_FAIL)
{
if (errorMsg)
{
if (wcsstr(errorMsg.get(), L"toomanyrequests") != nullptr)
{
LogWarning("Skipping PullImage test due to rate limiting.");
return;
}
}
}
VERIFY_SUCCEEDED(pullResult);
// Verify the image is usable by running a container from it.
auto output = RunContainerAndCapture(m_defaultSession, "hello-world:linux", {});
VERIFY_IS_TRUE(output.stdoutOutput.find("Hello from Docker!") != std::string::npos);
}
// Negative: pull an image that does not exist.
{
WslcPullImageOptions opts{};
opts.uri = "does-not:exist";
wil::unique_cotaskmem_string errorMsg;
VERIFY_ARE_EQUAL(WslcPullSessionImage(m_defaultSession, &opts, &errorMsg), WSLC_E_IMAGE_NOT_FOUND);
// An error message should be present.
VERIFY_IS_NOT_NULL(errorMsg.get());
}
// Negative: null options pointer must fail.
{
wil::unique_cotaskmem_string errorMsg;
VERIFY_ARE_EQUAL(WslcPullSessionImage(m_defaultSession, nullptr, &errorMsg), E_POINTER);
}
// Negative: null URI inside options must fail.
{
WslcPullImageOptions opts{};
opts.uri = nullptr;
VERIFY_ARE_EQUAL(WslcPullSessionImage(m_defaultSession, &opts, nullptr), E_INVALIDARG);
}
}
WSLC_TEST_METHOD(ImageList)
{
// Positive: session has images pre-loaded — list must return at least one entry.
{
WslcImageInfo* images = nullptr;
uint32_t count = 0;
VERIFY_SUCCEEDED(WslcListSessionImages(m_defaultSession, &images, &count));
auto cleanupImages = wil::scope_exit([images]() { CoTaskMemFree(images); });
VERIFY_IS_TRUE(count >= 1);
VERIFY_IS_NOT_NULL(images);
// At least one image must have a non-empty name.
bool foundNonEmpty = false;
for (uint32_t i = 0; i < count; ++i)
{
if (images[i].name[0] != '\0' && (images[i].sha256[0] != 0 || images[i].sha256[31] != 0) &&
images[i].sizeBytes != 0 && images[i].createdTimestamp != 0)
{
foundNonEmpty = true;
break;
}
}
VERIFY_IS_TRUE(foundNonEmpty);
}
// Negative: null images pointer must fail.
{
uint32_t count = 0;
VERIFY_ARE_EQUAL(WslcListSessionImages(m_defaultSession, nullptr, &count), E_POINTER);
}
// Negative: null count pointer must fail.
{
WslcImageInfo* images = nullptr;
VERIFY_ARE_EQUAL(WslcListSessionImages(m_defaultSession, &images, nullptr), E_POINTER);
}
}
WSLC_TEST_METHOD(LoadImage)
{
// Positive: load a saved image tar and verify the image can be run.
{
// Remove the image first (ignore failure if it wasn't present).
WslcDeleteSessionImage(m_defaultSession, "hello-world:latest", nullptr);
std::filesystem::path imageTar = GetTestImagePath("hello-world:latest");
wil::unique_handle imageTarFileHandle{
CreateFileW(imageTar.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr)};
VERIFY_IS_FALSE(INVALID_HANDLE_VALUE == imageTarFileHandle.get());
LARGE_INTEGER fileSize{};
VERIFY_IS_TRUE(GetFileSizeEx(imageTarFileHandle.get(), &fileSize));
VERIFY_SUCCEEDED(WslcLoadSessionImage(
m_defaultSession, imageTarFileHandle.get(), static_cast<uint64_t>(fileSize.QuadPart), nullptr, nullptr));
// Verify the loaded image is usable.
auto output = RunContainerAndCapture(m_defaultSession, "hello-world:latest", {});
VERIFY_IS_TRUE(output.stdoutOutput.find("Hello from Docker!") != std::string::npos);
}
// Positive: load a saved image tar and verify the image can be run.
{
// Remove the image first (ignore failure if it wasn't present).
WslcDeleteSessionImage(m_defaultSession, "hello-world:latest", nullptr);
std::filesystem::path imageTar = GetTestImagePath("hello-world:latest");
VERIFY_SUCCEEDED(WslcLoadSessionImageFromFile(m_defaultSession, imageTar.c_str(), nullptr, nullptr));
// Verify the loaded image is usable.
auto output = RunContainerAndCapture(m_defaultSession, "hello-world:latest", {});
VERIFY_IS_TRUE(output.stdoutOutput.find("Hello from Docker!") != std::string::npos);
}
WslcLoadImageOptions opts{};
// Negative: null ImageHandle must fail.
VERIFY_ARE_EQUAL(WslcLoadSessionImage(m_defaultSession, nullptr, 1, &opts, nullptr), E_INVALIDARG);
// Negative: INVALID_HANDLE_VALUE must fail.
VERIFY_ARE_EQUAL(WslcLoadSessionImage(m_defaultSession, INVALID_HANDLE_VALUE, 1, &opts, nullptr), E_INVALIDARG);
// Negative: zero ContentLength must fail.
VERIFY_ARE_EQUAL(WslcLoadSessionImage(m_defaultSession, GetCurrentThreadEffectiveToken(), 0, &opts, nullptr), E_INVALIDARG);
// Negative: null path must fail.
VERIFY_ARE_EQUAL(WslcLoadSessionImageFromFile(m_defaultSession, nullptr, &opts, nullptr), E_POINTER);
}
WSLC_TEST_METHOD(ImportImage)
{
const auto exportedImageTar = std::filesystem::path{g_testDataPath} / L"HelloWorldExported.tar";
constexpr auto c_handleImportedImageName = "my-hello-world-handle:test";
constexpr auto c_pathImportedImageName = "my-hello-world-path:test";
// Positive: import an exported image tar via handle+length and verify the image can be run.
{
WslcDeleteSessionImage(m_defaultSession, c_handleImportedImageName, nullptr);
auto cleanup = wil::scope_exit(
[this]() { LOG_IF_FAILED(WslcDeleteSessionImage(m_defaultSession, c_handleImportedImageName, nullptr)); });
wil::unique_handle imageTarFileHandle{CreateFileW(
exportedImageTar.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr)};
VERIFY_IS_FALSE(INVALID_HANDLE_VALUE == imageTarFileHandle.get());
LARGE_INTEGER fileSize{};
VERIFY_IS_TRUE(GetFileSizeEx(imageTarFileHandle.get(), &fileSize));
VERIFY_SUCCEEDED(WslcImportSessionImage(
m_defaultSession, c_handleImportedImageName, imageTarFileHandle.get(), static_cast<uint64_t>(fileSize.QuadPart), nullptr, nullptr));
auto output = RunContainerAndCapture(m_defaultSession, c_handleImportedImageName, {"/hello"});
VERIFY_IS_TRUE(output.stdoutOutput.find("Hello from Docker!") != std::string::npos);
}
// Positive: import an exported image tar via path and verify the image can be run.
{
WslcDeleteSessionImage(m_defaultSession, c_pathImportedImageName, nullptr);
auto cleanup = wil::scope_exit(
[this]() { LOG_IF_FAILED(WslcDeleteSessionImage(m_defaultSession, c_pathImportedImageName, nullptr)); });
VERIFY_SUCCEEDED(WslcImportSessionImageFromFile(m_defaultSession, c_pathImportedImageName, exportedImageTar.c_str(), nullptr, nullptr));
auto output = RunContainerAndCapture(m_defaultSession, c_pathImportedImageName, {"/hello"});
VERIFY_IS_TRUE(output.stdoutOutput.find("Hello from Docker!") != std::string::npos);
}
WslcImportImageOptions opts{};
// Negative: null image name must fail.
VERIFY_ARE_EQUAL(WslcImportSessionImageFromFile(m_defaultSession, nullptr, exportedImageTar.c_str(), &opts, nullptr), E_POINTER);
// Negative: missing file input must fail.
VERIFY_ARE_EQUAL(WslcImportSessionImageFromFile(m_defaultSession, "missing-file-input:test", nullptr, &opts, nullptr), E_POINTER);
// Negative: zero ContentLength must fail.
VERIFY_ARE_EQUAL(WslcImportSessionImage(m_defaultSession, "zero-length:test", GetCurrentThreadEffectiveToken(), 0, &opts, nullptr), E_INVALIDARG);
}
WSLC_TEST_METHOD(LoadImageNonTar)
{
// The load should fail but it just silently ignores the load currently.
SKIP_TEST_NOT_IMPL();
// Negative: attempt to load a non-tar file.
{
std::filesystem::path pathToSelf = wil::QueryFullProcessImageNameW<std::wstring>(GetCurrentProcess());
wil::unique_handle selfFileHandle{
CreateFileW(pathToSelf.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr)};
VERIFY_IS_FALSE(INVALID_HANDLE_VALUE == selfFileHandle.get());
LARGE_INTEGER fileSize{};
VERIFY_IS_TRUE(GetFileSizeEx(selfFileHandle.get(), &fileSize));
wil::unique_cotaskmem_string errorMsg;
VERIFY_ARE_EQUAL(
WslcLoadSessionImage(m_defaultSession, selfFileHandle.get(), static_cast<uint64_t>(fileSize.QuadPart), nullptr, &errorMsg), E_FAIL);
VERIFY_IS_NOT_NULL(errorMsg.get());
}
}
WSLC_TEST_METHOD(ImportImageNonTar)
{
// Negative: attempt to load a non-tar file.
{
std::filesystem::path pathToSelf = wil::QueryFullProcessImageNameW<std::wstring>(GetCurrentProcess());
wil::unique_handle selfFileHandle{
CreateFileW(pathToSelf.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr)};
VERIFY_IS_FALSE(INVALID_HANDLE_VALUE == selfFileHandle.get());
LARGE_INTEGER fileSize{};
VERIFY_IS_TRUE(GetFileSizeEx(selfFileHandle.get(), &fileSize));
wil::unique_cotaskmem_string errorMsg;
VERIFY_ARE_EQUAL(
WslcImportSessionImage(
m_defaultSession, "import-self:test", selfFileHandle.get(), static_cast<uint64_t>(fileSize.QuadPart), nullptr, &errorMsg),
E_FAIL);
VERIFY_IS_NOT_NULL(errorMsg.get());
LogInfo("Import error: %ws", errorMsg.get());
}
}
WSLC_TEST_METHOD(ImageDelete)
{
auto checkForImage = [this](std::string_view image) -> bool {
WslcImageInfo* images = nullptr;
uint32_t count = 0;
VERIFY_SUCCEEDED(WslcListSessionImages(m_defaultSession, &images, &count));
auto cleanupImages = wil::scope_exit([images]() { CoTaskMemFree(images); });
bool found = false;
for (uint32_t i = 0; i < count; ++i)
{
if (images[i].name == image)
{
found = true;
break;
}
}
return found;
};
// Setup: load hello-world:latest so we have something to delete.
LoadTestImage("hello-world:latest");
VERIFY_IS_TRUE(checkForImage("hello-world:latest"));
// Positive: delete an existing image.
wil::unique_cotaskmem_string errorMsg;
VERIFY_SUCCEEDED(WslcDeleteSessionImage(m_defaultSession, "hello-world:latest", &errorMsg));
// Verify the image is no longer present in the list.
VERIFY_IS_FALSE(checkForImage("hello-world:latest"));
// Negative: null name must fail.
VERIFY_ARE_EQUAL(WslcDeleteSessionImage(m_defaultSession, nullptr, nullptr), E_POINTER);
}
// -----------------------------------------------------------------------
// Container lifecycle tests
// -----------------------------------------------------------------------
WSLC_TEST_METHOD(CreateContainer)
{
// Simple echo — verify stdout is captured correctly.
{
auto output = RunContainerAndCapture(m_defaultSession, "debian:latest", {"/bin/echo", "OK"});
VERIFY_ARE_EQUAL(output.stdoutOutput, "OK\n");
VERIFY_ARE_EQUAL(output.stderrOutput, "");
}
// Verify stdout and stderr are routed independently.
{
auto output =
RunContainerAndCapture(m_defaultSession, "debian:latest", {"/bin/sh", "-c", "echo stdout && echo stderr >&2"});
VERIFY_ARE_EQUAL(output.stdoutOutput, "stdout\n");
VERIFY_ARE_EQUAL(output.stderrOutput, "stderr\n");
}
// Verify that creating a container with a non-existent image fails.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("invalid-image:notfound", &containerSettings));
WslcContainer container = nullptr;
wil::unique_cotaskmem_string errorMsg;
VERIFY_ARE_EQUAL(WslcCreateContainer(m_defaultSession, &containerSettings, &container, &errorMsg), WSLC_E_IMAGE_NOT_FOUND);
VERIFY_IS_NULL(container);
}
// Verify that a null image name is rejected.
{
WslcContainerSettings containerSettings;
VERIFY_ARE_EQUAL(WslcInitContainerSettings(nullptr, &containerSettings), E_POINTER);
}
// Verify that a null settings pointer is rejected.
{
VERIFY_ARE_EQUAL(WslcInitContainerSettings("debian:latest", nullptr), E_POINTER);
}
// Verify that a null container output pointer is rejected.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_ARE_EQUAL(WslcCreateContainer(m_defaultSession, &containerSettings, nullptr, nullptr), E_POINTER);
}
}
WSLC_TEST_METHOD(ContainerGetID)
{
UniqueContainer container;
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcCreateContainer(m_defaultSession, &containerSettings, &container, nullptr));
// Positive: ID is returned and is the expected length of hex characters.
CHAR id[WSLC_CONTAINER_ID_BUFFER_SIZE]{};
VERIFY_SUCCEEDED(WslcGetContainerID(container.get(), id));
VERIFY_ARE_EQUAL(strnlen(id, WSLC_CONTAINER_ID_BUFFER_SIZE), static_cast<size_t>(WSLC_CONTAINER_ID_BUFFER_SIZE - 1));
// Negative: null ID buffer must fail.
VERIFY_ARE_EQUAL(WslcGetContainerID(container.get(), nullptr), E_POINTER);
VERIFY_SUCCEEDED(WslcDeleteContainer(container.get(), WSLC_DELETE_CONTAINER_FLAG_NONE, nullptr));
}
WSLC_TEST_METHOD(ContainerGetState)
{
WslcProcessSettings procSettings;
VERIFY_SUCCEEDED(WslcInitProcessSettings(&procSettings));
const char* argv[] = {"/bin/sleep", "99"};
VERIFY_SUCCEEDED(WslcSetProcessSettingsCmdLine(&procSettings, argv, ARRAYSIZE(argv)));
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings, &procSettings));
UniqueContainer container;
VERIFY_SUCCEEDED(WslcCreateContainer(m_defaultSession, &containerSettings, &container, nullptr));
// State after creation: CREATED.
{
WslcContainerState state{};
VERIFY_SUCCEEDED(WslcGetContainerState(container.get(), &state));
VERIFY_ARE_EQUAL(state, WSLC_CONTAINER_STATE_CREATED);
}
VERIFY_SUCCEEDED(WslcStartContainer(container.get(), WSLC_CONTAINER_START_FLAG_NONE, nullptr));
// State while running: RUNNING.
{
WslcContainerState state{};
VERIFY_SUCCEEDED(WslcGetContainerState(container.get(), &state));
VERIFY_ARE_EQUAL(state, WSLC_CONTAINER_STATE_RUNNING);
}
VERIFY_SUCCEEDED(WslcStopContainer(container.get(), WSLC_SIGNAL_SIGKILL, 0, nullptr));
// State after stop: EXITED.
{
WslcContainerState state{};
VERIFY_SUCCEEDED(WslcGetContainerState(container.get(), &state));
VERIFY_ARE_EQUAL(state, WSLC_CONTAINER_STATE_EXITED);
}
// Negative: null state pointer must fail.
VERIFY_ARE_EQUAL(WslcGetContainerState(container.get(), nullptr), E_POINTER);
VERIFY_SUCCEEDED(WslcDeleteContainer(container.get(), WSLC_DELETE_CONTAINER_FLAG_NONE, nullptr));
}
WSLC_TEST_METHOD(ContainerStopAndDelete)
{
// Build a long-running container.
WslcProcessSettings procSettings;
VERIFY_SUCCEEDED(WslcInitProcessSettings(&procSettings));
const char* argv[] = {"/bin/sleep", "999"};
VERIFY_SUCCEEDED(WslcSetProcessSettingsCmdLine(&procSettings, argv, ARRAYSIZE(argv)));
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings, &procSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsName(&containerSettings, "wslc-stop-delete-test"));
UniqueContainer container;
VERIFY_SUCCEEDED(WslcCreateContainer(m_defaultSession, &containerSettings, &container, nullptr));
VERIFY_SUCCEEDED(WslcStartContainer(container.get(), WSLC_CONTAINER_START_FLAG_NONE, nullptr));
// Acquire and release the init process handle — we won't read its I/O.
{
UniqueProcess process;
VERIFY_SUCCEEDED(WslcGetContainerInitProcess(container.get(), &process));
}
// Stop the container gracefully (after the timeout).
VERIFY_SUCCEEDED(WslcStopContainer(container.get(), WSLC_SIGNAL_SIGKILL, 0, nullptr));
// Delete the stopped container.
VERIFY_SUCCEEDED(WslcDeleteContainer(container.get(), WSLC_DELETE_CONTAINER_FLAG_NONE, nullptr));
}
WSLC_TEST_METHOD(ProcessIOHandles)
{
// Verify that stdout and stderr can each be read, and are independent streams.
WslcProcessSettings procSettings;
VERIFY_SUCCEEDED(WslcInitProcessSettings(&procSettings));
const char* argv[] = {"/bin/sh", "-c", "printf 'stdout-line\n' ; printf 'stderr-line\n' >&2"};
VERIFY_SUCCEEDED(WslcSetProcessSettingsCmdLine(&procSettings, argv, ARRAYSIZE(argv)));
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings, &procSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsFlags(&containerSettings, WSLC_CONTAINER_FLAG_NONE));
UniqueContainer container;
VERIFY_SUCCEEDED(WslcCreateContainer(m_defaultSession, &containerSettings, &container, nullptr));
VERIFY_SUCCEEDED(WslcStartContainer(container.get(), WSLC_CONTAINER_START_FLAG_ATTACH, nullptr));
UniqueProcess process;
VERIFY_SUCCEEDED(WslcGetContainerInitProcess(container.get(), &process));
HANDLE exitEvent = nullptr;
VERIFY_SUCCEEDED(WslcGetProcessExitEvent(process.get(), &exitEvent));
HANDLE rawStdout = nullptr;
VERIFY_SUCCEEDED(WslcGetProcessIOHandle(process.get(), WSLC_PROCESS_IO_HANDLE_STDOUT, &rawStdout));
wil::unique_handle ownedStdout(rawStdout);
HANDLE rawStderr = nullptr;
VERIFY_SUCCEEDED(WslcGetProcessIOHandle(process.get(), WSLC_PROCESS_IO_HANDLE_STDERR, &rawStderr));
wil::unique_handle ownedStderr(rawStderr);
// Verify that each handle can only be acquired once.
{
HANDLE duplicate = nullptr;
VERIFY_ARE_EQUAL(WslcGetProcessIOHandle(process.get(), WSLC_PROCESS_IO_HANDLE_STDOUT, &duplicate), HRESULT_FROM_WIN32(ERROR_INVALID_STATE));
}
VERIFY_ARE_EQUAL(WaitForSingleObject(exitEvent, 60 * 1000), WAIT_OBJECT_0);
}
WSLC_TEST_METHOD(ContainerNetworkingMode)
{
// BRIDGED: container should have an eth0 interface in sysfs.
{
auto output = RunContainerAndCapture(
m_defaultSession,
"debian:latest",
{"/bin/sh", "-c", "[ -d /sys/class/net/eth0 ] && echo 'HAS_ETH0' || echo 'NO_ETH0'"},
WSLC_CONTAINER_FLAG_NONE,
nullptr,
60s,
WSLC_CONTAINER_NETWORKING_MODE_BRIDGED);
VERIFY_ARE_EQUAL(output.stdoutOutput, "HAS_ETH0\n");
}
// NONE: container should not have an eth0 interface.
{
auto output = RunContainerAndCapture(
m_defaultSession,
"debian:latest",
{"/bin/sh", "-c", "[ -d /sys/class/net/eth0 ] && echo 'HAS_ETH0' || echo 'NO_ETH0'"},
WSLC_CONTAINER_FLAG_NONE,
nullptr,
60s,
WSLC_CONTAINER_NETWORKING_MODE_NONE);
VERIFY_ARE_EQUAL(output.stdoutOutput, "NO_ETH0\n");
}
// Invalid networking mode must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_ARE_EQUAL(WslcSetContainerSettingsNetworkingMode(&containerSettings, static_cast<WslcContainerNetworkingMode>(99)), E_INVALIDARG);
}
}
WSLC_TEST_METHOD(ContainerPortMapping)
{
// Negative: null mappings with nonzero count must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_ARE_EQUAL(WslcSetContainerSettingsPortMappings(&containerSettings, nullptr, 1), E_INVALIDARG);
}
// Negative: non-null pointer with zero count must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
WslcContainerPortMapping portMappings[1] = {};
VERIFY_ARE_EQUAL(WslcSetContainerSettingsPortMappings(&containerSettings, portMappings, 0), E_INVALIDARG);
}
// Positive: null mappings with zero count must succeed (clears the mapping).
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsPortMappings(&containerSettings, nullptr, 0));
}
// Negative: port mappings with NONE networking must fail at container creation.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings, WSLC_CONTAINER_NETWORKING_MODE_NONE));
WslcContainerPortMapping mapping{};
mapping.windowsPort = 12342;
mapping.containerPort = 8000;
mapping.protocol = WSLC_PORT_PROTOCOL_TCP;
VERIFY_SUCCEEDED(WslcSetContainerSettingsPortMappings(&containerSettings, &mapping, 1));
WslcContainer rawContainer = nullptr;
VERIFY_ARE_EQUAL(WslcCreateContainer(m_defaultSession, &containerSettings, &rawContainer, nullptr), E_INVALIDARG);
VERIFY_IS_NULL(rawContainer);
}
// Functional: create a container with BRIDGED networking and a port mapping;
// verify that a TCP connection from the host reaches the container.
{
WslcProcessSettings procSettings;
VERIFY_SUCCEEDED(WslcInitProcessSettings(&procSettings));
const char* argv[] = {"python3", "-m", "http.server", "8000"};
VERIFY_SUCCEEDED(WslcSetProcessSettingsCmdLine(&procSettings, argv, ARRAYSIZE(argv)));
const char* env[] = {"PYTHONUNBUFFERED=1"};
VERIFY_SUCCEEDED(WslcSetProcessSettingsEnvVariables(&procSettings, env, ARRAYSIZE(env)));
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("python:3.12-alpine", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsInitProcess(&containerSettings, &procSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsNetworkingMode(&containerSettings, WSLC_CONTAINER_NETWORKING_MODE_BRIDGED));
WslcContainerPortMapping mapping{};
mapping.windowsPort = 12341;
mapping.containerPort = 8000;
mapping.protocol = WSLC_PORT_PROTOCOL_TCP;
VERIFY_SUCCEEDED(WslcSetContainerSettingsPortMappings(&containerSettings, &mapping, 1));
UniqueContainer container;
VERIFY_SUCCEEDED(WslcCreateContainer(m_defaultSession, &containerSettings, &container, nullptr));
VERIFY_SUCCEEDED(WslcStartContainer(container.get(), WSLC_CONTAINER_START_FLAG_ATTACH, nullptr));
UniqueProcess process;
VERIFY_SUCCEEDED(WslcGetContainerInitProcess(container.get(), &process));
wil::unique_handle ownedStdout;
VERIFY_SUCCEEDED(WslcGetProcessIOHandle(process.get(), WSLC_PROCESS_IO_HANDLE_STDOUT, &ownedStdout));
WaitForOutput(std::move(ownedStdout), "Serving HTTP on", 30s);
ExpectHttpResponse(L"http://127.0.0.1:12341", 200);
}
}
WSLC_TEST_METHOD(ContainerVolumeUnit)
{
// Negative: null volumes with nonzero count must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_ARE_EQUAL(WslcSetContainerSettingsVolumes(&containerSettings, nullptr, 1), E_INVALIDARG);
}
// Negative: non-null pointer with zero count must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
WslcContainerVolume containerVolumes[1] = {};
VERIFY_ARE_EQUAL(WslcSetContainerSettingsVolumes(&containerSettings, containerVolumes, 0), E_INVALIDARG);
}
// Negative: null paths must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
WslcContainerVolume containerVolumes[1] = {nullptr, "/mnt/path"};
VERIFY_ARE_EQUAL(WslcSetContainerSettingsVolumes(&containerSettings, containerVolumes, ARRAYSIZE(containerVolumes)), E_INVALIDARG);
}
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
auto currentDirectory = std::filesystem::current_path();
WslcContainerVolume containerVolumes[1] = {currentDirectory.c_str(), nullptr};
VERIFY_ARE_EQUAL(WslcSetContainerSettingsVolumes(&containerSettings, containerVolumes, ARRAYSIZE(containerVolumes)), E_INVALIDARG);
}
// Relative paths must fail.
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
WslcContainerVolume containerVolumes[1] = {L"relative", "/mnt/path"};
VERIFY_ARE_EQUAL(WslcSetContainerSettingsVolumes(&containerSettings, containerVolumes, ARRAYSIZE(containerVolumes)), E_INVALIDARG);
}
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
auto currentDirectory = std::filesystem::current_path();
WslcContainerVolume containerVolumes[1] = {currentDirectory.c_str(), "./mnt/path"};
VERIFY_ARE_EQUAL(WslcSetContainerSettingsVolumes(&containerSettings, containerVolumes, ARRAYSIZE(containerVolumes)), E_INVALIDARG);
}
// Positive: null volumes with zero count must succeed (clears volumes).
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
VERIFY_SUCCEEDED(WslcSetContainerSettingsVolumes(&containerSettings, nullptr, 0));
}
// Absolute paths should succeed
{
WslcContainerSettings containerSettings;
VERIFY_SUCCEEDED(WslcInitContainerSettings("debian:latest", &containerSettings));
auto currentDirectory = std::filesystem::current_path();
WslcContainerVolume containerVolumes[1] = {currentDirectory.c_str(), "/mnt/path"};
VERIFY_SUCCEEDED(WslcSetContainerSettingsVolumes(&containerSettings, containerVolumes, ARRAYSIZE(containerVolumes)));
}
}
WSLC_TEST_METHOD(ContainerVolumeFunctional)
{