| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
cd ${AUTOPKGTEST_TMP} |
| 6 |
|
| 7 |
# Testing which |
| 8 |
mkdir ../Which && cd ../Which |
| 9 |
which sh |
| 10 |
|
| 11 |
PATH="$PATH:/tmp" |
| 12 |
cp /usr/bin/which /tmp |
| 13 |
with_a_arg=$(which -a which) |
| 14 |
echo "$with_a_arg" |
| 15 |
without_a_arg=$(which which) |
| 16 |
echo "$without_a_arg" |
| 17 |
if [ "$with_a_arg" != "$without_a_arg" ]; then |
| 18 |
echo "Success! 'which -a' works as expected" |
| 19 |
fi |
| 20 |
|
| 21 |
which fakeCommand 2>&1 || echo "Success! 'which fakeCommand' does not exist" |
| 22 |
|
| 23 |
which -s fakeCommand || echo "Success! 'which -s fakeCommand' does not exist" |
| 24 |
which -s fakeCommand &> error_output.txt |
| 25 |
error_length=$(wc -l error_output.txt) |
| 26 |
if [ "$error_length" = "0 error_output.txt" ]; then |
| 27 |
echo "Success! 'which -s fakeCommand' does not print error output" |
| 28 |
fi |
| 29 |
|
| 30 |
which -s which &> standard_output.txt |
| 31 |
standard_length=$(wc -l standard_output.txt) |
| 32 |
if [ "$standard_length" = "0 standard_output.txt" ]; then |
| 33 |
echo "Success! 'which -s which' does not print standard output" |
| 34 |
fi |
| 35 |
|
| 36 |
which -sa which &> standard_all_output.txt |
| 37 |
standard_all_length=$(wc -l standard_all_output.txt) |
| 38 |
if [ "$standard_all_length" = "0 standard_all_output.txt" ]; then |
| 39 |
echo "Success! 'which -sa which' does not print standard output" |
| 40 |
fi |
| 41 |
|
| 42 |
which -f sh 2>&1 || echo "Success! '-f' is an invalid option" |
| 43 |
|
| 44 |
# Testing ischroot |
| 45 |
ischroot --version |
| 46 |
ischroot --help |
| 47 |
|
| 48 |
# Testing tempfile |
| 49 |
mkdir ../Tempfile && cd ../Tempfile |
| 50 |
tempfile --version 2>&1 |
| 51 |
tempfile --help 2>&1 |
| 52 |
|
| 53 |
tempFile=$(tempfile) 2>&1 |
| 54 |
ls -la "$tempFile" && \ |
| 55 |
echo "Success! Temporary file created" |
| 56 |
|
| 57 |
tempFile=$(tempfile -n temporary) 2>&1 |
| 58 |
ls -la "$tempFile" | grep -- "temporary" && \ |
| 59 |
echo "Success! Name was set properly" |
| 60 |
|
| 61 |
tempFile=$(tempfile -p my_ -s _file) 2>&1 |
| 62 |
ls -la "$tempFile" | grep -- "my_" && \ |
| 63 |
echo "Success! Prefix was set properly" |
| 64 |
ls -la "$tempFile" | grep -- "_file" && \ |
| 65 |
echo "Success! Suffix was set properly" |
| 66 |
|
| 67 |
mkdir tmp |
| 68 |
tempFile=$(tempfile -d tmp) 2>&1 |
| 69 |
ls -la "$tempFile" | grep -- "tmp/" && \ |
| 70 |
echo "Success! tempfile created in 'tmp/' directory" |
| 71 |
|
| 72 |
tempFile=$(tempfile -m 644) 2>&1 |
| 73 |
ls -la "$tempFile" | grep -- "-rw-r--r--" && \ |
| 74 |
echo "Success! File permissions set as 644, not 600" |
| 75 |
|
| 76 |
# Testing savelog |
| 77 |
mkdir ../Savelog && cd ../Savelog |
| 78 |
|
| 79 |
savelog -h |
| 80 |
|
| 81 |
savelog -t temp |
| 82 |
ls -la temp |
| 83 |
ls -la temp.0 |
| 84 |
|
| 85 |
ls -la temp | grep -- "-rw-r--r--" && \ |
| 86 |
echo "Log file permissions set to 644" |
| 87 |
savelog -m 755 temp |
| 88 |
ls -la temp.1.gz |
| 89 |
ls -la temp | grep -- "-rwxr-xr-x" && \ |
| 90 |
echo "Success! Log file permissions changed to 755" |
| 91 |
|
| 92 |
savelog temp |
| 93 |
ls -la temp.1.gz && ls -la temp.2.gz && \ |
| 94 |
echo "Success! Log file was rotated and compressed" |
| 95 |
|
| 96 |
savelog -l temp |
| 97 |
ls -la temp.1.gz 2>&1 || ls -la temp.1 && \ |
| 98 |
ls -la temp.2.gz && ls -la temp.3.gz && \ |
| 99 |
echo "Success! Log file was rotated and not compressed" |