1#!/bin/sh
2
3VERBOSE=""
4THIS="seek-stress-test.sh"
5COLLECTION="$HOME"
6
7usage () {
8    echo >&2 "$THIS, stress oggz's seeking using a collection of Ogg files"
9    echo >&2
10    echo >&2 "Usage: $THIS [options] [directory]"
11    echo >&2
12    echo >&2 "If no directory is specified, $THIS defaults to reading all"
13    echo >&2 "Ogg files found in your home directory."
14    echo >&2
15    echo >&2 "Miscellaneous options"
16    echo >&2 "  -h, --help                  Display this help and exit"
17    echo >&2 "  -v, --verbose               Print informative messages"
18    echo >&2
19    exit 1
20}
21
22GETOPTEST=`getopt --version`
23SHORTOPTS="hv"
24
25case $GETOPTEST in
26getopt*) # GNU getopt
27    TEMP=`getopt -l help -l verbose -- +$SHORTOPTS $@`
28    ;;
29*) # POSIX getopt ?
30    TEMP=`getopt $SHORTOPTS $@`
31    ;;
32esac
33
34if test "$?" != "0"; then
35  usage
36fi
37
38eval set -- "$TEMP"
39
40while test "X$1" != "X--"; do
41    case "$1" in
42	    -v|--verbose)
43	    VERBOSE="--verbose"
44	    ;;
45	    -h|--help)
46	    usage
47	    ;;
48    esac
49    shift
50done
51
52# Check that all options parsed ok
53if test "x$1" != "x--"; then
54    usage
55fi
56shift #get rid of the "--"
57
58if test "x$1" != "x"; then
59    COLLECTION=$1
60fi
61
62echo "Stress testing Oggz seeking on all Ogg files in $COLLECTION..."
63
64for ext in ogg spx anx; do
65    CMD="find $COLLECTION -follow -name '*.$ext'"
66    FILES="$FILES `eval $CMD`"
67done
68
69for i in $FILES; do
70    ./seek-stress $VERBOSE $i;
71done
72