test: fix net_registry tests to correctly capture output of commands inside one test
authorMichael Adam <obnox@samba.org>
Tue, 1 Apr 2008 13:35:12 +0000 (15:35 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 1 Apr 2008 14:16:55 +0000 (16:16 +0200)
so that failure output is not clobbered by  output of previous
successful commands.

Michael
(This used to be commit cb3dafe5fd8867b000e01979d4232968d994d376)

source3/script/tests/test_net_registry.sh

index 4c6dd1910055523d82e625025d1419e49279fa65..82861bae108bd49405d02982bcb8a39b7f540723 100755 (executable)
@@ -73,8 +73,11 @@ test_createkey()
        BASEKEY=`dirname $KEY`
        SUBKEY=`basename $KEY`
 
-       ${NETREG} createkey ${KEY}
+       OUTPUT=`${NETREG} createkey ${KEY}`
        if test "x$?" != "x0" ; then
+               echo "ERROR: createkey ${KEY} failed"
+               echo "output:"
+               printf "%s\n" "$OUTPUT"
                false
                return
        fi
@@ -108,14 +111,20 @@ test_deletekey()
        BASEKEY=`dirname ${KEY}`
        SUBKEY=`basename ${KEY}`
 
-       test_createkey "${KEY}"
+       OUTPUT=`test_createkey "${KEY}"`
 
        if test "x$?" != "x0" ; then
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi
 
-       ${NETREG} deletekey ${KEY}
+       OUTPUT=`${NETREG} deletekey ${KEY}`
+       if test "x$?" != "x0" ; then
+               printf "%s\n" "${OUTPUT}"
+               false
+               return
+       fi
 
        # check enumerate of basekey does not show key anymore:
        OUTPUT=`${NETREG} enumerate ${BASEKEY}`
@@ -148,9 +157,9 @@ test_deletekey_nonexisting()
 {
        KEY="$1"
 
-       test_deletekey "${KEY}"
-
+       OUTPUT=`test_deletekey "${KEY}"`
        if test "x$?" != "x0" ; then
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi
@@ -170,17 +179,19 @@ test_createkey_with_subkey()
        BASENAME=`dirname ${KEY2}`
        SUBKEYNAME1=`basename ${KEY2}`
 
-       ${NETREG} createkey ${KEY}
-
+       OUTPUT=`${NETREG} createkey ${KEY}`
        if test "x$?" != "x0" ; then
+               echo "ERROR: createkey ${KEY} failed"
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi
 
        # check we can enumerate to level key
-       ${NETREG} enumerate ${KEY}
+       OUTPUT=`${NETREG} enumerate ${KEY}`
        if test "x$?" != "x0" ; then
                echo "ERROR: failed to enumerate '${KEY}' after creation"
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi
@@ -194,9 +205,9 @@ test_deletekey_with_subkey()
        KEY="$1"
        KEY2=`dirname ${KEY}`
 
-       ${NETREG} createkey ${KEY}
-
+       OUTPUT=`${NETREG} createkey ${KEY}`
        if test "x$?" != "x0" ; then
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi
@@ -221,15 +232,17 @@ test_setvalue()
        VALTYPE="$3"
        VALVALUE="$4"
 
-       test_createkey ${KEY}
+       OUTPUT=`test_createkey ${KEY}`
        if test "x$?" != "x0" ; then
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi
 
-       ${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE} ${VALVALUE}
+       OUTPUT=`${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE} ${VALVALUE}`
        if test "x$?" != "x0" ; then
                echo "ERROR: failed to set value testval in key ${KEY}"
+               printf "%s\n" "${OUTPUT}"
                false
                return
        fi