Skip to content

Commit

Permalink
TestChildNative should write stdout in the binary mode
Browse files Browse the repository at this point in the history
  • Loading branch information
asmichi committed Feb 23, 2022
1 parent 4a975b0 commit 58cacb4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

extern char** environ;

int TestCommandDumpEnvironmentvariables(int, const char* const*)
int TestCommandDumpEnvironmentVariables(int, const char* const*)
{
for (char** p = environ; *p != nullptr; p++)
{
Expand Down
10 changes: 9 additions & 1 deletion src/ChildProcess.Native/tests/DumpEnvironmentVariables.win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#include <io.h>
#include <memory>

int TestCommandDumpEnvironmentvariables(int argc, const char* const* argv)
int TestCommandDumpEnvironmentVariables(int argc, const char* const* argv)
{
if (_setmode(_fileno(stdout), O_BINARY) == -1)
{
perror("_setmode");
return 1;
}

wchar_t* pFirstEnv = GetEnvironmentStringsW();
if (pFirstEnv == nullptr)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ChildProcess.Native/tests/TestChildMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern void SetupDefaultTestSignalHandlers();

// Handlers
extern int TestCommandReportSignal(int argc, const char* const* argv);
extern int TestCommandDumpEnvironmentvariables(int argc, const char* const* argv);
extern int TestCommandDumpEnvironmentVariables(int argc, const char* const* argv);
#if defined(_WIN32)
#else
#endif
Expand All @@ -25,7 +25,7 @@ namespace

TestCommandDefinition TestCommandDefinitions[] = {
{"ReportSignal", TestCommandReportSignal},
{"DumpEnvironmentVariables", TestCommandDumpEnvironmentvariables},
{"DumpEnvironmentVariables", TestCommandDumpEnvironmentVariables},
#if defined(_WIN32)
#else
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public void CanAddEnvironmentVariables()
{
new("A", "A"),
new("BB", "BB"),
// This is actually testing if TestChildNative writes to stdout in the binary mode.
new("C", "C\nC\n"),
};

var expected = GetProcessEnvVars().Concat(extraEnvVars);
Expand Down

0 comments on commit 58cacb4

Please sign in to comment.