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