mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 23:53:38 +00:00
cmd/tests: Make sure for /f doesn't loop infinitely on NULs.
This commit is contained in:
parent
e1c37c21da
commit
92e4cad8e0
|
@ -455,6 +455,24 @@ static int cmd_available(void)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void create_nul_test_file(void)
|
||||
{
|
||||
HANDLE file;
|
||||
DWORD size;
|
||||
BOOL bres;
|
||||
char contents[] = "a b c\nd e\0f\ng h i";
|
||||
|
||||
file = CreateFileA("nul_test_file", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
|
||||
if(file == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
bres = WriteFile(file, contents, ARRAYSIZE(contents), &size, NULL);
|
||||
ok(bres, "Could not write to file: %lu\n", GetLastError());
|
||||
CloseHandle(file);
|
||||
}
|
||||
|
||||
START_TEST(batch)
|
||||
{
|
||||
int argc;
|
||||
|
@ -479,9 +497,13 @@ START_TEST(batch)
|
|||
}
|
||||
shortpath_len = GetShortPathNameA(path, shortpath, ARRAY_SIZE(shortpath));
|
||||
|
||||
create_nul_test_file();
|
||||
|
||||
argc = winetest_get_mainargs(&argv);
|
||||
if(argc > 2)
|
||||
run_from_file(argv[2]);
|
||||
else
|
||||
EnumResourceNamesA(NULL, "TESTCMD", test_enum_proc, 0);
|
||||
|
||||
DeleteFileA("nul_test_file");
|
||||
}
|
||||
|
|
|
@ -1957,6 +1957,9 @@ FOR /F "delims=. tokens=1*" %%A IN (testfile) DO @echo 5:%%A,%%B
|
|||
FOR /F "delims=. tokens=2*" %%A IN (testfile) DO @echo 6:%%A,%%B
|
||||
FOR /F "delims=. tokens=3*" %%A IN (testfile) DO @echo 7:%%A,%%B
|
||||
del testfile
|
||||
rem file contains NUL, created by the .exe
|
||||
for /f %%A in (nul_test_file) DO echo %%A
|
||||
for /f "tokens=*" %%A in (nul_test_file) DO echo %%A
|
||||
|
||||
echo ------------ Testing del ------------
|
||||
echo abc > file
|
||||
|
|
|
@ -1315,6 +1315,8 @@ h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
|
|||
4:3.14,%B
|
||||
5:3,14
|
||||
6:14,
|
||||
a
|
||||
a b c
|
||||
------------ Testing del ------------
|
||||
deleting 'file'
|
||||
errorlevel is 0, good
|
||||
|
|
Loading…
Reference in a new issue