test/functions/ip/ip_get_prefix \
test/functions/ip/ip_is_network \
test/functions/ip/ip_is_valid \
+ test/functions/ip/ip_network_is_subnet_of \
test/functions/ip/ip_prefix_is_valid \
test/functions/ip/ip_protocol_is_supported \
test/functions/ip/ip_split_prefix
--- /dev/null
+#!/bin/bash
+
+. ${functions}
+
+# Load test functions
+. ${testdir}/test-functions
+
+############################################################
+# Run a number of valid function calls #
+############################################################
+
+# IPv6
+test_expect_ok ip_network_is_subset_of 2001:db8:abcd::/32 2001:db8::/32
+test_expect_ok ip_network_is_subset_of 2001:db8:abcd::/33 2001:db8::/32
+test_expect_ok ip_network_is_subset_of 2001:db8:abcd::/36 2001:db8::/32
+test_expect_ok ip_network_is_subset_of 2001:db8:abcd::/48 2001:db8::/32
+test_expect_ok ip_network_is_subset_of 2001:db8:abcd::/52 2001:db8::/32
+test_expect_ok ip_network_is_subset_of 2001:db8:abcd::/64 2001:db8::/32
+
+# IPv4
+test_expect_ok ip_network_is_subset_of 1.1.1.1 1.0.0.0/8
+test_expect_ok ip_network_is_subset_of 2.2.2.2 2.0.0.0/8
+
+############################################################
+# Run a number of invalid function calls #
+############################################################
+
+# IPv6
+test_expect_error ip_network_is_subset_of 2001:db8::/31 2001:db8::/32
+test_expect_error ip_network_is_subset_of ::1/128 2001:db8::/32
+
+# IPv4
+test_expect_error ip_network_is_subset_of 1.1.1.1 1.0.0.0/16
+test_expect_error ip_network_is_subset_of 1.1.1.1 1.0.0.0/24
+
+# Protocols cannot be mixed
+test_expect_error ip_network_is_subset_of ::1 127.0.0.0/8
+test_expect_error ip_network_is_subset_of 127.0.0.0/8 ::1
+
+# Some garbage inputs
+test_expect_error ip_network_is_subset_of 127.0.0.0/8 a.b.c.d/e
+test_expect_error ip_network_is_subset_of a.b.c.d/e 127.0.0.0/8
+
+exit ${TEST_FAILED}
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2017 IPFire Network Development Team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+TEST_FAILED=${EXIT_OK}
+
+test_expect_ok() {
+ local cmd=$@
+
+ if ${cmd}; then
+ echo "OK: ${cmd} exited successfully"
+ else
+ echo "ERROR: ${cmd} exited with failure"
+ TEST_FAILED=${EXIT_ERROR}
+ fi
+
+ return ${TEST_FAILED}
+}
+
+test_expect_error() {
+ local cmd=$@
+
+ if ! ${cmd}; then
+ echo "OK: ${cmd} exited with error"
+ else
+ echo "ERROR: ${cmd} exited successfully"
+ TEST_FAILED=${EXIT_ERROR}
+ fi
+
+ return ${TEST_FAILED}
+}