ReactOS 0.4.16-dev-2104-gb84fa49
popen.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: See COPYING in the top level directory
4 * PURPOSE: Test for CRT process handling.
5 * PROGRAMMER: Andreas Maier <andy1.m@gmx.de>
6 */
7
8#include <apitest.h>
9
10#define WIN32_NO_STATUS
11#include <stdio.h>
12
13static void Test_popen()
14{
15 FILE * f;
16 int r;
17 char str[20];
18
19 /* NOTE: We suppose that the NT test installation has an accessible cmd.exe */
20 f = _popen("cmd.exe /C \"echo Hallo\"", "r");
21 ok(f != NULL, "_popen returns NULL!\n");
22
23 ZeroMemory(str, sizeof(str));
24 fgets(str, sizeof(str) - 1, f);
25 ok(lstrcmp(str, "Hallo\n") == 0, "fgets: expected \"Hallo\", got %s.\n", str);
26
27 r = _pclose(f);
28 ok(r == 0, "_pclose: expected 0, got %i.\n", r);
29 r = *_errno();
30 ok(r == 0, "_errno: expected 0, got %i,\n", r);
31}
32
34{
35 Test_popen();
36}
37
38/* EOF */
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
int *CDECL _errno(void)
Definition: errno.c:215
char *CDECL fgets(char *s, int size, FILE *file)
Definition: file.c:3903
_ACRTIMP int __cdecl _pclose(FILE *)
Definition: process.c:1212
_ACRTIMP FILE *__cdecl _popen(const char *, const char *)
Definition: process.c:1185
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
#define ZeroMemory
Definition: minwinbase.h:31
static void Test_popen()
Definition: popen.c:13
#define popen
Definition: syshdrs.h:72
const WCHAR * str
#define lstrcmp
Definition: winbase.h:3621