From 6e92889aa61d1bb3e3cd6348691bda0bcead37a2 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 1 Mar 2016 18:56:31 +0000 Subject: [PATCH] [CMD_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912 svn path=/trunk/; revision=70845 --- rostests/winetests/cmd/batch.c | 55 ++++++------ rostests/winetests/cmd/test_builtins.cmd | 89 ++++++++++++++++---- rostests/winetests/cmd/test_builtins.cmd.exp | 10 ++- 3 files changed, 108 insertions(+), 46 deletions(-) diff --git a/rostests/winetests/cmd/batch.c b/rostests/winetests/cmd/batch.c index f53af5edacc..01c55d74a12 100644 --- a/rostests/winetests/cmd/batch.c +++ b/rostests/winetests/cmd/batch.c @@ -274,11 +274,11 @@ static const char *compare_line(const char *out_line, const char *out_end, const static void test_output(const char *out_data, DWORD out_size, const char *exp_data, DWORD exp_size) { - const char *out_ptr = out_data, *exp_ptr = exp_data, *out_nl, *exp_nl, *err; + const char *out_ptr = out_data, *exp_ptr = exp_data, *out_nl, *exp_nl, *err = NULL; DWORD line = 0; static const char todo_wine_cmd[] = {'@','t','o','d','o','_','w','i','n','e','@'}; static const char resync_cmd[] = {'-','-','-'}; - BOOL is_todo_wine, is_out_resync, is_exp_resync; + BOOL is_todo_wine, is_out_resync = FALSE, is_exp_resync = FALSE; while(out_ptr < out_data+out_size && exp_ptr < exp_data+exp_size) { line++; @@ -288,32 +288,32 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da is_todo_wine = (exp_ptr+sizeof(todo_wine_cmd) <= exp_nl && !memcmp(exp_ptr, todo_wine_cmd, sizeof(todo_wine_cmd))); - if (is_todo_wine) { + if (is_todo_wine) exp_ptr += sizeof(todo_wine_cmd); - winetest_start_todo("wine"); + + todo_wine_if(is_todo_wine) + { + is_exp_resync=(exp_ptr+sizeof(resync_cmd) <= exp_nl && + !memcmp(exp_ptr, resync_cmd, sizeof(resync_cmd))); + is_out_resync=(out_ptr+sizeof(resync_cmd) <= out_nl && + !memcmp(out_ptr, resync_cmd, sizeof(resync_cmd))); + + err = compare_line(out_ptr, out_nl, exp_ptr, exp_nl); + if(err == out_nl) + ok(0, "unexpected end of line %d (got '%.*s', wanted '%.*s')\n", + line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr); + else if(err == exp_nl) + ok(0, "excess characters on line %d (got '%.*s', wanted '%.*s')\n", + line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr); + else if (!err && is_todo_wine && is_out_resync && is_exp_resync) + /* Consider that the todo_wine was to deal with extra lines, + * not for the resync line itself + */ + err = NULL; + else + ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n", + (err ? *err : 0), (err ? (int)(err-out_ptr) : -1), line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr); } - is_exp_resync=(exp_ptr+sizeof(resync_cmd) <= exp_nl && - !memcmp(exp_ptr, resync_cmd, sizeof(resync_cmd))); - is_out_resync=(out_ptr+sizeof(resync_cmd) <= out_nl && - !memcmp(out_ptr, resync_cmd, sizeof(resync_cmd))); - - err = compare_line(out_ptr, out_nl, exp_ptr, exp_nl); - if(err == out_nl) - ok(0, "unexpected end of line %d (got '%.*s', wanted '%.*s')\n", - line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr); - else if(err == exp_nl) - ok(0, "excess characters on line %d (got '%.*s', wanted '%.*s')\n", - line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr); - else if (!err && is_todo_wine && is_out_resync && is_exp_resync) - /* Consider that the todo_wine was to deal with extra lines, - * not for the resync line itself - */ - err = NULL; - else - ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n", - (err ? *err : 0), (err ? (int)(err-out_ptr) : -1), line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr); - - if(is_todo_wine) winetest_end_todo("wine"); if (is_exp_resync && err && is_todo_wine) { @@ -321,7 +321,8 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da /* If we rewind to the beginning of the line, don't increment line number */ line--; } - else if (!is_exp_resync || !err) + else if (!is_exp_resync || !err || + (is_exp_resync && is_out_resync && err)) { exp_ptr = exp_nl+1; if(exp_nl+1 < exp_data+exp_size && exp_nl[0] == '\r' && exp_nl[1] == '\n') diff --git a/rostests/winetests/cmd/test_builtins.cmd b/rostests/winetests/cmd/test_builtins.cmd index 0a8a4f47131..cf2559aec48 100644 --- a/rostests/winetests/cmd/test_builtins.cmd +++ b/rostests/winetests/cmd/test_builtins.cmd @@ -952,11 +952,11 @@ goto :TestForR del temp.bat 2>nul call :WriteLine set WINE_found=N for /l %%i in (1,1,%WINE_expectedresults%) do ( - call :WriteLine if "%%%%WINE_expectedresults.%%i%%%%"=="%%%%1" set WINE_found=Y + call :WriteLine if "%%%%WINE_expectedresults.%%i%%%%"=="%%%%~1" set WINE_found=Y call :WriteLine if "%%%%WINE_found%%%%"=="Y" set WINE_expectedresults.%%i= call :WriteLine if "%%%%WINE_found%%%%"=="Y" goto :eof ) -call :WriteLine echo Got unexpected result: "%%%%1" +call :WriteLine echo Got unexpected result: "%%%%~1" goto :eof :WriteLine @@ -973,7 +973,7 @@ del temp.bat 2>nul goto :eof :TestForR -rem %CD% does not tork on NT4 so use the following workaround +rem %CD% does not work on NT4 so use the following workaround for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi echo --- for /R @@ -984,7 +984,7 @@ set WINE_expectedresults.2=%WINE_CURDIR%\bar\. set WINE_expectedresults.3=%WINE_CURDIR%\baz\. set WINE_expectedresults.4=%WINE_CURDIR%\foo\. call :SetExpected -for /R %%i in (.) do call temp.bat %%i +for /R %%i in (.) do call temp.bat "%%i" call :ValidateExpected echo Plain directory enumeration from provided root @@ -995,7 +995,7 @@ set WINE_expectedresults.3=%WINE_CURDIR%\baz\. set WINE_expectedresults.4=%WINE_CURDIR%\foo\. if "%CD%"=="" goto :SkipBrokenNT4 call :SetExpected -for /R "%WINE_CURDIR%" %%i in (.) do call temp.bat %%i +for /R "%WINE_CURDIR%" %%i in (.) do call temp.bat "%%i" call :ValidateExpected :SkipBrokenNT4 @@ -1004,7 +1004,7 @@ set WINE_expectedresults=2 set WINE_expectedresults.1=%WINE_CURDIR%\baz\bazbaz set WINE_expectedresults.2=%WINE_CURDIR%\bazbaz call :SetExpected -for /R %%i in (baz*) do call temp.bat %%i +for /R %%i in (baz*) do call temp.bat "%%i" call :ValidateExpected echo File enumeration from provided root @@ -1012,7 +1012,7 @@ set WINE_expectedresults=2 set WINE_expectedresults.1=%WINE_CURDIR%\baz\bazbaz set WINE_expectedresults.2=%WINE_CURDIR%\bazbaz call :SetExpected -for /R %%i in (baz*) do call temp.bat %%i +for /R %%i in (baz*) do call temp.bat "%%i" call :ValidateExpected echo Mixed enumeration @@ -1024,7 +1024,7 @@ set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz set WINE_expectedresults.5=%WINE_CURDIR%\bazbaz set WINE_expectedresults.6=%WINE_CURDIR%\foo\. call :SetExpected -for /R %%i in (. baz*) do call temp.bat %%i +for /R %%i in (. baz*) do call temp.bat "%%i" call :ValidateExpected echo Mixed enumeration from provided root @@ -1036,7 +1036,7 @@ set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz set WINE_expectedresults.5=%WINE_CURDIR%\bazbaz set WINE_expectedresults.6=%WINE_CURDIR%\foo\. call :SetExpected -for /R %%i in (. baz*) do call temp.bat %%i +for /R %%i in (. baz*) do call temp.bat "%%i" call :ValidateExpected echo With duplicates enumeration @@ -1054,7 +1054,7 @@ set WINE_expectedresults.10=%WINE_CURDIR%\foo\bazbaz set WINE_expectedresults.11=%WINE_CURDIR%\foo\fred set WINE_expectedresults.12=%WINE_CURDIR%\fred call :SetExpected -for /R %%i in (baz* bazbaz fred ba*) do call temp.bat %%i +for /R %%i in (baz* bazbaz fred ba*) do call temp.bat "%%i" call :ValidateExpected echo Strip missing wildcards, keep unwildcarded names @@ -1066,7 +1066,7 @@ set WINE_expectedresults.4=%WINE_CURDIR%\bazbaz set WINE_expectedresults.5=%WINE_CURDIR%\foo\jim set WINE_expectedresults.6=%WINE_CURDIR%\jim call :SetExpected -for /R %%i in (baz* fred* jim) do call temp.bat %%i +for /R %%i in (baz* fred* jim) do call temp.bat "%%i" call :ValidateExpected echo for /R passed @@ -1493,6 +1493,28 @@ for /f "tokens=3,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k cd .. rd /s/q foobar +echo ------------ Testing del ------------ +echo abc > file +echo deleting 'file' +del file +if errorlevel 0 ( + echo errorlevel is 0, good +) else ( + echo unexpected errorlevel, got %errorlevel% +) +if not exist file ( + echo successfully deleted 'file' +) else ( + echo error deleting 'file' +) +echo attempting to delete 'file', even though it is not present +del file +if errorlevel 0 ( + echo errorlevel is 0, good +) else ( + echo unexpected errorlevel, got %errorlevel% +) + echo ------------ Testing del /a ------------ del /f/q *.test > nul echo r > r.test @@ -1928,6 +1950,10 @@ if exist baz\lala (echo file created in read-only dir) else echo file not create cd .. & rd /s/q foobar echo ------------ Testing assoc ------------ +rem Modifying associations requires some privileges... +net session >nul 2>&1 +if errorlevel 1 goto :SkipAssoc + rem FIXME Can't test error messages in the current test system, so we have to use some kludges rem FIXME Revise once || conditional execution is fixed mkdir foobar & cd foobar @@ -1956,8 +1982,25 @@ cmd /c tmp.cmd > baz type baz echo --- cd .. & rd /s/q foobar +goto ContinueFType +:SkipAssoc +echo --- setting association +echo --- +echo .foo=bar +echo .foo=bar +echo +++ +echo .foo=bar +echo --- resetting association +echo --- +echo +++ +echo --- + +:ContinueFType echo ------------ Testing ftype ------------ +rem Modifying associations requires some privileges... +net session >nul 2>&1 +if errorlevel 1 goto :SkipFType rem FIXME Can't test error messages in the current test system, so we have to use some kludges rem FIXME Revise once || conditional execution is fixed mkdir foobar & cd foobar @@ -1998,7 +2041,19 @@ regedit /s regCleanup.reg set WINE_FOO= endlocal cd .. & rd /s/q foobar +goto ContinueCall +:SkipFType +echo --- setting association +echo --- +echo footype=foo_opencmd +echo .foo=footype +echo footype=foo_opencmd +echo +++ +echo footype=foo_opencmd +echo --- resetting association +echo original value +:ContinueCall echo ------------ Testing CALL ------------ mkdir foobar & cd foobar echo --- external script @@ -2435,7 +2490,7 @@ cmd /e:oN /C tmp.cmd rem FIXME: creating file before setting envvar value to prevent parsing-time evaluation (due to EnableDelayedExpansion not being implemented/available yet) echo --- setlocal with corresponding endlocal -rem %CD% does not tork on NT4 so use the following workaround +rem %CD% does not work on NT4 so use the following workaround for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi echo @echo off> test.cmd echo echo %%WINE_VAR%%>> test.cmd @@ -2465,7 +2520,7 @@ echo cd foobar2>> test.cmd echo echo %%WINE_VAR%%>> test.cmd echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd set WINE_VAR=globalval -rem %CD% does not tork on NT4 so use the following workaround +rem %CD% does not work on NT4 so use the following workaround for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi call test.cmd echo %WINE_VAR% @@ -2477,7 +2532,7 @@ echo --- setlocal within same batch program set WINE_var1=one set WINE_var2= set WINE_var3= -rem %CD% does not tork on NT4 so use the following workaround +rem %CD% does not work on NT4 so use the following workaround for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi setlocal set WINE_var2=two @@ -2509,7 +2564,7 @@ echo --- Mismatched set and end locals mkdir foodir2 2>nul mkdir foodir3 2>nul mkdir foodir4 2>nul -rem %CD% does not tork on NT4 so use the following workaround +rem %CD% does not work on NT4 so use the following workaround for /d %%i in (.) do set WINE_curdir=%%~dpnxi echo @echo off> 2set1end.cmd @@ -2542,7 +2597,7 @@ rem -- setlocal1 == this batch, should never be used inside a called routine setlocal set WINE_var=value2 cd foodir2 -call %WINE_CURDIR%\2set1end.cmd +call "%WINE_CURDIR%\2set1end.cmd" echo Finished: echo %WINE_VAR% for /d %%i in (.) do echo %%~dpnxi @@ -2557,7 +2612,7 @@ rem -- setlocal1 == this batch, should never be used inside a called routine setlocal set WINE_var=value2 cd foodir2 -call %WINE_CURDIR%\1set2end.cmd +call "%WINE_CURDIR%\1set2end.cmd" echo Finished: echo %WINE_VAR% for /d %%i in (.) do echo %%~dpnxi diff --git a/rostests/winetests/cmd/test_builtins.cmd.exp b/rostests/winetests/cmd/test_builtins.cmd.exp index b2221588c3b..7543b53959a 100644 --- a/rostests/winetests/cmd/test_builtins.cmd.exp +++ b/rostests/winetests/cmd/test_builtins.cmd.exp @@ -331,7 +331,7 @@ N @todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@'' ''@or_broken@'%~ai' ''@or_broken@'%~ai' -'--a------'@or_broken@'%~ai' +'--a------'@or_broken@'--a--------'@or_broken@'%~ai' '5'@or_broken@'%~zi' ''@or_broken@'%~ti' ''@or_broken@'%~ti' @@ -1009,6 +1009,12 @@ h=%h i=a j=b k=c l=d e f g m=%m n=%n o=%o@or_broken@h=%h i=a j=b k=c l=d e f g m h=%h i=a j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=a j=c k= l= m= n=%n o=%o 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 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 +------------ Testing del ------------ +deleting 'file' +errorlevel is 0, good +successfully deleted 'file' +attempting to delete 'file', even though it is not present +errorlevel is 0, good ------------ Testing del /a ------------ not-r.test not found after delete, good r.test found before delete, good @@ -1201,7 +1207,7 @@ passed --- a batch file can delete itself file correctly deleted --- a batch file can alter itself -@todo_wine@bar +bar ---------- Testing copy Passed: Found expected dummy.file Passed: Found expected dir1\file1