Merge pull request #8796 from artokin/nanostack_mac_tester_sync

nanostack-mac-tester sync with v1.0.0
pull/8944/head
Cruz Monrreal 2018-11-30 17:51:23 -06:00 committed by GitHub
commit b83cdb303e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 151 additions and 21 deletions

View File

@ -477,6 +477,7 @@ void mac_data_confirm_handler(const mac_api_t *api, const mcps_data_conf_t *data
if (data->status == expected_statuses.data_conf) {
cmd_ready(CMDLINE_RETCODE_SUCCESS);
} else {
cmd_printf("CMD failed, status: %hhu (%s)\n", data->status, mlme_status_string(data->status));
cmd_ready(CMDLINE_RETCODE_FAIL);
}
}
@ -501,12 +502,14 @@ void mac_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *da
}
if (data->msdu_ptr && expected_statuses.data_ind) {
if (data->msduLength != expected_statuses.data_ind_len) {
cmd_printf("Bad recv length %d != %d!\n", data->msduLength, expected_statuses.data_ind_len);
return;
}
if (strncmp((const char *)data->msdu_ptr, (const char *)expected_statuses.data_ind, expected_statuses.data_ind_len) == 0) {
++data_count;
cmd_printf("Data count %d\n", data_count);
} else {
tr_warn("Received unexpected data!");
cmd_printf("Received unexpected data!\n");
}
}
}
@ -521,6 +524,7 @@ void mac_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
if (data->status == expected_statuses.purge_conf) {
cmd_ready(CMDLINE_RETCODE_SUCCESS);
} else {
cmd_printf("CMD failed, status: %hhu (%s)\n", data->status, mlme_status_string(data->status));
cmd_ready(CMDLINE_RETCODE_FAIL);
}
}
@ -547,6 +551,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
if (get_data->status == expected_statuses.get_conf) {
cmd_ready(CMDLINE_RETCODE_SUCCESS);
} else {
cmd_printf("CMD failed, status: %hhu (%s)\n", get_data->status, mlme_status_string(get_data->status));
cmd_ready(CMDLINE_RETCODE_FAIL);
}
break;
@ -585,6 +590,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
if (scan_data->status == expected_statuses.scan_conf || scan_data->status == MLME_LIMIT_REACHED) {
cmd_ready(CMDLINE_RETCODE_SUCCESS);
} else {
cmd_printf("CMD failed, status: %hhu (%s)\n", scan_data->status, mlme_status_string(scan_data->status));
cmd_ready(CMDLINE_RETCODE_FAIL);
}
break;
@ -599,24 +605,28 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
mlme_poll_conf_t *poll_data = (mlme_poll_conf_t *)data;
cmd_printf("MLME-POLL.confirm\n");
if (!silent_mode) {
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
cmd_printf("data_count %u\n", data_count);
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
cmd_printf("expected status: %hhu (%s)\n", expected_statuses.poll_conf, mlme_status_string(expected_statuses.poll_conf));
cmd_printf("data_count %u\n", data_count);
}
if (expected_statuses.poll_conf == MLME_SUCCESS) {
if (data_count == 1 && poll_data->status == MLME_SUCCESS) {
cmd_ready(CMDLINE_RETCODE_SUCCESS);
} else {
cmd_printf("CMD failed, data_count = %u, status:%hhu\n", data_count, poll_data->status);
cmd_ready(CMDLINE_RETCODE_FAIL);
}
} else if (expected_statuses.poll_conf == poll_data->status) {
cmd_ready(CMDLINE_RETCODE_SUCCESS);
} else {
cmd_printf("CMD failed, data_count = %u, status:%hhu, expected ret:%hhu\n", data_count, poll_data->status, expected_statuses.poll_conf);
cmd_ready(CMDLINE_RETCODE_FAIL);
}
break;
}
default: {
cmd_ready(CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
cmd_printf("CMD failed, not implemented\n");
break;
}
}

View File

@ -28,7 +28,7 @@
#include "mac_mcps.h"
#include "mac_common_defines.h"
#include "mac_filter_api.h"
#include "util.h"
#include "mac_tester_util.h"
#define LOOKUP_DESCRIPTOR_TABLE_SIZE 2
#define DEVICE_DESCRIPTOR_TABLE_SIZE 2

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "util.h"
#include "mac_tester_util.h"
int string_to_bytes(const char *str, uint8_t *buf, int bytes)
{

View File

@ -18,12 +18,13 @@ limitations under the License.
import threading
import os,sys
from icetea_lib.bench import Bench
from icetea_lib.TestStepError import TestStepFail
class Testcase(Bench):
def __init__(self):
Bench.__init__(self, name = "ED_scan",
title = "ED scan test",
status = "development",
status = "released",
type = "smoke",
subtype = "",
execution = {
@ -54,9 +55,6 @@ class Testcase(Bench):
def setUp(self):
self.channel = 11
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
def spam_channel(self, event):
while not event.wait(0.1):
@ -71,8 +69,16 @@ class Testcase(Bench):
res = res | ( 1 << ch)
return hex(res)
def case(self):
def do_test_iteration(self):
self.lock_th = threading.Lock()
self.command("First", "mlme-reset")
self.command("Second", "mlme-reset")
self.command("Third", "mlme-reset")
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
self.payload = "01234567890123456789012345678901234567890123456789"
# Start PAN coordinator
@ -105,6 +111,20 @@ class Testcase(Bench):
# Energy detection analysis
self.command("Second", "analyze-ed --channel {} --above 100".format(self.channel))
def case(self):
# Try tests few times because of potential RF failures
loop = 0
while loop < 5:
try:
self.do_test_iteration()
break
except TestStepFail:
self.logger.info("Warning, iteration failed #" + str(loop+1))
loop = loop + 1
self.delay(5)
else:
raise TestStepFail("Too many failed iterations!")
def tearDown(self):
self.command("First", "silent-mode off")
self.command("Third", "silent-mode off")
@ -112,3 +132,4 @@ class Testcase(Bench):
self.th.join()
del self.th
self.reset_dut()

View File

@ -17,12 +17,13 @@ limitations under the License.
import os,sys
from icetea_lib.bench import Bench
from icetea_lib.TestStepError import TestStepFail
class Testcase(Bench):
def __init__(self):
Bench.__init__(self, name = "address_read_and_write",
title = "MAC address and PAN id read/write test",
status = "development",
status = "released",
type = "smoke",
subtype = "",
execution = {
@ -52,7 +53,8 @@ class Testcase(Bench):
def setUp(self):
pass
def case(self):
def do_test_iteration(self):
self.command("First", "mlme-reset")
self.command("First", "addr")
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
self.command("First", "addr --16-bit 0xABCD")
@ -61,5 +63,20 @@ class Testcase(Bench):
self.command("First", "addr")
self.verify_trace(1, "MAC64: 01:02:03:00:00:00:00:01")
def case(self):
# Try tests few times because of potential RF failures
loop = 0
while loop < 5:
try:
self.do_test_iteration()
break
except TestStepFail:
self.logger.info("Warning, iteration failed #" + str(loop+1))
loop = loop + 1
self.delay(5)
else:
raise TestStepFail("Too many failed iterations!")
def tearDown(self):
self.reset_dut()

View File

@ -17,12 +17,13 @@ limitations under the License.
import os,sys
from icetea_lib.bench import Bench
from icetea_lib.TestStepError import TestStepFail
class Testcase(Bench):
def __init__(self):
Bench.__init__(self, name = "create_and_join_PAN",
title = "Create a PAN and have a device join it",
status = "development",
status = "released",
type = "smoke",
subtype = "",
execution = {
@ -60,12 +61,16 @@ class Testcase(Bench):
def setUp(self):
self.channel = 11
def case(self):
def do_test_iteration(self):
self.command("First", "mlme-reset")
self.command("Second", "mlme-reset")
self.command("Third", "mlme-reset")
# Beacon payload
self.command("First", "mlme-set --attr 0x45 --value_ascii mac-tester --value_size 10")
# Beacon payload length
self.command("First", "mlme-set --attr 0x46 --value_uint8 10 --value_size 1")
self.command("Second", "mlme-set --attr 0x45 --value_ascii second-mac-tester --value_size 17")
self.command("Second", "mlme-set --attr 0x46 --value_uint8 17 --value_size 1")
@ -84,5 +89,19 @@ class Testcase(Bench):
self.command("Third", "find-beacon --data mac-tester")
self.command("Third", "find-beacon --data second-mac-tester")
def case(self):
# Try tests few times because of potential RF failures
loop = 0
while loop < 5:
try:
self.do_test_iteration()
break
except TestStepFail:
self.logger.info("Warning, iteration failed #" + str(loop+1))
loop = loop + 1
self.delay(5)
else:
raise TestStepFail("Too many failed iterations!")
def tearDown(self):
self.reset_dut()

View File

@ -17,12 +17,13 @@ limitations under the License.
import os,sys
from icetea_lib.bench import Bench
from icetea_lib.TestStepError import TestStepFail
class Testcase(Bench):
def __init__(self):
Bench.__init__(self, name = "send_data",
title = "Simple data transmission test",
status = "development",
status = "released",
type = "smoke",
subtype = "",
execution = {
@ -52,10 +53,14 @@ class Testcase(Bench):
def setUp(self):
self.channel = 11
def do_test_iteration(self):
self.command("First", "mlme-reset")
self.command("Second", "mlme-reset")
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
def case(self):
# Start PAN coordinator
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
# Start PAN beacon
@ -65,5 +70,20 @@ class Testcase(Bench):
self.command("First", "data --dst_addr 01:02:03:00:00:00:00:02 --msdu_length 5 --msdu abcde")
self.command("Second", "data --dst_addr 01:02:03:00:00:00:00:01 --msdu_length 5 --msdu 12345")
def case(self):
# Try tests few times because of potential RF failures
loop = 0
while loop < 5:
try:
self.do_test_iteration()
break
except TestStepFail:
self.logger.info("Warning, iteration failed #" + str(loop+1))
loop = loop + 1
self.delay(5)
else:
raise TestStepFail("Too many failed iterations!")
def tearDown(self):
self.reset_dut()

View File

@ -17,12 +17,13 @@ limitations under the License.
import os,sys
from icetea_lib.bench import Bench
from icetea_lib.TestStepError import TestStepFail
class Testcase(Bench):
def __init__(self):
Bench.__init__(self, name = "send_data_indirect",
title = "Indirect data transmission test",
status = "development",
status = "released",
type = "smoke",
subtype = "",
execution = {
@ -53,11 +54,17 @@ class Testcase(Bench):
def setUp(self):
self.channel = 11
def do_test_iteration(self):
self.channel = 11
self.command("First", "mlme-reset")
self.command("Second", "mlme-reset")
self.command("Third", "mlme-reset")
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03")
def case(self):
# Start PAN coordinator
self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel))
# Start PAN beacon
@ -107,5 +114,21 @@ class Testcase(Bench):
self.command("Third", "poll --coord_address 01:02:03:00:00:00:00:01")
self.command("*", "silent-mode off")
def case(self):
# Try tests few times because of potential RF failures
loop = 0
while loop < 5:
try:
self.do_test_iteration()
break
except TestStepFail:
self.logger.info("Warning, iteration failed #" + str(loop+1))
loop = loop + 1
self.delay(5)
else:
raise TestStepFail("Too many failed iterations!")
def tearDown(self):
self.command("*", "silent-mode off")
self.reset_dut()

View File

@ -17,12 +17,13 @@ limitations under the License.
import os,sys
from icetea_lib.bench import Bench
from icetea_lib.TestStepError import TestStepFail
class Testcase(Bench):
def __init__(self):
Bench.__init__(self, name = "send_large_payloads",
title = "Data transmission test with large packets",
status = "development",
status = "released",
type = "reliability",
subtype = "",
execution = {
@ -52,10 +53,14 @@ class Testcase(Bench):
def setUp(self):
self.channel = 11
def do_test_iteration(self):
self.command("First", "mlme-reset")
self.command("Second", "mlme-reset")
self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01")
self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02")
def case(self):
#104 characters, headers are 2+1+2+8+8+2=23 bytes, resulting in a packet size of 127 (max)
large_payload = "0123456789abcdefghjiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZZZZZZZZZ0123456789012345678901234567891234"
# Start PAN coordinator
@ -83,5 +88,20 @@ class Testcase(Bench):
self.command("Second", "data")
self.command("First", "wait")
def case(self):
# Try tests few times because of potential RF failures
loop = 0
while loop < 5:
try:
self.do_test_iteration()
break
except TestStepFail:
self.logger.info("Warning, iteration failed #" + str(loop+1))
loop = loop + 1
self.delay(5)
else:
raise TestStepFail("Too many failed iterations!")
def tearDown(self):
self.reset_dut()