aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_tools.sh
blob: 462866f87db6538a6b36d6ac64afa6af214ee70f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# This file is in the public domain.

GNUNET_TMP="$(gnunet-config -f -s PATHS -o GNUNET_TMP)"
out=`mktemp $GNUNET_TMP/test-gnunet-dht-logXXXXXXXX`
tempcfg=`mktemp $GNUNET_TMP/test-dht-tools.XXXXXXXX`
checkout="check.out"
armexe="gnunet-arm -c $tempcfg "
putexe="gnunet-dht-put -c $tempcfg "
getexe="gnunet-dht-get -c $tempcfg "
peerinfo="gnunet-peerinfo -c $tempcfg -sq"
stop_arm()
{
  if ! $armexe $DEBUG -e -d > $out ; then
    echo "FAIL: error running $armexe"
    echo "Command output was:"
    cat $out
    rm -f $out $tempcfg
    exit 1
  fi
  rm -f $out $tempcfg
}

cp test_dht_tools.conf $tempcfg

echo -n "TEST: Starting ARM..."
if ! $armexe $DEBUG -s > $out ; then
  echo "FAIL: error running $armexe"
  echo "Command output was:"
  cat $out
  stop_arm
  exit 1
fi
echo "PASS"

echo -n "TEST: Testing put..."
if ! $putexe -k testkey -d testdata -t 8 > $out ; then
  echo "FAIL: error running $putexe"
  echo "Command output was:"
  cat $out
  stop_arm
  exit 1
fi
echo "PASS"

echo -n "TEST: Testing get..."
echo "Result 0, type 8:" > $checkout
echo "testdata" >> $checkout

if ! $getexe -k testkey -T 100ms -t 8 > $out ; then
  echo "FAIL: error running $putexe"
  echo "Command output was:"
  cat $out
  stop_arm
  exit 1
fi

if ! diff --strip-trailing-cr -q $out $checkout ; then
  echo "FAIL: $out and $checkout differ:"
  diff --strip-trailing-cr $out $checkout
  stop_arm
  exit 1
fi
echo "PASS"
stop_arm