From patchwork Tue Mar 3 22:08:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 445935 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 ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DEE5714016A for ; Wed, 4 Mar 2015 09:08:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id F1F7B9C207; Tue, 3 Mar 2015 17:08:56 -0500 (EST) 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 O9gLmmvBLyRL; Tue, 3 Mar 2015 17:08:56 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id DAD389C208; Tue, 3 Mar 2015 17:08:52 -0500 (EST) 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 0FAD09C20E for ; Tue, 3 Mar 2015 17:08:51 -0500 (EST) 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 070+lozfh3FB for ; Tue, 3 Mar 2015 17:08:46 -0500 (EST) Received: from sipsolutions.net (s3.sipsolutions.net [5.9.151.49]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 9A58F9C208 for ; Tue, 3 Mar 2015 17:08:46 -0500 (EST) Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84) (envelope-from ) id 1YSuzd-0006a3-5c; Tue, 03 Mar 2015 23:08:45 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH 2/2] hwsim tests: allow running with arbitrary working directory Date: Tue, 3 Mar 2015 23:08:41 +0100 Message-Id: <1425420521-6153-2-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425420521-6153-1-git-send-email-johannes@sipsolutions.net> References: <1425420521-6153-1-git-send-email-johannes@sipsolutions.net> 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 It's somewhat annoying that you can only run parallel-vm.py as ./parallel-vm.py, not from elsewhere by giving the full path, so fix that by resolving the paths correctly in the scripts where needed. Signed-off-by: Johannes Berg --- tests/hwsim/run-tests.py | 11 +++-------- tests/hwsim/vm/parallel-vm.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 0cd404325a97..7e9c4a25597d 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -18,10 +18,8 @@ import termios import logging logger = logging.getLogger() -if os.path.exists('../../wpaspy'): - sys.path.append('../../wpaspy') -else: - sys.path.append('../../../wpaspy') +scriptsdir = os.path.dirname(os.path.realpath(sys.modules[__name__].__file__)) +sys.path.append(os.path.join(scriptsdir, '..', '..', 'wpaspy')) from wpasupplicant import WpaSupplicant from hostapd import HostapdGlobal @@ -169,10 +167,7 @@ def rename_log(logdir, basename, testname, dev): def main(): tests = [] test_modules = [] - if os.path.exists('run-tests.py'): - files = os.listdir(".") - else: - files = os.listdir("..") + files = os.listdir(scriptsdir) for t in files: m = re.match(r'(test_.*)\.py$', t) if m: diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py index 27033791fc0f..32fae4d5c3b4 100755 --- a/tests/hwsim/vm/parallel-vm.py +++ b/tests/hwsim/vm/parallel-vm.py @@ -241,6 +241,7 @@ def show_progress(scr): def main(): import argparse + import os global num_servers global vm global dir @@ -258,6 +259,8 @@ def main(): debug_level = logging.INFO rerun_failures = True + scriptsdir = os.path.dirname(os.path.realpath(sys.argv[0])) + p = argparse.ArgumentParser(description='run multiple testing VMs in parallel') p.add_argument('num_servers', metavar='number of VMs', type=int, choices=range(1, 100), help="number of VMs to start") @@ -279,7 +282,7 @@ def main(): print "Code coverage - build separate binaries" logdir = "/tmp/hwsim-test-logs/" + str(timestamp) os.makedirs(logdir) - subprocess.check_call(['./build-codecov.sh', logdir]) + subprocess.check_call([os.path.join(scriptsdir, 'build-codecov.sh'), logdir]) codecov_args = ['--codecov_dir', logdir] codecov = True else: @@ -290,7 +293,8 @@ def main(): first_run_failures = [] tests = [] - cmd = [ '../run-tests.py', '-L' ] + args.params + cmd = [ os.path.join(os.path.dirname(scriptsdir), 'run-tests.py'), '-L' ] + args.params + print cmd lst = subprocess.Popen(cmd, stdout=subprocess.PIPE) for l in lst.stdout.readlines(): name = l.split(' ')[0] @@ -369,7 +373,7 @@ def main(): for i in range(0, num_servers): print("\rStarting virtual machine {}/{}".format(i + 1, num_servers)), logger.info("Starting virtual machine {}/{}".format(i + 1, num_servers)) - cmd = ['./vm-run.sh', '--delay', str(i), '--timestamp', str(timestamp), + cmd = [os.path.join(scriptsdir, 'vm-run.sh'), '--delay', str(i), '--timestamp', str(timestamp), '--ext', 'srv.%d' % (i + 1), '-i'] + codecov_args + extra_args vm[i] = {} @@ -440,10 +444,10 @@ def main(): if codecov: print "Code coverage - preparing report" for i in range(num_servers): - subprocess.check_call(['./process-codecov.sh', + subprocess.check_call([os.path.join(scriptsdir, 'process-codecov.sh'), logdir + ".srv.%d" % (i + 1), str(i)]) - subprocess.check_call(['./combine-codecov.sh', logdir]) + subprocess.check_call([os.path.join(scriptsdir, 'combine-codecov.sh'), logdir]) print "file://%s/index.html" % logdir logger.info("Code coverage report: file://%s/index.html" % logdir)