Skip to content

Commit 421df73

Browse files
author
Olli-Pekka Puolitaival
committed
Autoformatted mac tests
1 parent a6219e9 commit 421df73

File tree

7 files changed

+243
-217
lines changed

7 files changed

+243
-217
lines changed

TEST_APPS/testcases/nanostack_mac_tester/ED_scan.py

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,42 @@
1616
"""
1717

1818
import threading
19-
import os,sys
19+
import sys
2020
from icetea_lib.bench import Bench
2121

22+
2223
class Testcase(Bench):
2324
def __init__(self):
24-
Bench.__init__(self, name = "ED_scan",
25-
title = "ED scan test",
26-
status = "development",
27-
type = "smoke",
28-
subtype = "",
29-
execution = {
30-
"skip": {
31-
"value": False,
32-
"reason": ""
33-
}
34-
},
35-
author = "Valtteri Erkkila",
36-
purpose = "Tests reading the ED values from channels 11-16",
37-
feature = ["MLME-SCAN (ED)"],
38-
component = ["MAC"],
39-
requirements = {
40-
"duts": {
41-
'*': {
42-
"count":3,
43-
"type": "hardware",
44-
"allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"],
45-
"application": {
25+
Bench.__init__(self, name="ED_scan",
26+
title="ED scan test",
27+
status="development",
28+
type="smoke",
29+
subtype="",
30+
execution={
31+
"skip": {
32+
"value": False,
33+
"reason": ""
34+
}
35+
},
36+
author="Valtteri Erkkila",
37+
purpose="Tests reading the ED values from channels 11-16",
38+
feature=["MLME-SCAN (ED)"],
39+
component=["MAC"],
40+
requirements={
41+
"duts": {
42+
'*': {
43+
"count": 3,
44+
"type": "hardware",
45+
"allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"],
46+
"application": {
4647
"name": "TEST_APPS-device-nanostack_mac_tester"
47-
}
48-
},
49-
"1":{"nick": "First"},
50-
"2":{"nick": "Second"},
51-
"3":{"nick": "Third"}
52-
}}
53-
)
48+
}
49+
},
50+
"1": {"nick": "First"},
51+
"2": {"nick": "Second"},
52+
"3": {"nick": "Third"}
53+
}}
54+
)
5455

5556
def setUp(self):
5657
self.channel = 11
@@ -61,14 +62,18 @@ def setUp(self):
6162
def spam_channel(self, event):
6263
while not event.wait(0.1):
6364
self.lock_th.acquire()
64-
self.command("First", "data --dst_addr 01:02:03:00:00:00:00:03 --msdu {} --msdu_length {} --wait_for_confirm false".format(self.payload, len(self.payload)))
65-
self.command("Third", "data --dst_addr 01:02:03:00:00:00:00:01 --msdu {} --msdu_length {} --wait_for_confirm false".format(self.payload, len(self.payload)))
65+
self.command("First",
66+
"data --dst_addr 01:02:03:00:00:00:00:03 --msdu {} --msdu_length {} --wait_for_confirm false".format(
67+
self.payload, len(self.payload)))
68+
self.command("Third",
69+
"data --dst_addr 01:02:03:00:00:00:00:01 --msdu {} --msdu_length {} --wait_for_confirm false".format(
70+
self.payload, len(self.payload)))
6671
self.lock_th.release()
6772

6873
def mask_from_channel_list(self, channels):
6974
res = 0
7075
for ch in channels:
71-
res = res | ( 1 << ch)
76+
res = res | (1 << ch)
7277
return hex(res)
7378

7479
def case(self):
@@ -79,23 +84,24 @@ def case(self):
7984
self.command("Second", "start --pan_coordinator false --logical_channel {}".format(self.channel))
8085
self.command("Third", "start --pan_coordinator false --logical_channel {}".format(self.channel))
8186

82-
#No reason to print their spamming
87+
# No reason to print their spamming
8388
self.command("First", "silent-mode on")
8489
self.command("Third", "silent-mode on")
8590

8691
self.stop_event = threading.Event()
8792
self.th = threading.Thread(target=self.spam_channel, args=(self.stop_event,))
8893
self.th.start()
8994
self.stopped = True
90-
channels = range(11,27)
95+
channels = range(11, 27)
9196
for i in range(0, 3):
9297
self.lock_th.acquire()
9398
self.command("First", "mlme-reset")
9499
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
95100
self.command("Third", "mlme-reset")
96101
self.command("Third", "start --pan_coordinator false --logical_channel {}".format(self.channel))
97102
self.lock_th.release()
98-
self.command("Second", "scan --scan_type 0 --scan_duration 7 --channel_mask {}".format(self.mask_from_channel_list(channels)))
103+
self.command("Second", "scan --scan_type 0 --scan_duration 7 --channel_mask {}".format(
104+
self.mask_from_channel_list(channels)))
99105
self.command("Second", "analyze-ed --channel {} --above 100".format(self.channel))
100106

101107
def tearDown(self):
@@ -106,5 +112,6 @@ def tearDown(self):
106112
del self.th
107113
self.reset_dut()
108114

109-
if __name__=='__main__':
110-
sys.exit( Testcase().run() )
115+
116+
if __name__ == '__main__':
117+
sys.exit(Testcase().run())
Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, Arm Limited and affiliates.
2+
Copyright (c) 2018, Arm Limited and affiliates.
33
SPDX-License-Identifier: Apache-2.0
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,39 +15,40 @@
1515
limitations under the License.
1616
"""
1717

18-
import os,sys
18+
import sys
1919
from icetea_lib.bench import Bench
2020

21+
2122
class Testcase(Bench):
2223
def __init__(self):
23-
Bench.__init__(self, name = "address_read_and_write",
24-
title = "MAC address and PAN id read/write test",
25-
status = "development",
26-
type = "smoke",
27-
subtype = "",
28-
execution = {
29-
"skip": {
30-
"value": False,
31-
"reason": ""
32-
}
33-
},
34-
author = "Valtteri Erkkila",
35-
purpose = "Tests reading a MAC address from the driver, and writing to the modifiable MAC address",
36-
feature = ["MLME-SET"],
37-
component = ["MAC"],
38-
requirements = {
39-
"duts": {
40-
'*': {
41-
"count":1,
42-
"type": "hardware",
43-
"allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"],
44-
"application": {
24+
Bench.__init__(self, name="address_read_and_write",
25+
title="MAC address and PAN id read/write test",
26+
status="development",
27+
type="smoke",
28+
subtype="",
29+
execution={
30+
"skip": {
31+
"value": False,
32+
"reason": ""
33+
}
34+
},
35+
author="Valtteri Erkkila",
36+
purpose="Tests reading a MAC address from the driver, and writing to the modifiable MAC address",
37+
feature=["MLME-SET"],
38+
component=["MAC"],
39+
requirements={
40+
"duts": {
41+
'*': {
42+
"count": 1,
43+
"type": "hardware",
44+
"allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"],
45+
"application": {
4546
"name": "TEST_APPS-device-nanostack_mac_tester"
46-
}
47-
},
48-
"1":{"nick": "First"}
49-
}}
50-
)
47+
}
48+
},
49+
"1": {"nick": "First"}
50+
}}
51+
)
5152

5253
def setUp(self):
5354
pass
@@ -56,13 +57,14 @@ def case(self):
5657
self.command("First", "addr")
5758
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
5859
self.command("First", "addr --16-bit 0xABCD")
59-
#macPANId
60+
# macPANId
6061
self.command("First", "mlme-set --attr 0x50 --value_bytes CD:CD --value_size 2")
6162
self.command("First", "addr")
6263
self.verify_trace(1, "MAC64: 01:02:03:00:00:00:00:01")
6364

6465
def tearDown(self):
6566
self.reset_dut()
6667

67-
if __name__=='__main__':
68-
sys.exit( Testcase().run() )
68+
69+
if __name__ == '__main__':
70+
sys.exit(Testcase().run())
Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, Arm Limited and affiliates.
2+
Copyright (c) 2018, Arm Limited and affiliates.
33
SPDX-License-Identifier: Apache-2.0
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,68 +15,69 @@
1515
limitations under the License.
1616
"""
1717

18-
import os,sys
18+
import sys
1919
from icetea_lib.bench import Bench
2020

21+
2122
class Testcase(Bench):
2223
def __init__(self):
23-
Bench.__init__(self, name = "create_and_join_PAN",
24-
title = "Create a PAN and have a device join it",
25-
status = "development",
26-
type = "smoke",
27-
subtype = "",
28-
execution = {
29-
"skip": {
30-
"value": False,
31-
"reason": ""
32-
}
33-
},
34-
author = "Valtteri Erkkila",
35-
purpose = "",
36-
feature = ["MLME-START", "MLME-SCAN (active)"],
37-
component = ["MAC"],
38-
requirements = {
39-
"duts": {
40-
'*': {
41-
"count":3,
42-
"type": "hardware",
43-
"allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"],
44-
"application": {
24+
Bench.__init__(self, name="create_and_join_PAN",
25+
title="Create a PAN and have a device join it",
26+
status="development",
27+
type="smoke",
28+
subtype="",
29+
execution={
30+
"skip": {
31+
"value": False,
32+
"reason": ""
33+
}
34+
},
35+
author="Valtteri Erkkila",
36+
purpose="",
37+
feature=["MLME-START", "MLME-SCAN (active)"],
38+
component=["MAC"],
39+
requirements={
40+
"duts": {
41+
'*': {
42+
"count": 3,
43+
"type": "hardware",
44+
"allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"],
45+
"application": {
4546
"name": "TEST_APPS-device-nanostack_mac_tester"
46-
}
47-
},
48-
"1":{"nick": "First"},
49-
"2":{"nick": "Second"},
50-
"3":{"nick": "Third"}
51-
}}
52-
)
47+
}
48+
},
49+
"1": {"nick": "First"},
50+
"2": {"nick": "Second"},
51+
"3": {"nick": "Third"}
52+
}}
53+
)
5354

5455
def mask_from_channel_list(self, channels):
5556
res = 0
5657
for ch in channels:
57-
res = res | ( 1 << ch)
58+
res = res | (1 << ch)
5859
return hex(res)
5960

6061
def setUp(self):
6162
self.channel = 11
6263

6364
def case(self):
64-
#Beacon payload & length
65+
# Beacon payload & length
6566
self.command("First", "mlme-set --attr 0x45 --value_ascii mac-tester --value_size 10")
6667
self.command("First", "mlme-set --attr 0x46 --value_uint8 10 --value_size 1")
6768

6869
self.command("Second", "mlme-set --attr 0x45 --value_ascii second-mac-tester --value_size 17")
6970
self.command("Second", "mlme-set --attr 0x46 --value_uint8 17 --value_size 1")
7071

7172
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
72-
self.command("Second", "start --pan_coordinator true --logical_channel {}".format(int(self.channel)+1))
73+
self.command("Second", "start --pan_coordinator true --logical_channel {}".format(int(self.channel) + 1))
7374
self.delay(3)
7475
if self.channel == 11:
75-
channels = [11,12]
76+
channels = [11, 12]
7677
elif self.channel == 26:
77-
channels = [25,26]
78+
channels = [25, 26]
7879
else:
79-
channels = [self.channel, self.channel+1]
80+
channels = [self.channel, self.channel + 1]
8081
self.command("Third", "scan --channel_mask {}".format(self.mask_from_channel_list(channels)))
8182
self.delay(0.2)
8283
self.command("Third", "find-beacon --data mac-tester")
@@ -85,5 +86,6 @@ def case(self):
8586
def tearDown(self):
8687
self.reset_dut()
8788

88-
if __name__=='__main__':
89-
sys.exit( Testcase().run() )
89+
90+
if __name__ == '__main__':
91+
sys.exit(Testcase().run())

0 commit comments

Comments
 (0)