xref: /netbsd-src/tests/usr.sbin/tcpdump/t_tcpdump.sh (revision 80d9064ac03cbb6a4174695f0d5b237c8766d3d0)
1*80d9064aSozaki-r# $NetBSD: t_tcpdump.sh,v 1.4 2014/09/20 06:08:07 ozaki-r Exp $
20953dc87Sjruoho#
30953dc87Sjruoho# Copyright (c) 2012 The NetBSD Foundation, Inc.
40953dc87Sjruoho# All rights reserved.
50953dc87Sjruoho#
60953dc87Sjruoho# This code is derived from software contributed to The NetBSD Foundation
70953dc87Sjruoho# by Jukka Ruohonen.
80953dc87Sjruoho#
90953dc87Sjruoho# Redistribution and use in source and binary forms, with or without
100953dc87Sjruoho# modification, are permitted provided that the following conditions
110953dc87Sjruoho# are met:
120953dc87Sjruoho# 1. Redistributions of source code must retain the above copyright
130953dc87Sjruoho#    notice, this list of conditions and the following disclaimer.
140953dc87Sjruoho# 2. Redistributions in binary form must reproduce the above copyright
150953dc87Sjruoho#    notice, this list of conditions and the following disclaimer in the
160953dc87Sjruoho#    documentation and/or other materials provided with the distribution.
170953dc87Sjruoho#
180953dc87Sjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
190953dc87Sjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
200953dc87Sjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
210953dc87Sjruoho# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
220953dc87Sjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
230953dc87Sjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
240953dc87Sjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
250953dc87Sjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
260953dc87Sjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
270953dc87Sjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
280953dc87Sjruoho# POSSIBILITY OF SUCH DAMAGE.
290953dc87Sjruoho#
300953dc87Sjruohoprom() {
310953dc87Sjruoho	atf_check -s ignore -o ignore -e ignore -x "tcpdump -c 1 -i $1" &
320953dc87Sjruoho	sleep 2; kill $! >/dev/null 2>&1
330953dc87Sjruoho}
340953dc87Sjruoho
350953dc87Sjruohoatf_test_case promiscuous
360953dc87Sjruohopromiscuous_head() {
370953dc87Sjruoho	atf_set "require.user" "root"
380953dc87Sjruoho	atf_set "descr" "Test that switching an interface into and out " \
390953dc87Sjruoho			"of promiscuous mode does not lockup (PR kern/46328)"
400953dc87Sjruoho}
410953dc87Sjruoho
420953dc87Sjruohopromiscuous_body() {
430953dc87Sjruoho
442e74a3b7Schristos	for i in $(ifconfig -l); do
45*80d9064aSozaki-r		case $i in
46*80d9064aSozaki-r		bridge*)
47*80d9064aSozaki-r			echo "Skipping $i"
48*80d9064aSozaki-r			continue
49*80d9064aSozaki-r			;;
50*80d9064aSozaki-r		esac
51*80d9064aSozaki-r
520953dc87Sjruoho		echo "Testing $i"
530953dc87Sjruoho		prom $i
540953dc87Sjruoho	done
550953dc87Sjruoho}
560953dc87Sjruoho
570953dc87Sjruohoatf_init_test_cases() {
580953dc87Sjruoho	atf_add_test_case promiscuous
590953dc87Sjruoho}
60