]> git.ipfire.org Git - network.git/commitdiff
test: add test for function ip_is_network
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 31 May 2017 13:06:33 +0000 (15:06 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 31 May 2017 13:06:33 +0000 (15:06 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
test/functions/ip/ip_is_network [new file with mode: 0755]

diff --git a/test/functions/ip/ip_is_network b/test/functions/ip/ip_is_network
new file mode 100755 (executable)
index 0000000..6570ad2
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+. ${networkdir}/functions
+
+. ${testdir}/constants.sh
+
+failed=0
+
+for network in ${VALID_NETWORKS[@]}; do
+       if ip_is_network ${network}; then
+               echo "OK: network: ${network} is valid"
+       else
+               echo "ERROR: network ${network} is invalid"
+               failed=1
+       fi
+done
+
+for network in ${INVALID_NETWORKS[@]}; do
+       if ! ip_is_network ${network}; then
+               echo "OK: network: ${network} is invalid"
+       else
+               echo "ERROR: network: ${network} is valid"
+               failed=1
+       fi
+done
+
+exit ${failed}