]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
testprogs: fix some "net ads dns" tests
authorBjörn Baumbach <bb@sernet.de>
Wed, 22 Feb 2023 14:22:58 +0000 (15:22 +0100)
committerBjörn Baumbach <bb@sernet.de>
Fri, 3 Mar 2023 11:58:34 +0000 (11:58 +0000)
Use testit_grep_count instead of greping the output of testit.
Running testit with "| grep" falsifies the test results.

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
testprogs/blackbox/test_net_ads_dns.sh

index 072a4c5c3118d9046a480a0cd80b322f0f947eb4..27498808ade5176cebc5a6ff997680a5cdfab031 100755 (executable)
@@ -53,13 +53,34 @@ echo "Starting ..."
 
 testit "admin user should be able to add a DNS entry $NAME.$REALM $IPADDRESS $IP6ADDRESS" $VALGRIND $net_tool ads dns register $NAME.$REALM $IPADDRESS $IP6ADDRESS -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
 
-testit "We should be able to see the new name $NAME.$REALM $IPADDRESS" dig @$SERVER +short -t a $NAME.$REALM | grep -q $IPADDRESS || failed=$(expr $failed + 1)
-testit "We should be able to see the new name $NAME.$REALM $IP6ADDRESS" dig @$SERVER +short -t aaaa $NAME.$REALM | grep -q $IP6ADDRESS || failed=$(expr $failed + 1)
+testit_grep_count \
+       "We should be able to see the new name $NAME.$REALM $IPADDRESS" \
+       "$IPADDRESS" \
+       1 \
+       dig @$SERVER +short -t a $NAME.$REALM ||
+       failed=$(expr $failed + 1)
+testit_grep_count \
+       "We should be able to see the new name $NAME.$REALM $IP6ADDRESS" \
+       "$IP6ADDRESS" \
+       1 \
+       dig @$SERVER +short -t aaaa $NAME.$REALM ||
+       failed=$(expr $failed + 1)
 
 testit "We should be able to unregister the name $NAME.$REALM" $VALGRIND $net_tool ads dns unregister $NAME.$REALM -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
 
-testit "The name $NAME.$REALM $IPADDRESS should not be there any longer" dig @$SERVER +short -t a $NAME.$REALM | grep -q $IPADDRESS && failed=$(expr $failed + 1)
-testit "The name $NAME.$REALM $IP6ADDRESS should not be there any longer" dig @$SERVER +short -t aaaa $NAME.$REALM | grep -q $IP6ADDRESS && failed=$(expr $failed + 1)
+testit_grep_count \
+       "The name $NAME.$REALM $IPADDRESS should not be there any longer" \
+       "$IPADDRESS" \
+       0 \
+       dig @$SERVER +short -t a $NAME.$REALM ||
+       failed=$(expr $failed + 1)
+
+testit_grep_count \
+       "The name $NAME.$REALM $IP6ADDRESS should not be there any longer" \
+       "$IP6ADDRESS" \
+       0 \
+       dig @$SERVER +short -t aaaa $NAME.$REALM ||
+       failed=$(expr $failed + 1)
 
 # prime the kpasswd server, see "git blame" for an explanation
 $VALGRIND $net_tool user add $UNPRIVUSER $UNPRIVPASS -U$DC_USERNAME%$DC_PASSWORD
@@ -83,14 +104,29 @@ testit "Unprivileged users should be able to add new names" $net_tool ads dns re
 # This should work as well
 testit "machine account should be able to add a DNS entry net ads dns register membername.$REALM $IPADDRMAC -P " $net_tool ads dns register membername.$REALM $IPADDRMAC -P || failed=$(expr $failed + 1)
 
-testit "We should be able to see the new name membername.$REALM" dig @$SERVER +short -t a membername.$REALM | grep -q $IPADDRMAC || failed=$(expr $failed + 1)
+testit_grep_count \
+       "We should be able to see the new name membername.$REALM" \
+       "$IPADDRMAC" \
+       1 \
+       dig @$SERVER +short -t a membername.$REALM ||
+       failed=$(expr $failed + 1)
 
 #Unprivileged users should not be able to overwrite other's names
 testit_expect_failure "Unprivileged users should not be able to modify existing names" $net_tool ads dns register membername.$REALM $UNPRIVIP -U$UNPRIVUSER%$UNPRIVPASS || failed=$(expr $failed + 1)
 
 testit "We should be able to unregister the name $NAME.$REALM $IPADDRESS" $VALGRIND $net_tool ads dns unregister $NAME.$REALM -P || failed=$(expr $failed + 1)
 
-testit "The name $NAME.$REALM ($IPADDRESS) should not be there any longer" dig @$SERVER +short -t a $NAME.$REALM | grep -q $IPADDRESS && failed=$(expr $failed + 1)
-testit "The name $NAME.$REALM ($IP6ADDRESS) should not be there any longer" dig @$SERVER +short -t aaaa $NAME.$REALM | grep -q $IP6ADDRESS && failed=$(expr $failed + 1)
+testit_grep_count \
+       "The name $NAME.$REALM ($IPADDRESS) should not be there any longer" \
+       "$IPADDRESS" \
+       0 \
+       dig @$SERVER +short -t a $NAME.$REALM ||
+       failed=$(expr $failed + 1)
+testit_grep_count \
+       "The name $NAME.$REALM ($IP6ADDRESS) should not be there any longer" \
+       "$IP6ADDRESS" \
+       0 \
+       dig @$SERVER +short -t aaaa $NAME.$REALM ||
+       failed=$(expr $failed + 1)
 
 exit $failed