diff options
-rwxr-xr-x | apts | 53 | ||||
-rw-r--r-- | tests/lsof | 3 | ||||
-rw-r--r-- | tests/sed | 4 |
3 files changed, 60 insertions, 0 deletions
@@ -0,0 +1,53 @@ +#!/bin/sh + +# Get file to output to +program=$0 + +usage() { + echo "Usage: $program outputfile <package>" + exit 1 +} + +# parse opts +while getopts "h" opt; do + case "$opt" in + h) usage;; + esac +done + +OUTFILE=$1 + +# are there any file arguments +if [ $# -eq 0 ]; then + echo "no outfile specified" + usage +fi + +#remove opts so that package is $@ +shift $(( $OPTIND - 1 )) + +# shift once more +shift + +# if there aren't any args besides outfile test all packages +if [ $# -eq 0 ]; + then echo "All packages to be tested" && for package in `ls ./tests`; + do echo "Testing $1 apk" && /bin/sh -e ./tests/$1 >> "$OUTFILE" 2>&1 && echo "$1 passed tests" >> "$OUTFILE" && echo "$1 passed tests"; + done && exit 0; +fi + +# If script still running, there's args, so test all specified packages +i=1 +while [ $# -gt 0 ]; do + echo "file number $i: $1" + PACKAGE=$1 + # does testing file exist + test -e ./tests/$PACKAGE + if [ "$?" == "1" ]; + then echo "Testing file for $PACKAGE does not exist"; + # if testing file exists, then keep running + else echo "Testing $PACKAGE apk" && /bin/sh -e ./tests/$PACKAGE >> "$OUTFILE" 2>&1 && echo "$PACKAGE passed tests" && exit 0;i + fi + i=$(( $i + 1 )) + shift +done diff --git a/tests/lsof b/tests/lsof new file mode 100644 index 0000000..3c49a22 --- /dev/null +++ b/tests/lsof @@ -0,0 +1,3 @@ + apk_add $@ + lsof + apk_del $@ diff --git a/tests/sed b/tests/sed new file mode 100644 index 0000000..0d1b744 --- /dev/null +++ b/tests/sed @@ -0,0 +1,4 @@ + apk_add $@ + echo "hello" | sed 's/hello/world/g' | grep 'world' + apk_del $@ + [ `readlink /bin/sed` = /bin/busybox ] |