From: Hermès Bélusca-Maïto Date: Mon, 17 Jul 2017 15:27:40 +0000 (+0000) Subject: [MSVCRT_APITEST]: Commit a simple test for popen(), by Andreas Maier. X-Git-Tag: ReactOS-0.4.6~70 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=73375485df914fa8eb61db8e30ddcb90b0818f64;ds=sidebyside [MSVCRT_APITEST]: Commit a simple test for popen(), by Andreas Maier. CORE-11568 svn path=/trunk/; revision=75364 --- diff --git a/rostests/apitests/msvcrt/CMakeLists.txt b/rostests/apitests/msvcrt/CMakeLists.txt index 8be74f05e29..60f3cde1c14 100644 --- a/rostests/apitests/msvcrt/CMakeLists.txt +++ b/rostests/apitests/msvcrt/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(CmdLineUtil) list(APPEND SOURCE CommandLine.c ieee.c + popen.c splitpath.c testlist.c) diff --git a/rostests/apitests/msvcrt/popen.c b/rostests/apitests/msvcrt/popen.c new file mode 100644 index 00000000000..c32550f1858 --- /dev/null +++ b/rostests/apitests/msvcrt/popen.c @@ -0,0 +1,38 @@ +/* + * PROJECT: ReactOS API Tests + * LICENSE: See COPYING in the top level directory + * PURPOSE: Test for CRT process handling. + * PROGRAMMER: Andreas Maier + */ + +#include + +#define WIN32_NO_STATUS +#include + +static void Test_popen() +{ + FILE * f; + int r; + char str[20]; + + /* NOTE: We suppose that the NT test installation has an accessible cmd.exe */ + f = _popen("cmd.exe /C \"echo Hallo\"", "r"); + ok(f != NULL, "_popen returns NULL!\n"); + + ZeroMemory(str, sizeof(str)); + fgets(str, sizeof(str) - 1, f); + ok(lstrcmp(str, "Hallo\n") == 0, "fgets: expected \"Hallo\", got %s.\n", str); + + r = _pclose(f); + ok(r == 0, "_pclose: expected 0, got %i.\n", r); + r = *_errno(); + ok(r == 0, "_errno: expected 0, got %i,\n", r); +} + +START_TEST(popen) +{ + Test_popen(); +} + +/* EOF */ diff --git a/rostests/apitests/msvcrt/testlist.c b/rostests/apitests/msvcrt/testlist.c index 96a9ef4c57d..d358dd99bd2 100644 --- a/rostests/apitests/msvcrt/testlist.c +++ b/rostests/apitests/msvcrt/testlist.c @@ -5,12 +5,14 @@ extern void func_CommandLine(void); extern void func_ieee(void); +extern void func_popen(void); extern void func_splitpath(void); const struct test winetest_testlist[] = { { "CommandLine", func_CommandLine }, { "ieee", func_ieee }, + { "popen", func_popen }, { "splitpath", func_splitpath }, { 0, 0 }