mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 05:52:57 +00:00
[MSVCRT][CRT_APITEST] Implement _wsystem (#5032)
Implement _wsystem(), by referring system(). Improve system(). Use WaitForSingleObject in system() and _wsystem(). Check existence of COMSPEC. Thanks ChatGPT.
This commit is contained in:
parent
72974d2bac
commit
f172503d57
6 changed files with 255 additions and 47 deletions
72
modules/rostests/apitests/crt/system.c
Normal file
72
modules/rostests/apitests/crt/system.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* PROJECT: ReactOS CRT
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Tests for system()
|
||||
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*/
|
||||
|
||||
#include <apitest.h>
|
||||
#include <apitest_guard.h>
|
||||
|
||||
START_TEST(system)
|
||||
{
|
||||
int ret;
|
||||
CHAR szCmdExe[MAX_PATH];
|
||||
|
||||
GetSystemDirectoryA(szCmdExe, _countof(szCmdExe));
|
||||
lstrcatA(szCmdExe, "\\cmd.exe");
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", NULL);
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system(NULL);
|
||||
ok_int(errno, 0xDEADBEEF);
|
||||
ok_int(ret, 1);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", "InvalidComSpec");
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system(NULL);
|
||||
ok_int(errno, 0xDEADBEEF);
|
||||
ok_int(ret, 1);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", szCmdExe);
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system(NULL);
|
||||
ok_int(errno, 0xDEADBEEF);
|
||||
ok_int(ret, 1);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", NULL);
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system("echo This is a test");
|
||||
ok_int(errno, 0);
|
||||
ok_int(ret, 0);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", "InvalidComSpec");
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system("echo This is a test");
|
||||
ok_int(errno, 0);
|
||||
ok_int(ret, 0);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", szCmdExe);
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system("echo This is a test");
|
||||
ok_int(errno, 0);
|
||||
ok_int(ret, 0);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", NULL);
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system("InvalidCommandLine");
|
||||
ok_int(errno, 0);
|
||||
ok_int(ret, 1);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", "InvalidComSpec");
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system("InvalidCommandLine");
|
||||
ok_int(errno, 0);
|
||||
ok_int(ret, 1);
|
||||
|
||||
SetEnvironmentVariableA("COMSPEC", szCmdExe);
|
||||
errno = 0xDEADBEEF;
|
||||
ret = system("InvalidCommandLine");
|
||||
ok_int(errno, 0);
|
||||
ok_int(ret, 1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue