From patchwork Wed Oct 30 17:17:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 287304 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 E53C62C0399 for ; Thu, 31 Oct 2013 04:17:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D8E839C19E; Wed, 30 Oct 2013 13:17:32 -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 SRy3qqH+Ab4C; Wed, 30 Oct 2013 13:17:32 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7C4DD9C182; Wed, 30 Oct 2013 13:17:28 -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 D49039C182 for ; Wed, 30 Oct 2013 13:17:27 -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 NTZHpMEvO5SF for ; Wed, 30 Oct 2013 13:17:23 -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 910779C180 for ; Wed, 30 Oct 2013 13:17:23 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1VbZOT-00045z-9X; Wed, 30 Oct 2013 18:17:21 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH] hwsim tests: refactor run-all.sh Date: Wed, 30 Oct 2013 18:17:17 +0100 Message-Id: <1383153437-6365-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 Reuse the code rather than duplicating the implementation of starting the tests. To make that easier, allow passing multiple modules with -f to run-tests.py. Signed-hostap: Johannes Berg --- tests/hwsim/run-all.sh | 125 +++++++++++++++++++---------------------------- tests/hwsim/run-tests.py | 12 ++--- 2 files changed, 56 insertions(+), 81 deletions(-) diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh index 9471dd8..9adea3f 100755 --- a/tests/hwsim/run-all.sh +++ b/tests/hwsim/run-all.sh @@ -17,90 +17,65 @@ else fi if [ "x$1" = "xconcurrent-valgrind" ]; then - if ! ./start.sh concurrent valgrind; then - echo "Could not start test environment" > $LOGDIR/last-debug - exit 1 - fi - DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-` - rm $LOGDIR/last-debug - for i in autogo discovery grpform; do - ./run-tests.py -l $LOGDIR/$DATE-run-$i $DB -e $LOGDIR/$DATE-failed-$i -r $LOGDIR/results.txt -f test_p2p_$i || errors=1 - cat $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug - done - ./stop-wifi.sh - failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l` - if [ $failures -gt 0 ]; then - echo "Mark as failed due to valgrind errors" - errors=1 - fi - if [ $errors -gt 0 ]; then - tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent-valgrind.tar.gz $LOGDIR/$DATE* - exit 1 - fi + VALGRIND=valgrind + CONCURRENT=concurrent + CONCURRENT_TESTS=-f test_p2p_autogo test_p2p_discovery test_p2p_grpform + SUFFIX=-concurrent-valgrind + shift elif [ "x$1" = "xconcurrent" ]; then - if ! ./start.sh concurrent; then - echo "Could not start test environment" > $LOGDIR/last-debug - exit 1 - fi - DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-` - rm $LOGDIR/last-debug - for i in autogo discovery grpform; do - ./run-tests.py -l $LOGDIR/$DATE-run-$i $DB -e $LOGDIR/$DATE-failed-$i -r $LOGDIR/results.txt -f test_p2p_$i || errors=1 - cat $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug - done - ./stop-wifi.sh - if [ $errors -gt 0 ]; then - tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent.tar.gz $LOGDIR/$DATE* - exit 1 - fi + CONCURRENT=concurrent + CONCURRENT_TESTS=-f test_p2p_autogo test_p2p_discovery test_p2p_grpform + unset VALGRIND + SUFFIX=-concurrent + shift elif [ "x$1" = "xvalgrind" ]; then - if ! ./start.sh valgrind; then + VALGRIND=valgrind + unset CONCURRENT + unset CONCURRENT_TESTS + SUFFIX=-valgrind + shift +else + unset VALGRIND + unset CONCURRENT + unset CONCURRENT_TESTS + SUFFIX= +fi + +if [ "x$1" = "xtrace" ] ; then + TRACE=trace + SUFFIX=$SUFFIX-trace +else + unset TRACE +fi + +if ! ./start.sh $CONCURRENT $VALGRIND $TRACE; then echo "Could not start test environment" > $LOGDIR/last-debug exit 1 - fi - DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-` - ./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt || errors=1 - cat $LOGDIR/$DATE-run > $LOGDIR/last-debug - ./stop-wifi.sh +fi +DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-` +rm $LOGDIR/last-debug 2>/dev/null +RUNTESTS="./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt $CONCURRENT_TESTS" + +if [ "$TRACE" != "" ] ; then + sudo trace-cmd record -o $LOGDIR/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c $RUNTESTS || errors=1 +else + $RUNTESTS || errors=1 +fi + + +cat $LOGDIR/$DATE-run >> $LOGDIR/last-debug +./stop-wifi.sh + +if [ ! -z "$VALGRIND" ] ; then failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l` if [ $failures -gt 0 ]; then echo "Mark as failed due to valgrind errors" errors=1 fi - if [ $errors -gt 0 ]; then - tar czf /tmp/hwsim-tests-$DATE-FAILED-valgrind.tar.gz $LOGDIR/$DATE* - exit 1 - fi -elif [ "x$1" = "xtrace" ]; then - if ! ./start.sh trace; then - echo "Could not start test environment" > $LOGDIR/last-debug - exit 1 - fi - DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-` - sudo trace-cmd record -o $LOGDIR/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c "./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt" || errors=1 - if [ -e $LOGDIR/$DATE-failed ]; then - error=1 - fi - sudo chown $USER $LOGDIR/$DATE-trace.dat - cat $LOGDIR/$DATE-run > $LOGDIR/last-debug - ./stop-wifi.sh - if [ $errors -gt 0 ]; then - tar czf /tmp/hwsim-tests-$DATE-FAILED-trace.tar.gz $LOGDIR/$DATE* - exit 1 - fi -else - if ! ./start.sh; then - echo "Could not start test environment" > $LOGDIR/last-debug - exit 1 - fi - DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-` - ./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt || errors=1 - cat $LOGDIR/$DATE-run > $LOGDIR/last-debug - ./stop-wifi.sh - if [ $errors -gt 0 ]; then - tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz $LOGDIR/$DATE* - exit 1 - fi +fi +if [ $errors -gt 0 ]; then + tar czf /tmp/hwsim-tests-$DATE-FAILED$SUFFIX.tar.gz $LOGDIR/$DATE* + exit 1 fi echo "ALL-PASSED" diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 9644b4a..d9a135d 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -85,16 +85,16 @@ def main(): parser.add_argument('-b', metavar='', dest='build', help='build ID') parser.add_argument('-L', action='store_true', dest='update_tests_db', help='List tests (and update descriptions in DB)') - parser.add_argument('-f', dest='testmodule', metavar='', - help='execute only tests from this test module', - type=str, choices=[[]] + test_modules) + parser.add_argument('-f', dest='testmodules', metavar='', + help='execute only tests from these test modules', + type=str, choices=[[]] + test_modules, nargs='+') parser.add_argument('tests', metavar='', nargs='*', type=str, help='tests to run (only valid without -f)', choices=[[]] + test_names) args = parser.parse_args() - if args.tests and args.testmodule: + if args.tests and args.testmodules: print 'Invalid arguments - both test module and tests given' sys.exit(2) @@ -168,8 +168,8 @@ def main(): if args.tests: if not t.__name__ in args.tests: continue - if args.testmodule: - if not t.__module__ == args.testmodule: + if args.testmodules: + if not t.__module__ in args.testmodules: continue reset_devs(dev, apdev) logger.info("START " + t.__name__)