aboutsummaryrefslogtreecommitdiff
path: root/tests/file.test
blob: 2d8f04b61f56867768596fc60fafa75247547d4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

touch empty
echo "#!/bin/bash" > bash.script
echo "#!  /bin/bash" > bash.script2
echo "#!  /usr/bin/env python" > env.python.script
echo "Hello, world!" > ascii
echo "cafebabe000000310000" | xxd -r -p > java.class
echo "6465780a3033350038ca8f6ce910f94e" | xxd -r -p > android.dex
ln -s java.class symlink

testing "empty" "file empty" "empty: empty\n" "" ""
testing "bash.script" "file bash.script" "bash.script: /bin/bash script\n" "" ""
testing "bash.script with spaces" "file bash.script2" "bash.script2: /bin/bash script\n" "" ""
testing "env python script" "file env.python.script" "env.python.script: python script\n" "" ""
testing "ascii" "file ascii" "ascii: ASCII text\n" "" ""
testing "java class" "file java.class" "java.class: Java class file, version 49.0 (Java 1.5)\n" "" ""
testing "Android .dex" "file android.dex" "android.dex: Android dex file, version 035\n" "" ""
testing "symlink" "file symlink" "symlink: symbolic link\n" "" ""
testing "symlink -h" "file -h symlink" "symlink: symbolic link\n" "" ""
testing "symlink -L" "file -L symlink" "symlink: Java class file, version 49.0 (Java 1.5)\n" "" ""

testing "- pipe" "cat java.class | file -" "-: Java class file, version 49.0 (Java 1.5)\n" "" ""
testing "- redirect" "file - <java.class" "-: Java class file, version 49.0 (Java 1.5)\n" "" ""

testing "/dev/zero" "file /dev/zero" "/dev/zero: character special\n" "" ""
testing "- </dev/zero" "file - </dev/zero" "-: data\n" "" ""

rm empty bash.script bash.script2 env.python.script ascii java.class android.dex