• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
22TST_USE_LEGACY_API=1
23. tst_net.sh
24
25cleanup()
26{
27	tst_rmdir
28}
29
30setup()
31{
32	tst_resm TINFO "traceroute version:"
33	tst_resm TINFO $(traceroute --version 2>&1)
34
35	tst_test_cmds traceroute
36	tst_tmpdir
37}
38
39run_trace()
40{
41	local opts="$@"
42	local ip=$(tst_ipaddr rhost)
43	local pattern="^[ ]+1[ ]+$ip([ ]+[0-9]+[.][0-9]+ ms){3}"
44
45	# According to man pages, default sizes:
46	local bytes=60
47	[ "$TST_IPV6" ] && bytes=80
48
49	EXPECT_PASS traceroute $ip $bytes -n -m 2 $opts \>out.log 2>&1
50
51	grep -q "$bytes byte" out.log
52	if [ $? -ne 0 ]; then
53		cat out.log
54		tst_resm TFAIL "'$bytes byte' not found"
55	else
56		tst_resm TPASS "traceroute use $bytes bytes"
57	fi
58
59	tail -1 out.log | grep -qE "$pattern"
60	if [ $? -ne 0 ]; then
61		cat out.log
62		tst_resm TFAIL "pattern '$pattern' not found in log"
63	else
64		tst_resm TPASS "traceroute test completed with 1 hop"
65	fi
66}
67
68setup
69tst_resm TINFO "run traceroute with ICMP ECHO"
70run_trace -I
71tst_resm TINFO "run traceroute with TCP SYN"
72run_trace -T
73
74tst_exit
75