add TODO
[oweals/gnunet.git] / src / statistics / test_gnunet_statistics.sh
index aacbc75b0c9c3338c85ab8ad1a2c8390c6dc7b28..eb2d618d9ac3c8f354e1d032113b9b56eceffaa1 100755 (executable)
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/bin/sh
 
 rm -rf /tmp/test-gnunetd-statistics/
 exe="./gnunet-statistics -c test_statistics_api_data.conf"
-base=/tmp/gnunet-test-statistics
+out=`mktemp /tmp/test-gnunet-statistics-logXXXXXXXX`
 arm="gnunet-arm -c test_statistics_api_data.conf $DEBUG"
 #DEBUG="-L DEBUG"
 # -----------------------------------
@@ -47,12 +47,12 @@ echo "PASS"
 # ----------------------------------------------------------------------------------
 echo -n "TEST: viewing all stats..."
 
-if ! $exe $DEBUG > $base.out; then
+if ! $exe $DEBUG > $out; then
     echo "FAIL: error running $exe"
     $arm -e
     exit 1
 fi
-LINES=`cat $base.out | wc -l`
+LINES=`cat $out | wc -l`
 if test $LINES -ne 2; then
     echo "FAIL: unexpected output"
     $arm -e
@@ -63,12 +63,12 @@ echo "PASS"
 # ----------------------------------------------------------------------------------
 echo -n "TEST: viewing stats by name..."
 
-if ! $exe $DEBUG -n other > $base.out; then
+if ! $exe $DEBUG -n other > $out; then
     echo "FAIL: error running $exe"
     $arm -e
     exit 1
 fi
-LINES=`cat $base.out | grep 43 | wc -l`
+LINES=`cat $out | grep 43 | wc -l`
 if test $LINES -ne 1; then
     echo "FAIL: unexpected output"
     $arm -e
@@ -79,12 +79,12 @@ echo "PASS"
 # ----------------------------------------------------------------------------------
 echo -n "TEST: viewing stats by subsystem..."
 
-if ! $exe $DEBUG -s subsystem > $base.out; then
+if ! $exe $DEBUG -s subsystem > $out; then
     echo "FAIL: error running $exe"
     $arm -e
     exit 1
 fi
-LINES=`cat $base.out | grep 42 | wc -l`
+LINES=`cat $out | grep 42 | wc -l`
 if test $LINES -ne 1; then
     echo "FAIL: unexpected output"
     $arm -e
@@ -101,6 +101,18 @@ if ! $exe $DEBUG -n lasting -s subsystem 40 -p; then
   $arm -e
   exit 1
 fi
+if ! $exe $DEBUG > $out; then
+    echo "FAIL: error running $exe"
+    $arm -e
+    exit 1
+fi
+LINES=`cat $out | grep 40 | wc -l`
+if test $LINES -ne 1; then
+    echo "FAIL: unexpected output"
+    cat $out
+    $arm -e
+    exit 1
+fi
 echo "PASS"
 
 # -----------------------------------
@@ -114,14 +126,15 @@ echo "DONE"
 # ----------------------------------------------------------------------------------
 echo -n "TEST: checking persistence..."
 
-if ! $exe $DEBUG > $base.out; then
+if ! $exe $DEBUG > $out; then
     echo "FAIL: error running $exe"
     $arm -e
     exit 1
 fi
-LINES=`cat $base.out | grep 40 | wc -l`
+LINES=`cat $out | grep 40 | wc -l`
 if test $LINES -ne 1; then
     echo "FAIL: unexpected output"
+    cat $out
     $arm -e
     exit 1
 fi
@@ -137,6 +150,18 @@ if ! $exe  $DEBUG -n lasting -s subsystem 40; then
   $arm -e
   exit 1
 fi
+if ! $exe $DEBUG > $out; then
+    echo "FAIL: error running $exe"
+    $arm -e
+    exit 1
+fi
+LINES=`cat $out | grep \! | wc -l`
+if test $LINES -ne 0; then
+    echo "FAIL: unexpected output"
+    cat $out
+    $arm -e
+    exit 1
+fi
 echo "PASS"
 
 
@@ -151,14 +176,15 @@ echo "DONE"
 # ----------------------------------------------------------------------------------
 echo -n "TEST: checking removed persistence..."
 
-if ! $exe $DEBUG > $base.out; then
+if ! $exe $DEBUG > $out; then
     echo "FAIL: error running $exe"
     $arm -e
     exit 1
 fi
-LINES=`cat $base.out | grep 40 | wc -l`
+LINES=`cat $out | grep 40 | wc -l`
 if test $LINES -ne 0; then
     echo "FAIL: unexpected output"
+    cat $out
     $arm -e
     exit 1
 fi
@@ -169,5 +195,5 @@ echo -n "Stopping service..."
 $arm -e > /dev/null
 sleep 1
 echo "DONE"
-rm -f $base.out
+rm -f $out
 rm -rf /tmp/test-gnunetd-statistics/