xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/names/tests.sh (revision 345cf9fb81bd0411c53e25d62cd93bdcaa865312)
1#!/bin/sh
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14set -e
15
16. ../conf.sh
17
18DIGOPTS="+nosea +stat +noquest +nocomm +nocmd -p ${PORT}"
19
20status=0
21
22echo_i "Getting message size with compression enabled"
23$DIG $DIGOPTS -b 10.53.0.1 @10.53.0.1 mx example >dig.compen.test
24COMPEN=$(grep ';; MSG SIZE' dig.compen.test | sed -e "s/.*: //g")
25cat dig.compen.test | grep -v ';;' | sort >dig.compen.sorted.test
26
27echo_i "Getting message size with compression disabled"
28$DIG $DIGOPTS -b 10.53.0.2 @10.53.0.1 mx example >dig.compdis.test
29COMPDIS=$(grep ';; MSG SIZE' dig.compdis.test | sed -e "s/.*: //g")
30cat dig.compdis.test | grep -v ';;' | sort >dig.compdis.sorted.test
31
32# the compression disabled message should be at least twice as large as with
33# compression disabled, but the content should be the same
34echo_i "Checking if responses are identical other than in message size"
35{
36  diff dig.compdis.sorted.test dig.compen.sorted.test >/dev/null
37  ret=$?
38} || true
39if [ $ret != 0 ]; then echo_i "failed"; fi
40status=$((status + ret))
41
42echo_i "Checking if message with compression disabled is significantly larger"
43echo_i "Disabled $COMPDIS vs enabled $COMPEN"
44val=$(((COMPDIS * 3 / 2) / COMPEN))
45if [ $val -le 1 ]; then
46  echo_i "failed"
47  status=$((status + 1))
48fi
49
50echo_i "exit status: $status"
51[ $status -eq 0 ] || exit 1
52