ReactOS 0.4.15-dev-7842-g558ab78
_wsystem.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS CRT
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Tests for _wsystem()
5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include <apitest.h>
9#include <apitest_guard.h>
10
12{
13 int ret;
14 WCHAR szCmdExe[MAX_PATH];
15
16 GetSystemDirectoryW(szCmdExe, _countof(szCmdExe));
17 lstrcatW(szCmdExe, L"\\cmd.exe");
18
20 errno = 0xDEADBEEF;
21 ret = _wsystem(NULL);
22 ok_int(errno, 0xDEADBEEF);
23 ok_int(ret, 1);
24
25 SetEnvironmentVariableW(L"COMSPEC", L"InvalidComSpec");
26 errno = 0xDEADBEEF;
27 ret = _wsystem(NULL);
28 ok_int(errno, 0xDEADBEEF);
29 ok_int(ret, 1);
30
31 SetEnvironmentVariableW(L"COMSPEC", szCmdExe);
32 errno = 0xDEADBEEF;
33 ret = _wsystem(NULL);
34 ok_int(errno, 0xDEADBEEF);
35 ok_int(ret, 1);
36
38 errno = 0xDEADBEEF;
39 ret = _wsystem(L"echo This is a test");
40 ok_int(errno, 0);
41 ok_int(ret, 0);
42
43 SetEnvironmentVariableW(L"COMSPEC", L"InvalidComSpec");
44 errno = 0xDEADBEEF;
45 ret = _wsystem(L"echo This is a test");
46 ok_int(errno, 0);
47 ok_int(ret, 0);
48
49 SetEnvironmentVariableW(L"COMSPEC", szCmdExe);
50 errno = 0xDEADBEEF;
51 ret = _wsystem(L"echo This is a test");
52 ok_int(errno, 0);
53 ok_int(ret, 0);
54
56 errno = 0xDEADBEEF;
57 ret = _wsystem(L"InvalidCommandLine");
58 ok_int(errno, 0);
59 ok_int(ret, 1);
60
61 SetEnvironmentVariableW(L"COMSPEC", L"InvalidComSpec");
62 errno = 0xDEADBEEF;
63 ret = _wsystem(L"InvalidCommandLine");
64 ok_int(errno, 0);
65 ok_int(ret, 1);
66
67 SetEnvironmentVariableW(L"COMSPEC", szCmdExe);
68 errno = 0xDEADBEEF;
69 ret = _wsystem(L"InvalidCommandLine");
70 ok_int(errno, 0);
71 ok_int(ret, 1);
72}
#define START_TEST(x)
Definition: atltest.h:75
#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 SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define L(x)
Definition: ntvdm.h:50
#define errno
Definition: errno.h:18
_CRTIMP int __cdecl _wsystem(_In_opt_z_ const wchar_t *_Command)
#define _countof(array)
Definition: sndvol32.h:68
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180