Subversion Repositories vgwhois

Rev

Go to most recent revision | Details | 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
 
16
ARGS=()
17
 
18
shuffle() {
19
	# http://stackoverflow.com/a/5533586
20
	local i tmp size max rand
21
 
22
	# $RANDOM % (i+1) is biased because of the limited range of $RANDOM
23
	# Compensate by using a range which is a multiple of the array size.
24
	size = ${#ARGS[*]}
25
	max = $(( 32768 / size * size ))
26
 
27
	for ((i=size-1; i>0; i--)); do
28
		while (( (rand=$RANDOM) >= max )); do :; done
29
		rand=$(( rand % (i+1) ))
30
		tmp=${ARGS[i]} ARGS[i]=${ARGS[rand]} ARGS[rand]=$tmp
31
	done
32
}
33
 
34
while read f; do
35
	if [ -z "$f" ]; then
36
		continue;
37
	fi
38
 
39
	echo "$f" | grep -E "\s*^#" > /dev/null
40
	if [ $? -eq 0 ]; then
41
		continue;
42
	fi
43
 
44
	# Warum? "tld jp" wird dann zu "tld"
45
	# query="$( basename $f )"
46
	query="$f";
47
 
48
	ARGS+=("$query")
49
done < "$DIR/../../config/testcases.list"
50
 
51
# TODO: does not work
52
#shuffle
53
 
54
"$DIR"/single $@ ${ARGS[@]}
55
exit $?