Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | #!/bin/bash |
2 | |||
3 | # |
||
4 | # generic Whois - Maintenance Framework: Testcases |
||
5 | # |
||
6 | # (c) 2012-2014 Daniel Marschall, ViaThinkSoft [www.viathinksoft.de] |
||
7 | # |
||
8 | # Distribution, usage etc. pp. regulated by the current version of GPL. |
||
9 | # |
||
10 | # |
||
11 | # Version 2014-08-19 |
||
12 | # |
||
13 | |||
14 | DIR=$( dirname "$0" ) |
||
15 | |||
4 | daniel-mar | 16 | TESTCASES_LIST="$DIR/../../config/testcases.list" |
17 | |||
2 | daniel-mar | 18 | ARGS=() |
19 | |||
20 | shuffle() { |
||
21 | # http://stackoverflow.com/a/5533586 |
||
22 | local i tmp size max rand |
||
23 | |||
24 | # $RANDOM % (i+1) is biased because of the limited range of $RANDOM |
||
25 | # Compensate by using a range which is a multiple of the array size. |
||
26 | size = ${#ARGS[*]} |
||
27 | max = $(( 32768 / size * size )) |
||
28 | |||
29 | for ((i=size-1; i>0; i--)); do |
||
30 | while (( (rand=$RANDOM) >= max )); do :; done |
||
31 | rand=$(( rand % (i+1) )) |
||
32 | tmp=${ARGS[i]} ARGS[i]=${ARGS[rand]} ARGS[rand]=$tmp |
||
33 | done |
||
34 | } |
||
35 | |||
36 | while read f; do |
||
37 | if [ -z "$f" ]; then |
||
38 | continue; |
||
39 | fi |
||
40 | |||
41 | echo "$f" | grep -E "\s*^#" > /dev/null |
||
42 | if [ $? -eq 0 ]; then |
||
43 | continue; |
||
44 | fi |
||
45 | |||
46 | # Warum? "tld jp" wird dann zu "tld" |
||
47 | # query="$( basename $f )" |
||
48 | query="$f"; |
||
49 | |||
50 | ARGS+=("$query") |
||
4 | daniel-mar | 51 | done < "$TESTCASES_LIST" |
2 | daniel-mar | 52 | |
53 | # TODO: does not work |
||
54 | #shuffle |
||
55 | |||
56 | "$DIR"/single $@ ${ARGS[@]} |
||
57 | exit $? |