ReactOS 0.4.16-dev-250-g3ecd236
system.c File Reference
#include <apitest.h>
#include <apitest_guard.h>
Include dependency graph for system.c:

Go to the source code of this file.

Functions

 START_TEST (system)
 

Function Documentation

◆ START_TEST()

START_TEST ( system  )

Definition at line 11 of file system.c.

12{
13 int ret;
14 CHAR szCmdExe[MAX_PATH];
15
16 GetSystemDirectoryA(szCmdExe, _countof(szCmdExe));
17 lstrcatA(szCmdExe, "\\cmd.exe");
18
19 SetEnvironmentVariableA("COMSPEC", NULL);
20 errno = 0xDEADBEEF;
21 ret = system(NULL);
22 ok_int(errno, 0xDEADBEEF);
23 ok_int(ret, 1);
24
25 SetEnvironmentVariableA("COMSPEC", "InvalidComSpec");
26 errno = 0xDEADBEEF;
27 ret = system(NULL);
28 ok_int(errno, 0xDEADBEEF);
29 ok_int(ret, 1);
30
31 SetEnvironmentVariableA("COMSPEC", szCmdExe);
32 errno = 0xDEADBEEF;
33 ret = system(NULL);
34 ok_int(errno, 0xDEADBEEF);
35 ok_int(ret, 1);
36
37 SetEnvironmentVariableA("COMSPEC", NULL);
38 errno = 0xDEADBEEF;
39 ret = system("echo This is a test");
40 ok_int(errno, 0);
41 ok_int(ret, 0);
42
43 SetEnvironmentVariableA("COMSPEC", "InvalidComSpec");
44 errno = 0xDEADBEEF;
45 ret = system("echo This is a test");
46 ok_int(errno, 0);
47 ok_int(ret, 0);
48
49 SetEnvironmentVariableA("COMSPEC", szCmdExe);
50 errno = 0xDEADBEEF;
51 ret = system("echo This is a test");
52 ok_int(errno, 0);
53 ok_int(ret, 0);
54
55 SetEnvironmentVariableA("COMSPEC", NULL);
56 errno = 0xDEADBEEF;
57 ret = system("InvalidCommandLine");
58 ok_int(errno, 0);
59 ok_int(ret, 1);
60
61 SetEnvironmentVariableA("COMSPEC", "InvalidComSpec");
62 errno = 0xDEADBEEF;
63 ret = system("InvalidCommandLine");
64 ok_int(errno, 0);
65 ok_int(ret, 1);
66
67 SetEnvironmentVariableA("COMSPEC", szCmdExe);
68 errno = 0xDEADBEEF;
69 ret = system("InvalidCommandLine");
70 ok_int(errno, 0);
71 ok_int(ret, 1);
72}
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define errno
Definition: errno.h:18
int __cdecl system(_In_opt_z_ const char *_Command)
#define _countof(array)
Definition: sndvol32.h:70
int ret
char CHAR
Definition: xmlstorage.h:175