From 6869b43fe082008d43e7a7b95cfa61857d4f0517 Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Thu, 10 Nov 2011 15:16:21 +0100 Subject: cesar: update and move discover procedure scenario from cco0/s1 to scenario --- .../station/cco0/s1/py/sc14_discover_beacon.py | 86 ---------------------- cesar/test_general/station/scenario/Makefile | 2 +- .../station/scenario/py/sc06_discover_procedure.py | 61 +++++++++++++++ 3 files changed, 62 insertions(+), 87 deletions(-) delete mode 100644 cesar/test_general/station/cco0/s1/py/sc14_discover_beacon.py create mode 100644 cesar/test_general/station/scenario/py/sc06_discover_procedure.py (limited to 'cesar/test_general/station') diff --git a/cesar/test_general/station/cco0/s1/py/sc14_discover_beacon.py b/cesar/test_general/station/cco0/s1/py/sc14_discover_beacon.py deleted file mode 100644 index 17b3b87436..0000000000 --- a/cesar/test_general/station/cco0/s1/py/sc14_discover_beacon.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python - -############################################################################## -# Three stations on the AVLN # -# ---------------------------------------------------------------------- # -# # -# Objective: Verify the discover process done by the CCo. # -# Once the CCo is choose in the AVLN, the discover process shall start # -# 83 beacon periods after (at 50Hz). The real objective is to get 3 # -# discover beacons since the apparition of the CCo. # -# The discovers beacon shall have a Source TEI different from 0. # -############################################################################## - -import unittest -import sys - -sys.path.append ('../../../../maximus/python/tools/csi/') -sys.path.append ('../../../../maximus/python/obj/') -sys.path.append ('../../../../maximus/python/') -sys.path.append ('../../../../maximus/python/lib/cesar') - -from struct import unpack - -from csicore import * - -csi = csiCore (1234) - -# Creating an AVLN. -avln = csi.avln_add ("Homeplug_AVLN1", "AVLN1") - -macs = ["00:13:d7:00:00:01", "00:13:d7:00:00:02", "00:13:d7:00:00:03"] -debugs = [False, False, False] - -for i in range (0, len (macs)): - avln.sta_add (macs[i], False, False, "Homeplug_Station" + str (i), - "spidcom_spc300_sta" + str (i), "station" + str (i), 1, - debugs[i]) - -csi.process_init (sys.argv + ['-e', 'obj/cco0s1.elf']) -csi.process_avlns_launch () -csi.process_wait_association () -# Skip the first round of discovery procedure. -csi.process_wait_sec (10) - -# Activate the sniffer for the beacon RX on the CCo. Normally the CCo shall -# only receive discover beacons not central beacon in this test because there -# is only one AVLN. -cco = avln.get_sta (len (macs) - 1) -state = csi.sniffer_activate (cco , False, False, False, True) -if state == False: - print "Sniffer not activated for CCo" - -# Wait 3 discover beacons from each station for 12 seconds. -db = csi.sniff_packets (2, 12); - -#print "Removing the AVLNS" -#csi.process_test_stop_avlns () -csi.process_avlns_remove () - -result = csi.process_end_get_result () - -class TestDiscoverBeacon(unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def test (self): - stei_list = list() - self.failUnless (db != None) - self.failUnless (len (db) == 2) - for i in range (0, len(db)): - data = db[i].get() - data = unpack (len(data) * 'B', data) - stei_list.append (hex(data[31])) - type = (data[32] & 0x3) - self.failUnless (type == 1) - self.failUnless (stei_list[0] != stei_list[1]) - -suite = unittest.TestLoader().loadTestsFromTestCase(TestDiscoverBeacon) -testResult = unittest.TextTestRunner(verbosity=2).run(suite) - -# For nightly build errors -sys.exit ((1, 0)[result and testResult.wasSuccessful ()]) diff --git a/cesar/test_general/station/scenario/Makefile b/cesar/test_general/station/scenario/Makefile index 6024089c57..ee672e158f 100644 --- a/cesar/test_general/station/scenario/Makefile +++ b/cesar/test_general/station/scenario/Makefile @@ -13,7 +13,7 @@ include $(BASE)/common/make/top.mk testbook: py/sc01_assoc_auth.py py/sc02_stas_communication.py \ py/sc03_two_avln_coexisting.py py/sc04_cc_whoru.py \ - py/sc05_cc_leave.py + py/sc05_cc_leave.py py/sc06_discover_procedure.py python testbook.py $^ > $@.rst CLEAN_FILES += testbook.rst diff --git a/cesar/test_general/station/scenario/py/sc06_discover_procedure.py b/cesar/test_general/station/scenario/py/sc06_discover_procedure.py new file mode 100644 index 0000000000..c294599039 --- /dev/null +++ b/cesar/test_general/station/scenario/py/sc06_discover_procedure.py @@ -0,0 +1,61 @@ +#!/usr/bin/python + +############################################################################# +# Copyright (C) 2011 Spidcom +############################################################################# + +import sys +sys.path.append ('py') +from scenario_init import * + +class TestDiscoverProcedure (unittest.TestCase): + """In HomePlug AV the CCo must require a discover beacon from each station + in a cycle of 10 seconds. + """ + + def setUp (self): + self.csi = csiCore (1234) + self.csi.process_init (args) + self.csi.init_test_bed ([2]) + self.computer_mac = "10:10:10:10:10:10" + + def tearDown (self): + self.csi.uninit_test_bed () + self.csi.process_uninit () + del self.csi + + def testDiscoverProcedure (self): + """Create an AVLN of 2 stations. Wait for authentication and then + activate the sniffer on one of the stations. + Sniff only beacons TX/RX. + + Excepted results: After a central beacon with a discover beacon entry, + a discover beacon from the requested station must be present. + """ + avln = self.csi.avln_get (0) + cco = avln.get_cco (self.csi.get_maximus ()) + sniff_state = sniffer (self.csi.get_maximus (), cco, + beacon_tx = True, beacon_rx = True) + self.failUnless (sniff_state) + timeout = 12 + # On AV for a powerline in 50Hz we have 25 beacon / second. + rsp = self.csi.sniff_packets (25 * timeout, timeout); + # Now for each beacon with a discover beacon entry must be followed + # by a discover beacon of the station requested. + stei = None + for i in rsp: + m = Ether (i.get ()) + # Central beacon. + if m.bt == 0: + for i in m.bentry: + if i.header == scammer.BENTRY_HDR['DISCOVER']: + stei = i.tei + elif m.bt == 1: + self.failUnless (m.stei == stei) + sniff_state = sniffer (self.csi.get_maximus (), cco) + self.failUnless (sniff_state) + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(TestDiscoverProcedure) + testResult = unittest.TextTestRunner(verbosity=2).run(suite) + sys.exit ((1, 0)[testResult.wasSuccessful ()]) -- cgit v1.2.3