diff options
Diffstat (limited to 'src/namestore/test_namestore_put_multiple.sh')
-rwxr-xr-x[-rw-r--r--] | src/namestore/test_namestore_put_multiple.sh | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/src/namestore/test_namestore_put_multiple.sh b/src/namestore/test_namestore_put_multiple.sh index f33fb1c3a..4c7340440 100644..100755 --- a/src/namestore/test_namestore_put_multiple.sh +++ b/src/namestore/test_namestore_put_multiple.sh | |||
@@ -24,25 +24,9 @@ if [ 0 -ne $ret ]; then | |||
24 | gnunet-identity -C randomtestingid | 24 | gnunet-identity -C randomtestingid |
25 | fi | 25 | fi |
26 | 26 | ||
27 | function minimize_ttl { | ||
28 | ttl=10000000 | ||
29 | arr=$1 | ||
30 | # parse each element and update ttl to smallest one | ||
31 | for i in "${arr[@]}" | ||
32 | do | ||
33 | currttl=$(echo -n "$i" | cut -d' ' -f1) | ||
34 | if [ "$currttl" -lt "$ttl" ] | ||
35 | then | ||
36 | ttl=$currttl | ||
37 | fi | ||
38 | |||
39 | done | ||
40 | echo "$ttl" | ||
41 | } | ||
42 | |||
43 | function get_record_type { | 27 | function get_record_type { |
44 | arr=$1 | 28 | arr=$1 |
45 | typ=$(echo -n "${arr[0]}" | cut -d' ' -f2) | 29 | typ=$(echo -n "${arr[0]}" | cut -d' ' -f1) |
46 | echo "$typ" | 30 | echo "$typ" |
47 | } | 31 | } |
48 | 32 | ||
@@ -59,10 +43,14 @@ function testing { | |||
59 | typ=$(get_record_type "${records[@]}") | 43 | typ=$(get_record_type "${records[@]}") |
60 | for i in "${records[@]}" | 44 | for i in "${records[@]}" |
61 | do | 45 | do |
62 | recordstring+="-R $i" | 46 | recordstring+="$i"$'\n' |
63 | done | 47 | done |
64 | #echo "$recordstring" | 48 | echo "$recordstring" |
65 | gnunet-namestore -z randomtestingid -n "$label" "$recordstring" 2>&1 /dev/null | 49 | gnunet-namestore -a -S <<EOF |
50 | $label.randomtestingid: | ||
51 | $recordstring | ||
52 | EOF | ||
53 | ret=$? | ||
66 | if [ 0 -ne $ret ]; then | 54 | if [ 0 -ne $ret ]; then |
67 | echo "failed to add record $label: $recordstring" | 55 | echo "failed to add record $label: $recordstring" |
68 | fi | 56 | fi |
@@ -75,26 +63,27 @@ function testing { | |||
75 | # TEST CASES | 63 | # TEST CASES |
76 | # 1 | 64 | # 1 |
77 | echo "Testing adding of single A record with -R" | 65 | echo "Testing adding of single A record with -R" |
66 | declare -a arr=('A 1200 [r] 127.0.0.1') | ||
78 | testing test1 "${arr[@]}" | 67 | testing test1 "${arr[@]}" |
79 | # 2 | 68 | # 2 |
80 | echo "Testing adding of multiple A records with -R" | 69 | echo "Testing adding of multiple A records with -R" |
81 | declare -a arr=('1200 A n 127.0.0.1' '2400 A n 127.0.0.2') | 70 | declare -a arr=('A 1200 [r] 127.0.0.1' 'A 2400 [r] 127.0.0.2') |
82 | testing test2 "${arr[@]}" | 71 | testing test2 "${arr[@]}" |
83 | # 3 | 72 | # 3 |
84 | echo "Testing adding of multiple different records with -R" | 73 | echo "Testing adding of multiple different records with -R" |
85 | declare -a arr=('1200 A n 127.0.0.1' '2400 AAAA n 2002::') | 74 | declare -a arr=('A 1200 [r] 127.0.0.1' 'AAAA 2400 [r] 2002::') |
86 | testing test3 "${arr[@]}" | 75 | testing test3 "${arr[@]}" |
87 | # 4 | 76 | # 4 |
88 | echo "Testing adding of single GNS2DNS record with -R" | 77 | echo "Testing adding of single GNS2DNS record with -R" |
89 | declare -a arr=('86400 GNS2DNS n gnu.org@127.0.0.1') | 78 | declare -a arr=('GNS2DNS 86400 [r] gnu.org@127.0.0.1') |
90 | testing test4 "${arr[@]}" | 79 | testing test4 "${arr[@]}" |
91 | # 5 | 80 | # 5 |
92 | echo "Testing adding of single GNS2DNS shadow record with -R" | 81 | echo "Testing adding of single GNS2DNS shadow record with -R" |
93 | declare -a arr=('86409 GNS2DNS s gnu.org@127.0.0.250') | 82 | declare -a arr=('GNS2DNS 86409 [rs] gnu.org@127.0.0.250') |
94 | testing test5 "${arr[@]}" | 83 | testing test5 "${arr[@]}" |
95 | # 6 | 84 | # 6 |
96 | echo "Testing adding of multiple GNS2DNS record with -R" | 85 | echo "Testing adding of multiple GNS2DNS record with -R" |
97 | declare -a arr=('1 GNS2DNS n gnunet.org@127.0.0.1' '3600 GNS2DNS s gnunet.org@127.0.0.2') | 86 | declare -a arr=('GNS2DNS 1 [r] gnunet.org@127.0.0.1' 'GNS2DNS 3600 [s] gnunet.org@127.0.0.2') |
98 | testing test6 "${arr[@]}" | 87 | testing test6 "${arr[@]}" |
99 | val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid) | 88 | val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid) |
100 | if [[ $val == *"127.0.0.1"* ]]; then | 89 | if [[ $val == *"127.0.0.1"* ]]; then |
@@ -108,16 +97,16 @@ if [[ $val == *"127.0.0.2"* ]]; then | |||
108 | fi | 97 | fi |
109 | # 7 | 98 | # 7 |
110 | echo "Testing adding MX record with -R" | 99 | echo "Testing adding MX record with -R" |
111 | declare -a arr=('3600 MX n 10,mail') | 100 | declare -a arr=('MX 3600 [r] 10,mail') |
112 | testing test7 "${arr[@]}" | 101 | testing test7 "${arr[@]}" |
113 | # 8 | 102 | # 8 |
114 | echo "Testing adding TXT record with -R" | 103 | echo "Testing adding TXT record with -R" |
115 | declare -a arr=('3600 TXT n Pretty_Unicorns') | 104 | declare -a arr=('TXT 3600 [r] Pretty_Unicorns') |
116 | testing test8 "${arr[@]}" | 105 | testing test8 "${arr[@]}" |
117 | # 8 | 106 | # 8 |
118 | echo "Testing adding TXT record with -R" | 107 | #echo "Testing adding TXT record with -R" |
119 | declare -a arr=('3600 SRV n _autodiscover_old._tcp.bfh.ch.') | 108 | #declare -a arr=('SRV 3600 [r] _autodiscover_old._tcp.bfh.ch.') |
120 | testing test8 "${arr[@]}" | 109 | #testing test8 "${arr[@]}" |
121 | 110 | ||
122 | # CLEANUP | 111 | # CLEANUP |
123 | gnunet-identity -D randomtestingid | 112 | gnunet-identity -D randomtestingid |