11.4Sozaki# $NetBSD: t_tcpdump.sh,v 1.4 2014/09/20 06:08:07 ozaki-r Exp $
21.1Sjruoho#
31.1Sjruoho# Copyright (c) 2012 The NetBSD Foundation, Inc.
41.1Sjruoho# All rights reserved.
51.1Sjruoho#
61.1Sjruoho# This code is derived from software contributed to The NetBSD Foundation
71.1Sjruoho# by Jukka Ruohonen.
81.1Sjruoho#
91.1Sjruoho# Redistribution and use in source and binary forms, with or without
101.1Sjruoho# modification, are permitted provided that the following conditions
111.1Sjruoho# are met:
121.1Sjruoho# 1. Redistributions of source code must retain the above copyright
131.1Sjruoho#    notice, this list of conditions and the following disclaimer.
141.1Sjruoho# 2. Redistributions in binary form must reproduce the above copyright
151.1Sjruoho#    notice, this list of conditions and the following disclaimer in the
161.1Sjruoho#    documentation and/or other materials provided with the distribution.
171.1Sjruoho#
181.1Sjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
191.1Sjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
201.1Sjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
211.1Sjruoho# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
221.1Sjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
231.1Sjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
241.1Sjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
251.1Sjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
261.1Sjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
271.1Sjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
281.1Sjruoho# POSSIBILITY OF SUCH DAMAGE.
291.1Sjruoho#
301.1Sjruohoprom() {
311.1Sjruoho	atf_check -s ignore -o ignore -e ignore -x "tcpdump -c 1 -i $1" &
321.1Sjruoho	sleep 2; kill $! >/dev/null 2>&1
331.1Sjruoho}
341.1Sjruoho
351.1Sjruohoatf_test_case promiscuous
361.1Sjruohopromiscuous_head() {
371.1Sjruoho	atf_set "require.user" "root"
381.1Sjruoho	atf_set "descr" "Test that switching an interface into and out " \
391.1Sjruoho			"of promiscuous mode does not lockup (PR kern/46328)"
401.1Sjruoho}
411.1Sjruoho
421.1Sjruohopromiscuous_body() {
431.1Sjruoho
441.3Schristos	for i in $(ifconfig -l); do
451.4Sozaki		case $i in
461.4Sozaki		bridge*)
471.4Sozaki			echo "Skipping $i"
481.4Sozaki			continue
491.4Sozaki			;;
501.4Sozaki		esac
511.4Sozaki
521.3Schristos		echo "Testing $i"
531.3Schristos		prom $i
541.1Sjruoho	done
551.1Sjruoho}
561.1Sjruoho
571.1Sjruohoatf_init_test_cases() {
581.1Sjruoho	atf_add_test_case promiscuous
591.1Sjruoho}
60