Skip to content
Snippets Groups Projects
Commit 25ef0cd2 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

Tweak llprocesslauncher_test.cpp to run properly on Windows.

Fix EOL issues: "\r\n" vs. "\n".
On Windows, requesting a read in nonblocking mode can produce EAGAIN instead
of EWOULDBLOCK.
parent 2fd0bc86
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
#if defined(LL_WINDOWS) #if defined(LL_WINDOWS)
#define sleep _sleep #define sleep _sleep
#define EOL "\r\n"
#else
#define EOL "\n"
#endif #endif
class APR class APR
...@@ -99,15 +102,15 @@ namespace tut ...@@ -99,15 +102,15 @@ namespace tut
// Write it. // Write it.
const char script[] = const char script[] =
"import sys\n" "import sys" EOL
"import time\n" "import time" EOL
"\n" EOL
"time.sleep(2)\n" "time.sleep(2)" EOL
"print >>sys.stdout, \"stdout after wait\"\n" "print >>sys.stdout, \"stdout after wait\"" EOL
"sys.stdout.flush()\n" "sys.stdout.flush()" EOL
"time.sleep(2)\n" "time.sleep(2)" EOL
"print >>sys.stderr, \"stderr after wait\"\n" "print >>sys.stderr, \"stderr after wait\"" EOL
"sys.stderr.flush()\n" "sys.stderr.flush()" EOL
; ;
apr_size_t len(sizeof(script)-1); apr_size_t len(sizeof(script)-1);
aprchk(apr_file_write(fp, script, &len)); aprchk(apr_file_write(fp, script, &len));
...@@ -159,7 +162,7 @@ namespace tut ...@@ -159,7 +162,7 @@ namespace tut
outfiles.erase(outfiles.begin() + i); outfiles.erase(outfiles.begin() + i);
continue; continue;
} }
if (rv == EWOULDBLOCK) if (rv == EWOULDBLOCK || rv == EAGAIN)
{ {
// std::cout << "(waiting; apr_file_gets(" << iterfiles[i].first << ") => " << rv << ": " << apr.strerror(rv) << ")\n"; // std::cout << "(waiting; apr_file_gets(" << iterfiles[i].first << ") => " << rv << ": " << apr.strerror(rv) << ")\n";
++history.back().tries; ++history.back().tries;
...@@ -210,12 +213,12 @@ namespace tut ...@@ -210,12 +213,12 @@ namespace tut
// waiting, proving the non-blocking nature of these pipes. // waiting, proving the non-blocking nature of these pipes.
ensure("blocking I/O on child pipe (0)", history[0].tries); ensure("blocking I/O on child pipe (0)", history[0].tries);
ensure_equals(history[0].which, "out"); ensure_equals(history[0].which, "out");
ensure_equals(history[0].what, "stdout after wait\n"); ensure_equals(history[0].what, "stdout after wait" EOL);
ensure("blocking I/O on child pipe (1)", history[1].tries); ensure("blocking I/O on child pipe (1)", history[1].tries);
ensure_equals(history[1].which, "out"); ensure_equals(history[1].which, "out");
ensure_equals(history[1].what, "*eof*"); ensure_equals(history[1].what, "*eof*");
ensure_equals(history[2].which, "err"); ensure_equals(history[2].which, "err");
ensure_equals(history[2].what, "stderr after wait\n"); ensure_equals(history[2].what, "stderr after wait" EOL);
ensure_equals(history[3].which, "err"); ensure_equals(history[3].which, "err");
ensure_equals(history[3].what, "*eof*"); ensure_equals(history[3].what, "*eof*");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment