Mercurial > hg > toybox
annotate tests/ls.test @ 1650:a740a876c76c draft
Cleanup pass on printf.
Alas, passing a union as the last argument to printf does not appear to work
reliably, and there's no obvious way to manually assemble varargs in a portable
manner. So I have to repeat the printf once for each data type. Oh well.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 11 Jan 2015 01:22:36 -0600 |
parents | 28b0987d4952 |
children |
rev | line source |
---|---|
1364
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
1 #!/bin/bash |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
2 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com> |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
4 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com> |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
5 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
6 [ -f testing.sh ] && . testing.sh |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
7 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
8 #testing "name" "command" "result" "infile" "stdin" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
9 #set -x |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
10 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
11 # Creating test-file/dir for testing ls |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
12 mkdir -p lstest/dir1 lstest/dir2 || exit 1 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
13 echo "test file1" > lstest/file1.txt |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
14 echo "test file2" > lstest/file2.txt |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
15 echo "hidden file1" > lstest/.hfile1 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
16 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
17 IN="cd lstest" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
18 OUT="cd .. " |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
19 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
20 testing "ls no argument" "$IN && ls; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
21 testing "ls with wild char" "$IN && ls file*; $OUT" "file1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
22 testing "ls with wild char - long listing" "$IN && ls -1 file*; $OUT" "file1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
23 testing "ls with -p" "$IN && ls -p; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
24 testing "ls with -a" "$IN && ls -a; $OUT" \ |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
25 ".\n..\ndir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
26 testing "ls with -A" "$IN && ls -A; $OUT" \ |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
27 "dir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
28 testing "ls with -d" "$IN && ls -d; $OUT" ".\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
29 testing "ls with wild char and -d *" "$IN && ls -d *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
30 testing "ls with -k" "$IN && ls -k; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
31 testing "ls with -m" "$IN && ls -m; $OUT" "dir1, dir2, file1.txt, file2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
32 testing "ls with -F" "$IN && ls -F; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
33 testing "ls with -dk *" "$IN && ls -dk *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
34 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
35 ln -s file1.txt lstest/slink |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
36 testing "ls softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' ; $OUT" \ |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
37 "file1.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
38 rm -f lstest/slink |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
39 |
1541
28b0987d4952
Test for ls -d from Isaac Dunham, and he pointed out -F also disables symlink following.
Rob Landley <rob@landley.net>
parents:
1485
diff
changeset
|
40 ln -s /dev/null/nosuchfile lstest/nosuchfile |
28b0987d4952
Test for ls -d from Isaac Dunham, and he pointed out -F also disables symlink following.
Rob Landley <rob@landley.net>
parents:
1485
diff
changeset
|
41 testing "ls with -d - broken softlink" "$IN && ls -d nosuchfile; $OUT" "nosuchfile\n" "" "" |
28b0987d4952
Test for ls -d from Isaac Dunham, and he pointed out -F also disables symlink following.
Rob Landley <rob@landley.net>
parents:
1485
diff
changeset
|
42 rm -f lstest/nosuchfile |
28b0987d4952
Test for ls -d from Isaac Dunham, and he pointed out -F also disables symlink following.
Rob Landley <rob@landley.net>
parents:
1485
diff
changeset
|
43 |
1364
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
44 rm -rf lstest/* && mkdir -p lstest/dir1 && touch lstest/file1.txt |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
45 testing "ls nested recursively" "$IN && ls -R; $OUT" \ |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
46 ".:\ndir1\nfile1.txt\n\n./dir1:\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
47 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
48 rm -rf lstest/* && touch lstest/file1.txt && INODE=`stat -c %i lstest/file1.txt` |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
49 testing "ls with -i" "$IN && ls -i 2>/dev/null; $OUT" "$INODE file1.txt\n" "" "" |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
50 unset INODE |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
51 |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
52 # Removing test dir for cleanup purpose |
94677e7b6d97
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
53 rm -rf lstest |