From patchwork Wed Oct 30 16:56:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 287299 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1D4BC2C0367 for ; Thu, 31 Oct 2013 03:56:36 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id F27669C118; Wed, 30 Oct 2013 12:56:34 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4cnquwX2dZfg; Wed, 30 Oct 2013 12:56:34 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id ABF6E9C14E; Wed, 30 Oct 2013 12:56:30 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8BA219C14E for ; Wed, 30 Oct 2013 12:56:28 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bsgy9VyxlLdv for ; Wed, 30 Oct 2013 12:56:20 -0400 (EDT) Received: from sipsolutions.net (s3.sipsolutions.net [144.76.43.152]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 725E59C118 for ; Wed, 30 Oct 2013 12:56:20 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1VbZ45-0003f8-9F; Wed, 30 Oct 2013 17:56:17 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH v2] hwsim tests: reduce duplication in startup code Date: Wed, 30 Oct 2013 17:56:14 +0100 Message-Id: <1383152174-5663-1-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 1.8.4.rc3 Cc: Johannes Berg X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg Instead of hard-coding four different cases, use variables (and printf) to reduce the duplication. Signed-hostap: Johannes Berg --- tests/hwsim/start.sh | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh index b44f7b8..034db2b 100755 --- a/tests/hwsim/start.sh +++ b/tests/hwsim/start.sh @@ -7,6 +7,8 @@ HAPD=$DIR/../../hostapd/hostapd WLANTEST=$DIR/../../wlantest/wlantest HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw +DATE=`date +%s` + if [ -z "$LOGDIR" ] ; then LOGDIR=$DIR/logs fi @@ -20,16 +22,25 @@ fi if [ "$1" = "concurrent" ]; then CONCURRENT=y + CONCURRENT_ARGS="-N -Dnl80211 -ista%d -c $DIR/sta-dummy.conf" shift else unset CONCURRENT + CONCURRENT_ARGS= fi if [ "$1" = "valgrind" ]; then VALGRIND=y + VALGRIND_WPAS="valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan%d" + VALGRIND_HAPD="valgrind --log-file=$LOGDIR/$DATE-valgrind-hostapd" + # why chmod? + chmod a+rx $WPAS + chmod a+rx $HAPD shift else unset VALGRIND + VALGRIND_WPAS= + VALGRIND_HAPD= fi if [ "$1" = "trace" ]; then @@ -48,31 +59,15 @@ if [ "$CONCURRENT" = "y" ]; then sudo iw wlan2 interface add sta2 type station fi mkdir -p $LOGDIR -DATE=`date +%s` sudo ifconfig hwsim0 up sudo $WLANTEST -i hwsim0 -c -d > $LOGDIR/$DATE-hwsim0 & sudo tcpdump -ni hwsim0 -s 2500 -w $LOGDIR/$DATE-hwsim0.dump > $LOGDIR/$DATE-tcpdump 2>&1 & -if [ "$VALGRIND" = "y" ]; then - for i in 0 1 2; do - chmod a+rx $WPAS - if [ "$CONCURRENT" = "y" ]; then - sudo valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan$i $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -N -Dnl80211 -ista$i -c $DIR/sta-dummy.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i & - else - sudo valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan$i $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i & - fi - done - chmod a+rx $HAPD - sudo valgrind --log-file=$LOGDIR/$DATE-valgrind-hostapd $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd & -else - for i in 0 1 2; do - if [ "$CONCURRENT" = "y" ]; then - sudo $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -N -Dnl80211 -ista$i -c $DIR/sta-dummy.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i & - else - sudo $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i & - fi - done - sudo $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd & -fi +for i in 0 1 2; do + sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf \ + $(printf -- "$CONCURRENT_ARGS" $i) -ddKt$TRACE > $LOGDIR/$DATE-log$i & +done +sudo $VALGRIND_HAPD $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd & + sleep 1 sudo chown $USER $LOGDIR/$DATE-hwsim0.dump if [ "x$VALGRIND" = "xy" ]; then