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 11 START_TEST(_wsystem) 12 { 13 int ret; 14 WCHAR szCmdExe[MAX_PATH]; 15 16 GetSystemDirectoryW(szCmdExe, _countof(szCmdExe)); 17 lstrcatW(szCmdExe, L"\\cmd.exe"); 18 19 SetEnvironmentVariableW(L"COMSPEC", NULL); 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 37 SetEnvironmentVariableW(L"COMSPEC", NULL); 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 55 SetEnvironmentVariableW(L"COMSPEC", NULL); 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 } 73