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 14SYSTEMTESTTOP=.. 15. $SYSTEMTESTTOP/conf.sh 16 17DIGOPTS="+nosea +stat +noquest +nocomm +nocmd -p ${PORT}" 18 19status=0 20 21echo_i "Getting message size with compression enabled" 22$DIG $DIGOPTS -b 10.53.0.1 @10.53.0.1 mx example > dig.compen.test 23COMPEN=`grep ';; MSG SIZE' dig.compen.test |sed -e "s/.*: //g"` 24cat dig.compen.test |grep -v ';;' |sort > dig.compen.sorted.test 25 26echo_i "Getting message size with compression disabled" 27$DIG $DIGOPTS -b 10.53.0.2 @10.53.0.1 mx example > dig.compdis.test 28COMPDIS=`grep ';; MSG SIZE' dig.compdis.test |sed -e "s/.*: //g"` 29cat dig.compdis.test |grep -v ';;' |sort > dig.compdis.sorted.test 30 31# the compression disabled message should be at least twice as large as with 32# compression disabled, but the content should be the same 33echo_i "Checking if responses are identical other than in message size" 34$DIFF dig.compdis.sorted.test dig.compen.sorted.test >/dev/null 35ret=$? 36if [ $ret != 0 ]; then echo_i "failed"; fi 37status=`expr $status + $ret` 38 39echo_i "Checking if message with compression disabled is significantly larger" 40echo_i "Disabled $COMPDIS vs enabled $COMPEN" 41val=`expr \( $COMPDIS \* 3 / 2 \) / $COMPEN` 42if [ $val -le 1 ]; then 43 echo_i "failed" 44 status=`expr $status + 1` 45fi; 46 47echo_i "exit status: $status" 48[ $status -eq 0 ] || exit 1 49