Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Knecht <rknecht@pm.me>2022-04-18 15:54:20 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2022-06-30 18:18:12 +0300
commit20a4f70ecaad79bb932af09b7317a058872cd867 (patch)
treeaaf6a3b29f415615dc7d185b041bc0a31ae98360 /testsuite
parent2617a5e4c600b4577b2c18f794701276e55da43b (diff)
tree: new applet
Adds the tree program to list directories and files in a tree structure. function old new delta tree_print - 343 +343 scandir64 - 330 +330 scandir - 330 +330 tree_main - 86 +86 .rodata 105150 105228 +78 packed_usage 34511 34557 +46 alphasort64 - 31 +31 alphasort - 31 +31 strcoll - 5 +5 applet_names 2801 2806 +5 applet_main 1616 1620 +4 applet_suid 101 102 +1 applet_install_loc 202 203 +1 ------------------------------------------------------------------------------ (add/remove: 11/0 grow/shrink: 6/0 up/down: 1291/0) Total: 1291 bytes Signed-off-by: Roger Knecht <rknecht@pm.me> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/tree.tests100
1 files changed, 100 insertions, 0 deletions
diff --git a/testsuite/tree.tests b/testsuite/tree.tests
new file mode 100755
index 000000000..4f4a9e30b
--- /dev/null
+++ b/testsuite/tree.tests
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# Copyright 2022 by Roger Knecht <rknecht@pm.me>
+# Licensed under GPLv2, see file LICENSE in this source tree.
+
+. ./testing.sh -v
+
+# testing "description" "command" "result" "infile" "stdin"
+
+testing "tree error opening dir" \
+ "tree tree.tempdir" \
+ "\
+tree.tempdir [error opening dir]\n\
+\n\
+0 directories, 0 files\n" \
+ "" ""
+
+mkdir -p tree2.tempdir
+touch tree2.tempdir/testfile
+
+testing "tree single file" \
+ "cd tree2.tempdir && tree" \
+ "\
+.\n\
+└── testfile\n\
+\n\
+0 directories, 1 files\n" \
+ "" ""
+
+mkdir -p tree3.tempdir/test1 \
+ tree3.tempdir/test2/a \
+ tree3.tempdir/test2/b \
+ tree3.tempdir/test3/c \
+ tree3.tempdir/test3/d
+
+touch tree3.tempdir/test2/a/testfile1 \
+ tree3.tempdir/test2/a/testfile2 \
+ tree3.tempdir/test2/a/testfile3 \
+ tree3.tempdir/test2/b/testfile4 \
+ tree3.tempdir/test3/c/testfile5 \
+ tree3.tempdir/test3/d/testfile6 \
+ tree3.tempdir/test3/d/.testfile7
+
+(cd tree3.tempdir/test2/a && ln -s ../b/testfile4 .)
+(cd tree3.tempdir/test2/b && ln -s ../../test3 .)
+
+testing "tree nested directories and files" \
+ "cd tree3.tempdir && tree" \
+ "\
+.\n\
+├── test1\n\
+├── test2\n\
+│   ├── a\n\
+│   │   ├── testfile1\n\
+│   │   ├── testfile2\n\
+│   │   ├── testfile3\n\
+│   │   └── testfile4 -> ../b/testfile4\n\
+│   └── b\n\
+│   ├── test3 -> ../../test3\n\
+│   └── testfile4\n\
+└── test3\n\
+ ├── c\n\
+ │   └── testfile5\n\
+ └── d\n\
+ └── testfile6\n\
+\n\
+7 directories, 8 files\n" \
+ "" ""
+#note: tree v2.0.1 says "8 directories, 7 files":
+#it counts "test3 -> ../../test3" as a directory, even though it does not follow this symlink
+
+testing "tree multiple directories" \
+ "tree tree2.tempdir tree3.tempdir" \
+ "\
+tree2.tempdir\n\
+└── testfile\n\
+tree3.tempdir\n\
+├── test1\n\
+├── test2\n\
+│   ├── a\n\
+│   │   ├── testfile1\n\
+│   │   ├── testfile2\n\
+│   │   ├── testfile3\n\
+│   │   └── testfile4 -> ../b/testfile4\n\
+│   └── b\n\
+│   ├── test3 -> ../../test3\n\
+│   └── testfile4\n\
+└── test3\n\
+ ├── c\n\
+ │   └── testfile5\n\
+ └── d\n\
+ └── testfile6\n\
+\n\
+7 directories, 9 files\n" \
+ "" ""
+#note: tree v2.0.1 says "8 directories, 7 files" (not "8 files", probably a/testfile4 -> ../b/testfile4 and b/testfile4 are counted as one file, not 2?)
+
+rm -rf tree.tempdir tree2.tempdir tree3.tempdir
+
+exit $FAILCOUNT