[PATCH] programs/cmd/tests: test paths which length exceeds MAX_PATH

Eric Pouech eric.pouech at gmail.com
Thu Jan 20 02:26:23 CST 2022


Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 programs/cmd/tests/test_builtins.cmd     |   20 ++++++++++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |    4 ++++
 2 files changed, 24 insertions(+)

diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 47b028207ac..a4cb8ec100c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -3333,6 +3333,26 @@ if errorlevel 1 echo Normal+tab+garbage drive change failed
 
 popd
 
+echo ------------ Testing length wrt. MAX_PATH ------------
+rem native cmd limits all path lengths to MAX_PATH=260
+rem so cannot create more than 23 10-letter subdirs:
+rem    260-2(C:)-1(\0)=23*11(\abcdefghij)+5
+pushd
+set depth=30
+for /L %d in (0,1,30) do (
+  mkdir abcdefghij
+  if errorlevel 0 (
+    cd abcdefghij
+    set depth=%d
+  )
+)
+popd
+if depth gtr 23 (echo Failure) else echo Success
+rem even relative paths are transformed to absolute, and tested against MAX_PATH
+echo abc > 0123456789
+if exist 0123456789 (echo Failure) else echo Success
+popd
+rmdir /s /q abcdefghij
 echo ------------ Testing combined CALLs/GOTOs ------------
 echo @echo off>foo.cmd
 echo goto :eof>>foot.cmd
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 4c7bc3e0c02..b6fc2fda894 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1687,6 +1687,10 @@ Normal+space+garbage
 Quoted should fail
 Normal+tab
 Normal+tab+garbage
+------------ Testing length wrt. MAX_PATH ------------
+ at pwd@
+ at todo_wine@Success
+ at todo_wine@Success
 ------------ Testing combined CALLs/GOTOs ------------
 world
 cheball




More information about the wine-devel mailing list