Blame tests/07-map_addrselect.tests

Packit 51d0f7
#!/bin/bash
Packit 51d0f7
Packit 51d0f7
#
Packit 51d0f7
# NetLabel Tools test script
Packit 51d0f7
#
Packit 51d0f7
Packit 51d0f7
#
Packit 51d0f7
# This program is free software: you can redistribute it and/or modify
Packit 51d0f7
# it under the terms of version 2 of the GNU General Public License as
Packit 51d0f7
# published by the Free Software Foundation.
Packit 51d0f7
#
Packit 51d0f7
# This program is distributed in the hope that it will be useful,
Packit 51d0f7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 51d0f7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 51d0f7
# GNU General Public License for more details.
Packit 51d0f7
#
Packit 51d0f7
# You should have received a copy of the GNU General Public License
Packit 51d0f7
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 51d0f7
#
Packit 51d0f7
Packit 51d0f7
# add the domain mappings
Packit 51d0f7
$GLBL_NETLABELCTL map add domain:test address:1.2.3.4 protocol:unlbl
Packit 51d0f7
[[ $? -ne 0 ]] && exit 1
Packit 51d0f7
$GLBL_NETLABELCTL map add domain:test address:0.0.0.0/0 protocol:unlbl
Packit 51d0f7
[[ $? -ne 0 ]] && exit 1
Packit 51d0f7
$GLBL_NETLABELCTL map add domain:test address:::1:2:3:4 protocol:unlbl
Packit 51d0f7
[[ $? -ne 0 ]] && exit 1
Packit 51d0f7
$GLBL_NETLABELCTL map add domain:test address:::0/0 protocol:unlbl
Packit 51d0f7
[[ $? -ne 0 ]] && exit 1
Packit 51d0f7
Packit 51d0f7
# verify the domain mappings
Packit 51d0f7
found=0
Packit 51d0f7
for i in $($GLBL_NETLABELCTL map list); do
Packit 51d0f7
	if [[ $i =~ ^domain:\"test\" ]]; then
Packit 51d0f7
		[[ $i =~ address:1.2.3.4/32,protocol:UNLABELED ]] && \
Packit 51d0f7
			found=$((found+1))
Packit 51d0f7
		[[ $i =~ address:0.0.0.0/0,protocol:UNLABELED ]] && \
Packit 51d0f7
			found=$((found+1))
Packit 51d0f7
		[[ $i =~ address:::1:2:3:4/128,protocol:UNLABELED ]] && \
Packit 51d0f7
			found=$((found+1))
Packit 51d0f7
		[[ $i =~ address:::/0,protocol:UNLABELED ]] && \
Packit 51d0f7
			found=$((found+1))
Packit 51d0f7
	fi
Packit 51d0f7
done
Packit 51d0f7
[[ $found -ne 4 ]] && exit 1
Packit 51d0f7
Packit 51d0f7
# remove the domain mappings
Packit 51d0f7
$GLBL_NETLABELCTL map del domain:test
Packit 51d0f7
[[ $? -ne 0 ]] && exit 1
Packit 51d0f7
Packit 51d0f7
exit 0