From patchwork Thu Apr 7 05:38:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 607250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qgWcZ3s18z9t0t for ; Thu, 7 Apr 2016 15:39:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=tieto.com header.i=@tieto.com header.b=zv826RaZ; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ao2f3-0005Bv-AV; Thu, 07 Apr 2016 05:39:21 +0000 Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ao2ek-0004zO-Ip for hostap@lists.infradead.org; Thu, 07 Apr 2016 05:39:08 +0000 Received: by mail-lb0-x231.google.com with SMTP id bk9so15715699lbc.3 for ; Wed, 06 Apr 2016 22:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YGgg3jcMrZitaywluPkJT7F+Gn6wbXyCzn1AA8RU/1Y=; b=zv826RaZR4qW8tGKIA/LjuVn0EK3vSSClvUbawtFcQk15+ofxvpijl/X0t08uVcZhG OZcB0+vWodnbZsDueBeFgOi0aQJ824L8s1gLlRVYapXVg3YG4z+U8cJn8N9kZwxrzgl8 GFptcJiGggUDuIJeNZSolzFqysd46Lb/xHi64= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YGgg3jcMrZitaywluPkJT7F+Gn6wbXyCzn1AA8RU/1Y=; b=dtUIpSVseP2HtFvixjpK936zRSAW49To9GgZj1jtPI1eXxh7LPzljanL1Zag070qXz GfX/DwxOtNvccfkAo6FxbnN8ZgZqgR80O5v3a4rdYFDsjUdjkxyTkjFOLAMj9mLrNDIr 9VGZKQBiTnnQ+amTjIWJhLHPURn9MjL9dl18A5dlX1H3zLo6MYkCkEvcsg6mSvWA/LxU q3qZVk50Jpd5zDSyPPdXNHJQ8JVnqpyV6XQjpqsLqqB5vqN2zth3S6rWKPk9rEZ728Ab TfUVqi6U5pISJ38nfu2lFTmH0EJ9E8U1ZkgiWYksRmhDZjcSBtO5/MQb7XBnugs276/8 71qg== X-Gm-Message-State: AD7BkJIuY8irz95CpkegvFZV9Zro7cNFHcbVBvPtIFzHtzwJkVn3defdcg0l27S1PI1mLU6yLaPdSTz1ecQo6WdnxamIh2T3XZZsNtQKP1Kb/yva3FtKhpeJ1iV/5HtZWEi0Ei2e0s57+PASWioQxImclMw9DOFJdoCN6R6xEj3SXuy/pu0JM9Tg1EF/efWISF8R X-Received: by 10.112.133.38 with SMTP id oz6mr526748lbb.64.1460007525514; Wed, 06 Apr 2016 22:38:45 -0700 (PDT) Received: from localhost.localdomain ([213.192.73.50]) by smtp.gmail.com with ESMTPSA id f134sm938018lff.34.2016.04.06.22.38.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Apr 2016 22:38:44 -0700 (PDT) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v2 16/17] tests/remote: add test_example.py Date: Thu, 7 Apr 2016 07:38:14 +0200 Message-Id: <1460007495-17921-16-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460007495-17921-1-git-send-email-janusz.dziedzic@tieto.com> References: <1460007495-17921-1-git-send-email-janusz.dziedzic@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160406_223903_312423_A8EECF6F X-CRM114-Status: GOOD ( 13.06 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c04:0:0:0:231 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@w1.fi, Janusz Dziedzic MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is simple example how to write simple test case. modprobe mac80211_hwsim radios=4 run example: ./run-tests.py -d hwsim0 -r hwsim1 -t example run example with monitors: ./run-tests.py -d hwsim0 -r hwsim1 -t example -m all -m hwsim2 run example with trace record: ./run-tests.py -d hwsim0 -r hwsim1 -t example -T run example with trace and perf: ./run-tests.py -d hwsim0 -r hwsim1 -t example -T -P restart hw before test case run: ./run-tests.py -d hwsim0 -r hwsim1 -t example -R run example verbose ./run-tests.py -d hwsim0 -r hwsim1 -t example -v For perf/trace you need to write own hw specyfic scripts: trace_start.sh, trace_stop.sh perf_start.sh, perf_stop.sh In any case you will find logs in logs/current/ directory. Signed-off-by: Janusz Dziedzic --- tests/remote/test_example.py | 138 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 tests/remote/test_example.py diff --git a/tests/remote/test_example.py b/tests/remote/test_example.py new file mode 100644 index 0000000..4537d51 --- /dev/null +++ b/tests/remote/test_example.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# +# Example test case +# Copyright (c) 2016, Tieto Corporation +# +# This software may be distributed under the terms of the BSD license. +# See README for more details. +import remotehost +from wpasupplicant import WpaSupplicant +import hostapd +import config +import rutils +import monitor + +import logging +logger = logging.getLogger() + +def test_example(devices, setup_params, refs, duts, monitors): + """TC example - simple connect and ping test""" + try: + sta = None + ap = None + hapd = None + wpas = None + mon = None + + # get hosts based on name + sta = rutils.get_host(devices, duts[0]) + ap = rutils.get_host(devices, refs[0]) + + # setup log dir + local_log_dir = setup_params['local_log_dir'] + + # setup hw before test + rutils.setup_hw([sta, ap], setup_params) + + # run traces if requested + rutils.trace_start([sta], setup_params) + + # run perf if requested + rutils.perf_start([sta], setup_params) + + # run hostapd/wpa_supplicant + rutils.run_wpasupplicant(sta, setup_params) + rutils.run_hostapd(ap, setup_params) + + # get ap_params + ap_params = rutils.get_ap_params(channel="1", bw="HT20", country="US", security="open") + + # Add monitors if requested + monitor_hosts = monitor.create(devices, setup_params, refs, duts, monitors) + if len(monitor_hosts) > 0: + mon = monitor_hosts[0] + monitor.add(sta, monitors) + monitor.add(ap, monitors) + + # connect to hostapd/wpa_supplicant UDP CTRL iface + hapd = hostapd.add_ap(ap.dev, ap_params) + freq = hapd.get_status_field("freq") + wpas = WpaSupplicant(hostname = sta.host, global_iface="udp", global_port = sta.port) + wpas.interface_add(sta.ifname) + + # setup standalone monitor based on hapd, could be multiiface monitor + monitor_param = monitor.get_monitor_params(hapd) + monitor.setup(mon, [monitor_param]) + + # run monitors + monitor.run(sta, setup_params) + monitor.run(ap, setup_params) + monitor.run(mon, setup_params) + + # connect wpa_supplicant to hostapd + wpas.connect(ap_params['ssid'], key_mgmt="NONE", scan_freq=freq) + + # run ping test + ap_sta, sta_ap = rutils.check_connectivity(ap, sta, "ipv6") + + # remove/destroy monitors + monitor.remove(sta) + monitor.remove(ap) + monitor.destroy(devices, monitor_hosts) + + # hostapd/wpa_supplicant cleanup + wpas.interface_remove(sta.ifname) + wpas.terminate() + + hapd.close_ctrl() + hostapd.remove_bss(ap.dev) + hostapd.terminate(ap.dev) + + # stop perf + rutils.perf_stop([sta], setup_params) + + # stop traces + rutils.trace_stop([sta], setup_params) + + # get wpa_supplicant/hostapd/tshark logs + sta.get_logs(local_log_dir) + ap.get_logs(local_log_dir) + if mon: + mon.get_logs(local_log_dir) + + return "packet_loss: " + ap_sta + ", " + sta_ap + except: + rutils.perf_stop([sta], setup_params) + rutils.trace_stop([sta], setup_params) + if wpas: + try: + wpas.interface_remove(sta.ifname) + wpas.terminate() + except: + pass + if hapd: + try: + hapd.close_ctrl() + hostapd.remove_bss(ap.dev) + hostapd.terminate(ap.dev) + except: + pass + if mon: + monitor.destroy(devices, monitor_hosts) + mon.get_logs(local_log_dir) + + if sta: + monitor.remove(sta) + dmesg = setup_params['log_dir'] + setup_params['tc_name'] + "_" + sta.name + "_" + sta.ifname + ".dmesg" + sta.execute("dmesg -c > " + dmesg) + sta.logs.append(dmesg) + sta.get_logs(local_log_dir) + sta.execute("ifconfig " + sta.ifname + " down") + if ap: + monitor.remove(ap) + dmesg = setup_params['log_dir'] + setup_params['tc_name'] + "_" + ap.name + "_" + ap.ifname + ".dmesg" + ap.execute("dmesg -c > " + dmesg) + ap.logs.append(dmesg) + ap.get_logs(local_log_dir) + ap.execute("ifconfig " + ap.ifname + " down") + raise