mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-10 17:47:59 -06:00
Enable the CreateContainer stdin test
This commit is contained in:
parent
2a41fe20e3
commit
708a6ce3ac
@ -88,7 +88,6 @@ Microsoft::WRL::ComPtr<WSLAContainer> WSLAContainer::Create(const WSLA_CONTAINER
|
||||
if (hasStdin)
|
||||
{
|
||||
// For now return a proper error if the caller tries to pass stdin without a TTY to prevent hangs.
|
||||
THROW_WIN32_IF(ERROR_NOT_SUPPORTED, hasTty == false);
|
||||
inputOptions.push_back("-i");
|
||||
}
|
||||
|
||||
|
||||
@ -1230,32 +1230,31 @@ class WSLATests
|
||||
ValidateProcessOutput(process, {{1, "testvalue\n"}});
|
||||
}
|
||||
|
||||
// Validate that starting containers works with the default entrypoint.
|
||||
// Validate that starting containers works with the default entrypoint and content on stdin
|
||||
{
|
||||
WSLAContainerLauncher launcher(
|
||||
"debian:latest", "test-default-entrypoint", "/bin/cat", {}, {}, ProcessFlags::Stdin | ProcessFlags::Stdout | ProcessFlags::Stderr);
|
||||
|
||||
// For now, validate that trying to use stdin without a tty returns the appropriate error.
|
||||
auto result = wil::ResultFromException([&]() { auto container = launcher.Launch(*session); });
|
||||
auto container = launcher.Launch(*session);
|
||||
|
||||
VERIFY_ARE_EQUAL(result, HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
|
||||
|
||||
// This is hanging. nerdctl run seems to hang with -i is passed outside of a TTY context.
|
||||
// TODO: Restore the test case once this is fixed.
|
||||
|
||||
/*
|
||||
// TODO: nerdctl hangs if stdin is closed without writting to it.
|
||||
// Add test coverage for that usecase once that the hang is fixed.
|
||||
auto process = container.GetInitProcess();
|
||||
auto input = process.GetStdHandle(0);
|
||||
|
||||
std::string shellInput = "foo";
|
||||
std::vector<char> inputBuffer{shellInput.begin(), shellInput.end()};
|
||||
|
||||
std::unique_ptr<OverlappedIOHandle> writeStdin(new WriteHandle(std::move(input), inputBuffer));
|
||||
|
||||
std::string shellInput = "echo $SHELL\n exit";
|
||||
std::unique_ptr<OverlappedIOHandle> writeStdin(
|
||||
new WriteHandle(process.GetStdHandle(0), {shellInput.begin(), shellInput.end()}));
|
||||
std::vector<std::unique_ptr<OverlappedIOHandle>> extraHandles;
|
||||
extraHandles.emplace_back(std::move(writeStdin));
|
||||
|
||||
auto result = process.WaitAndCaptureOutput(INFINITE, std::move(extraHandles));
|
||||
|
||||
VERIFY_ARE_EQUAL(result.Output[1], "bash\n");
|
||||
*/
|
||||
VERIFY_ARE_EQUAL(result.Output[2], "");
|
||||
VERIFY_ARE_EQUAL(result.Output[1], "foo");
|
||||
}
|
||||
|
||||
// Validate that stdin is empty if ProcessFlags::Stdin is not passed.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user