From: Dean M. B. <mik...@gm...> - 2008-08-10 07:33:02
|
Hi Allister, Please check in the patches. :) I don't have enough Windows know-how to check whether the patches work, but I trust that once they build and work correctly, then it should be safe to check in. Divye, do you have any idea why the size check fails in Windows but works fine in Linux? On Sun, Aug 10, 2008 at 5:10 AM, Allister Levi Sanchez <all...@gm...> wrote: > Hi again everyone, > > After getting my first introduction to Windows system programming, I finally > managed to make the python server run in the background on Vista, and to > kill it in the end as well :-) For debugging, however, you might still want > to see the python server logs, so I kept the console visible and just wrote > a comment in the code on how to hide it. > > About the error message, I don't see them on GCC 4.2.3 (Kubuntu) anymore. > But I still see them on Windows: > > ********************************** snip: start error log > 1>testing.unit-test > libs\network\test\bin\msvc-9.0express\debug\link-static\threading-multi\localhost_tests.passed > 1>Running 10 test cases... > 1>libs/network/test/localhost_tests.cpp(151): error in "text_file_query": > check body(response_).length() == size failed [113 != 117] > 1>*** 1 failure detected in test suite "http 1.0 localhost tests" > 1> > 1> > libs\network\test\bin\msvc-9.0express\debug\link-static\threading-multi\localhost_tests.exe > && echo. > > libs\network\test\bin\msvc-9.0express\debug\link-static\threading-multi\localhost_tests.passed > 1>...failed testing.unit-test > libs\network\test\bin\msvc-9.0express\debug\link-static\threading-multi\localhost_tests.passed... > 1>...failed updating 1 target... > 1>...updated 2 targets... > 1>Project : error PRJ0019: A tool returned an error code from "Performing > Makefile project actions" > 1>Build log was saved at "file://d:\Dev\vc9ws\cpp-netlib\Debug\BuildLog.htm" > 1>cpp-netlib - 2 error(s), 0 warning(s) > ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== > > ********************************** snip: end error log > > Anyway, here's the patch. Feel free to improve it. > > Cheers! > Allister > > Index: libs/network/test/localhost_tests.cpp > =================================================================== > --- libs/network/test/localhost_tests.cpp (revision 48) > +++ libs/network/test/localhost_tests.cpp (working copy) > @@ -28,6 +28,24 @@ > #pragma comment( lib, "shell32" ) // for ShellExecute > #pragma comment( lib, "ole32" ) // for CoInitialize, CoUninitialize > > + SHELLEXECUTEINFO server_info = { > + sizeof(server_info), // cbSize > + SEE_MASK_NOCLOSEPROCESS, // fMask > + NULL, // hwnd > + "open", // lpVerb > + "python.exe", // lpFile > + "cgi_server.py", // lpParameters > + "libs\\network\\test\\server", // lpDirectory > + SW_SHOWNOACTIVATE, // nShow, use SW_HIDE if you don't > like popup windows > + 0, // hInstApp > + NULL, // lpIDList > + NULL, // lpClass > + NULL, // hkeyClass > + 0, // dwHotKey > + NULL, // hIcon > + NULL // hProcess > + }; > + > #else > #include <unistd.h> // fork, execlp etc. > #include <sys/types.h> > @@ -48,8 +66,7 @@ > // Executes the Python Server > // See http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx > for a description of ShellExecute > CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | > COINIT_DISABLE_OLE1DDE); > - BOOST_REQUIRE_MESSAGE( (int)ShellExecute(NULL,"open", "python.exe", > " cgi_server.py", > - "libs\\network\\test\\server", SW_SHOWNOACTIVATE) > > 32, "Python server execution failed.\n" ); > + BOOST_REQUIRE_MESSAGE( ShellExecuteEx(&server_info), "Python server > execution failed.\n" ); > CoUninitialize(); > #else > // Try general Unix code > @@ -57,7 +74,7 @@ > BOOST_REQUIRE_MESSAGE(server_child >= 0, "Failed to fork!"); > if( server_child == 0 ) { // child process > chdir("libs/network/test/server"); > - BOOST_REQUIRE_MESSAGE(execlp("xterm", "xterm", "-e", "python > cgi_server.py", (char *)NULL) != -1, > + BOOST_REQUIRE_MESSAGE(execlp("python", "python", > "cgi_server.py", (char *)NULL) != -1, > "Python server execution failed!\n"); > } else { // parent > sleep(1); > @@ -218,10 +235,13 @@ > BOOST_AUTO_TEST_CASE(server_kill) { > // TODO: For automation of regression testing, the windows need to be > killed here. > #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) > - // Windows Kill code not implemented > + UINT exitcode = 0; > + BOOST_REQUIRE_MESSAGE( TerminateProcess(server_info.hProcess, > exitcode), > + "Failed to shutdown local server!\n" ); > + CloseHandle(server_info.hProcess); > #else > // This code causes a "fatal error" report for this test case. > - //kill(server_child, SIGINT); > + kill(server_child, SIGTERM); > //waitpid(server_child, 0, 0); > #endif > } > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Cpp-netlib-devel mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel > > -- Dean Michael C. Berris Software Engineer, Friendster, Inc. |