Skip to content

Commit b83cdb3

Browse files
author
Cruz Monrreal
authored
Merge pull request #8796 from artokin/nanostack_mac_tester_sync
nanostack-mac-tester sync with v1.0.0
2 parents 2b46b1d + bf6b904 commit b83cdb3

File tree

10 files changed

+151
-21
lines changed

10 files changed

+151
-21
lines changed

TEST_APPS/device/nanostack_mac_tester/source/mac_commands.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ void mac_data_confirm_handler(const mac_api_t *api, const mcps_data_conf_t *data
477477
if (data->status == expected_statuses.data_conf) {
478478
cmd_ready(CMDLINE_RETCODE_SUCCESS);
479479
} else {
480+
cmd_printf("CMD failed, status: %hhu (%s)\n", data->status, mlme_status_string(data->status));
480481
cmd_ready(CMDLINE_RETCODE_FAIL);
481482
}
482483
}
@@ -501,12 +502,14 @@ void mac_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *da
501502
}
502503
if (data->msdu_ptr && expected_statuses.data_ind) {
503504
if (data->msduLength != expected_statuses.data_ind_len) {
505+
cmd_printf("Bad recv length %d != %d!\n", data->msduLength, expected_statuses.data_ind_len);
504506
return;
505507
}
506508
if (strncmp((const char *)data->msdu_ptr, (const char *)expected_statuses.data_ind, expected_statuses.data_ind_len) == 0) {
507509
++data_count;
510+
cmd_printf("Data count %d\n", data_count);
508511
} else {
509-
tr_warn("Received unexpected data!");
512+
cmd_printf("Received unexpected data!\n");
510513
}
511514
}
512515
}
@@ -521,6 +524,7 @@ void mac_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
521524
if (data->status == expected_statuses.purge_conf) {
522525
cmd_ready(CMDLINE_RETCODE_SUCCESS);
523526
} else {
527+
cmd_printf("CMD failed, status: %hhu (%s)\n", data->status, mlme_status_string(data->status));
524528
cmd_ready(CMDLINE_RETCODE_FAIL);
525529
}
526530
}
@@ -547,6 +551,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
547551
if (get_data->status == expected_statuses.get_conf) {
548552
cmd_ready(CMDLINE_RETCODE_SUCCESS);
549553
} else {
554+
cmd_printf("CMD failed, status: %hhu (%s)\n", get_data->status, mlme_status_string(get_data->status));
550555
cmd_ready(CMDLINE_RETCODE_FAIL);
551556
}
552557
break;
@@ -585,6 +590,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
585590
if (scan_data->status == expected_statuses.scan_conf || scan_data->status == MLME_LIMIT_REACHED) {
586591
cmd_ready(CMDLINE_RETCODE_SUCCESS);
587592
} else {
593+
cmd_printf("CMD failed, status: %hhu (%s)\n", scan_data->status, mlme_status_string(scan_data->status));
588594
cmd_ready(CMDLINE_RETCODE_FAIL);
589595
}
590596
break;
@@ -599,24 +605,28 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
599605
mlme_poll_conf_t *poll_data = (mlme_poll_conf_t *)data;
600606
cmd_printf("MLME-POLL.confirm\n");
601607
if (!silent_mode) {
602-
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
603-
cmd_printf("data_count %u\n", data_count);
608+
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
609+
cmd_printf("expected status: %hhu (%s)\n", expected_statuses.poll_conf, mlme_status_string(expected_statuses.poll_conf));
610+
cmd_printf("data_count %u\n", data_count);
604611
}
605612
if (expected_statuses.poll_conf == MLME_SUCCESS) {
606613
if (data_count == 1 && poll_data->status == MLME_SUCCESS) {
607614
cmd_ready(CMDLINE_RETCODE_SUCCESS);
608615
} else {
616+
cmd_printf("CMD failed, data_count = %u, status:%hhu\n", data_count, poll_data->status);
609617
cmd_ready(CMDLINE_RETCODE_FAIL);
610618
}
611619
} else if (expected_statuses.poll_conf == poll_data->status) {
612620
cmd_ready(CMDLINE_RETCODE_SUCCESS);
613621
} else {
622+
cmd_printf("CMD failed, data_count = %u, status:%hhu, expected ret:%hhu\n", data_count, poll_data->status, expected_statuses.poll_conf);
614623
cmd_ready(CMDLINE_RETCODE_FAIL);
615624
}
616625
break;
617626
}
618627
default: {
619628
cmd_ready(CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
629+
cmd_printf("CMD failed, not implemented\n");
620630
break;
621631
}
622632
}

TEST_APPS/device/nanostack_mac_tester/source/mac_commands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "mac_mcps.h"
2929
#include "mac_common_defines.h"
3030
#include "mac_filter_api.h"
31-
#include "util.h"
31+
#include "mac_tester_util.h"
3232

3333
#define LOOKUP_DESCRIPTOR_TABLE_SIZE 2
3434
#define DEVICE_DESCRIPTOR_TABLE_SIZE 2

TEST_APPS/device/nanostack_mac_tester/source/util.cpp renamed to TEST_APPS/device/nanostack_mac_tester/source/mac_tester_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#include "util.h"
17+
#include "mac_tester_util.h"
1818

1919
int string_to_bytes(const char *str, uint8_t *buf, int bytes)
2020
{

TEST_APPS/testcases/nanostack_mac_tester/ED_scan.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
import threading
1919
import os,sys
2020
from icetea_lib.bench import Bench
21+
from icetea_lib.TestStepError import TestStepFail
2122

2223
class Testcase(Bench):
2324
def __init__(self):
2425
Bench.__init__(self, name = "ED_scan",
2526
title = "ED scan test",
26-
status = "development",
27+
status = "released",
2728
type = "smoke",
2829
subtype = "",
2930
execution = {
@@ -54,9 +55,6 @@ def __init__(self):
5455

5556
def setUp(self):
5657
self.channel = 11
57-
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
58-
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
59-
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
6058

6159
def spam_channel(self, event):
6260
while not event.wait(0.1):
@@ -71,8 +69,16 @@ def mask_from_channel_list(self, channels):
7169
res = res | ( 1 << ch)
7270
return hex(res)
7371

74-
def case(self):
72+
def do_test_iteration(self):
7573
self.lock_th = threading.Lock()
74+
self.command("First", "mlme-reset")
75+
self.command("Second", "mlme-reset")
76+
self.command("Third", "mlme-reset")
77+
78+
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
79+
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
80+
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
81+
7682
self.payload = "01234567890123456789012345678901234567890123456789"
7783

7884
# Start PAN coordinator
@@ -105,10 +111,25 @@ def case(self):
105111
# Energy detection analysis
106112
self.command("Second", "analyze-ed --channel {} --above 100".format(self.channel))
107113

114+
def case(self):
115+
# Try tests few times because of potential RF failures
116+
loop = 0
117+
while loop < 5:
118+
try:
119+
self.do_test_iteration()
120+
break
121+
except TestStepFail:
122+
self.logger.info("Warning, iteration failed #" + str(loop+1))
123+
loop = loop + 1
124+
self.delay(5)
125+
else:
126+
raise TestStepFail("Too many failed iterations!")
127+
108128
def tearDown(self):
109129
self.command("First", "silent-mode off")
110130
self.command("Third", "silent-mode off")
111131
self.stop_event.set()
112132
self.th.join()
113133
del self.th
114134
self.reset_dut()
135+

TEST_APPS/testcases/nanostack_mac_tester/address_read_and_write.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
import os,sys
1919
from icetea_lib.bench import Bench
20+
from icetea_lib.TestStepError import TestStepFail
2021

2122
class Testcase(Bench):
2223
def __init__(self):
2324
Bench.__init__(self, name = "address_read_and_write",
2425
title = "MAC address and PAN id read/write test",
25-
status = "development",
26+
status = "released",
2627
type = "smoke",
2728
subtype = "",
2829
execution = {
@@ -52,7 +53,8 @@ def __init__(self):
5253
def setUp(self):
5354
pass
5455

55-
def case(self):
56+
def do_test_iteration(self):
57+
self.command("First", "mlme-reset")
5658
self.command("First", "addr")
5759
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
5860
self.command("First", "addr --16-bit 0xABCD")
@@ -61,5 +63,20 @@ def case(self):
6163
self.command("First", "addr")
6264
self.verify_trace(1, "MAC64: 01:02:03:00:00:00:00:01")
6365

66+
def case(self):
67+
# Try tests few times because of potential RF failures
68+
loop = 0
69+
while loop < 5:
70+
try:
71+
self.do_test_iteration()
72+
break
73+
except TestStepFail:
74+
self.logger.info("Warning, iteration failed #" + str(loop+1))
75+
loop = loop + 1
76+
self.delay(5)
77+
else:
78+
raise TestStepFail("Too many failed iterations!")
79+
6480
def tearDown(self):
6581
self.reset_dut()
82+

TEST_APPS/testcases/nanostack_mac_tester/create_and_join_PAN.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
import os,sys
1919
from icetea_lib.bench import Bench
20+
from icetea_lib.TestStepError import TestStepFail
2021

2122
class Testcase(Bench):
2223
def __init__(self):
2324
Bench.__init__(self, name = "create_and_join_PAN",
2425
title = "Create a PAN and have a device join it",
25-
status = "development",
26+
status = "released",
2627
type = "smoke",
2728
subtype = "",
2829
execution = {
@@ -60,12 +61,16 @@ def mask_from_channel_list(self, channels):
6061
def setUp(self):
6162
self.channel = 11
6263

63-
def case(self):
64+
def do_test_iteration(self):
65+
self.command("First", "mlme-reset")
66+
self.command("Second", "mlme-reset")
67+
self.command("Third", "mlme-reset")
68+
6469
# Beacon payload
6570
self.command("First", "mlme-set --attr 0x45 --value_ascii mac-tester --value_size 10")
6671
# Beacon payload length
6772
self.command("First", "mlme-set --attr 0x46 --value_uint8 10 --value_size 1")
68-
73+
6974
self.command("Second", "mlme-set --attr 0x45 --value_ascii second-mac-tester --value_size 17")
7075
self.command("Second", "mlme-set --attr 0x46 --value_uint8 17 --value_size 1")
7176

@@ -84,5 +89,19 @@ def case(self):
8489
self.command("Third", "find-beacon --data mac-tester")
8590
self.command("Third", "find-beacon --data second-mac-tester")
8691

92+
def case(self):
93+
# Try tests few times because of potential RF failures
94+
loop = 0
95+
while loop < 5:
96+
try:
97+
self.do_test_iteration()
98+
break
99+
except TestStepFail:
100+
self.logger.info("Warning, iteration failed #" + str(loop+1))
101+
loop = loop + 1
102+
self.delay(5)
103+
else:
104+
raise TestStepFail("Too many failed iterations!")
105+
87106
def tearDown(self):
88107
self.reset_dut()

TEST_APPS/testcases/nanostack_mac_tester/send_data.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
import os,sys
1919
from icetea_lib.bench import Bench
20+
from icetea_lib.TestStepError import TestStepFail
2021

2122
class Testcase(Bench):
2223
def __init__(self):
2324
Bench.__init__(self, name = "send_data",
2425
title = "Simple data transmission test",
25-
status = "development",
26+
status = "released",
2627
type = "smoke",
2728
subtype = "",
2829
execution = {
@@ -52,10 +53,14 @@ def __init__(self):
5253

5354
def setUp(self):
5455
self.channel = 11
56+
57+
def do_test_iteration(self):
58+
self.command("First", "mlme-reset")
59+
self.command("Second", "mlme-reset")
60+
5561
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
5662
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
5763

58-
def case(self):
5964
# Start PAN coordinator
6065
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
6166
# Start PAN beacon
@@ -65,5 +70,20 @@ def case(self):
6570
self.command("First", "data --dst_addr 01:02:03:00:00:00:00:02 --msdu_length 5 --msdu abcde")
6671
self.command("Second", "data --dst_addr 01:02:03:00:00:00:00:01 --msdu_length 5 --msdu 12345")
6772

73+
def case(self):
74+
# Try tests few times because of potential RF failures
75+
loop = 0
76+
while loop < 5:
77+
try:
78+
self.do_test_iteration()
79+
break
80+
except TestStepFail:
81+
self.logger.info("Warning, iteration failed #" + str(loop+1))
82+
loop = loop + 1
83+
self.delay(5)
84+
else:
85+
raise TestStepFail("Too many failed iterations!")
86+
6887
def tearDown(self):
6988
self.reset_dut()
89+

TEST_APPS/testcases/nanostack_mac_tester/send_data_indirect.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
import os,sys
1919
from icetea_lib.bench import Bench
20+
from icetea_lib.TestStepError import TestStepFail
2021

2122
class Testcase(Bench):
2223
def __init__(self):
2324
Bench.__init__(self, name = "send_data_indirect",
2425
title = "Indirect data transmission test",
25-
status = "development",
26+
status = "released",
2627
type = "smoke",
2728
subtype = "",
2829
execution = {
@@ -53,11 +54,17 @@ def __init__(self):
5354

5455
def setUp(self):
5556
self.channel = 11
57+
58+
def do_test_iteration(self):
59+
self.channel = 11
60+
self.command("First", "mlme-reset")
61+
self.command("Second", "mlme-reset")
62+
self.command("Third", "mlme-reset")
63+
5664
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
5765
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
5866
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
5967

60-
def case(self):
6168
# Start PAN coordinator
6269
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
6370
# Start PAN beacon
@@ -107,5 +114,21 @@ def case(self):
107114
self.command("Third", "poll --coord_address 01:02:03:00:00:00:00:01")
108115
self.command("*", "silent-mode off")
109116

117+
def case(self):
118+
# Try tests few times because of potential RF failures
119+
loop = 0
120+
while loop < 5:
121+
try:
122+
self.do_test_iteration()
123+
break
124+
except TestStepFail:
125+
self.logger.info("Warning, iteration failed #" + str(loop+1))
126+
loop = loop + 1
127+
self.delay(5)
128+
else:
129+
raise TestStepFail("Too many failed iterations!")
130+
110131
def tearDown(self):
132+
self.command("*", "silent-mode off")
111133
self.reset_dut()
134+

0 commit comments

Comments
 (0)