cmd/tests: Add attrib tests

Frédéric Delanoy frederic.delanoy at
Wed Aug 24 05:53:21 CDT 2011

 programs/cmd/tests/test_builtins.cmd     |   61 ++++++++++++++++++++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |   20 ++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index b815e77..5839b8f 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -737,6 +737,67 @@ if not exist bar\baz (echo bar\baz removed) else echo bar\baz not removed!
 cd ..
 rd /s/q foobaz
+echo ------------ Testing attrib --------------
+rem FIXME Add tests for archive, hidden and system attributes + mixed attributes modifications
+mkdir foobar & cd foobar
+echo foo original contents> foo
+attrib foo
+echo > bar
+echo ... read-only attribute
+rem Read-only files cannot be altered or deleted, unless forced
+attrib +R foo
+attrib foo
+dir /Ar /B
+echo bar>> foo
+type foo
+del foo > NUL 2>&1
+if exist foo (
+    echo Read-only file not deleted
+) else (
+    echo Should not delete read-only file!
+del /F foo
+if not exist foo (
+    echo Read-only file forcibly deleted
+) else (
+    echo Should delete read-only file with del /F!
+    attrib -r foo
+    del foo
+cd ..
+rd /s/q foobar
+echo ... recursive behaviour
+mkdir foobar\baz & cd foobar
+echo > level1
+echo > whatever
+echo > baz\level2
+attrib baz\level2
+cd ..
+attrib +R l*vel? /S > nul 2>&1
+cd foobar
+attrib level1
+attrib baz\level2
+echo > bar
+attrib bar
+cd ..
+rd /s/q foobar
+echo ... folders processing
+mkdir foobar
+attrib foobar
+cd foobar
+mkdir baz
+echo toto> baz\toto
+attrib +r baz /s /d > nul 2>&1
+attrib baz
+attrib baz\toto
+echo lulu>>baz\toto
+type baz\toto
+echo > baz\lala
+rem Oddly windows allows file creation in a read-only directory...
+if exist baz\lala (echo file created in read-only dir) else echo file not created
+cd ..
+rd /s/q foobar
 echo ------------ Testing CALL --------------
 mkdir foobar & cd foobar
 rem External script
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 18ba102..86aa7e2 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -434,6 +434,26 @@ foo removed
 bar removed
 foobar removed
 bar\baz removed
+------------ Testing attrib --------------
+ at todo_wine@A            @pwd@\foobar\foo at or_broken@A          @pwd@\foobar\foo
+... read-only attribute
+ at todo_wine@A    R       @pwd@\foobar\foo at or_broken@A    R     @pwd@\foobar\foo
+foo original contents
+Read-only file not deleted
+Read-only file forcibly deleted
+... recursive behaviour
+ at todo_wine@A            @pwd@\foobar\baz\level2 at or_broken@A          @pwd@\foobar\baz\level2
+ at todo_wine@A    R       @pwd@\foobar\level1 at or_broken@A    R     @pwd@\foobar\level1
+ at todo_wine@A    R       @pwd@\foobar\baz\level2 at or_broken@A    R     @pwd@\foobar\baz\level2
+ at todo_wine@A            @pwd@\foobar\bar at or_broken@A          @pwd@\foobar\bar
+... folders processing
+ at todo_wine@             @pwd@\foobar at or_broken@           @pwd@\foobar
+ at todo_wine@     R       @pwd@\foobar\baz at or_broken@     R     @pwd@\foobar\baz at or_broken@           @pwd@\foobar\baz
+ at todo_wine@A            @pwd@\foobar\baz\toto at or_broken@A          @pwd@\foobar\baz\toto
+file created in read-only dir
 ------------ Testing CALL --------------
 foo at space@
 @todo_wine at foo 8

More information about the wine-patches mailing list