1#!/bin/sh 2# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved. 3# Copyright (c) International Business Machines Corp., 2001 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License as 7# published by the Free Software Foundation; either version 2 of 8# the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it would be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18TST_TOTAL=6 19TCID="traceroute01" 20TST_CLEANUP="cleanup" 21 22. test_net.sh 23 24cleanup() 25{ 26 tst_rmdir 27} 28 29setup() 30{ 31 tst_check_cmds traceroute 32 tst_tmpdir 33} 34 35run_trace() 36{ 37 local opts="$@" 38 local ip=$(tst_ipaddr rhost) 39 40 # According to man pages, default sizes: 41 local bytes=60 42 [ "$TST_IPV6" ] && bytes=80 43 44 EXPECT_PASS traceroute $ip $bytes -n -m 2 $opts \>out.log 2>&1 45 46 grep -q "$bytes byte" out.log 47 if [ $? -ne 0 ]; then 48 cat out.log 49 tst_resm TFAIL "'$bytes byte' not found" 50 else 51 tst_resm TPASS "traceroute use $bytes bytes" 52 fi 53 54 tail -1 out.log | grep -qE "^[ ]+1[ ]+$ip([ ]+[0-9]+[.][0-9]+ ms){3}" 55 if [ $? -ne 0 ]; then 56 cat out.log 57 tst_resm TFAIL "^[ ]+1[ ]+$ip([ ]+[0-9]+[.][0-9]+ ms){3}' " 58 "pattern not found in log" 59 else 60 tst_resm TPASS "traceroute test completed with 1 hop" 61 fi 62} 63 64setup 65tst_resm TINFO "run traceroute with ICMP ECHO" 66run_trace -I 67tst_resm TINFO "run traceroute with TCP SYN" 68run_trace -T 69 70tst_exit 71