Merge pull request #7208 from mikaleppanen/add_long_emac_echo_test

Added long echo sequence test to EMAC tests
pull/7249/head
Cruz Monrreal 2018-06-18 10:08:13 -05:00 committed by GitHub
commit f54067d6c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 1 deletions

View File

@ -124,6 +124,12 @@ The test case passes if there are no responses from the echo server, but further
2. Repeats the sending 10 times.
3. Verifies that all are replied.
### EMAC unicast long
1. Sends CTP unicast messages with random Ethernet message length.
2. Repeats the sending 50000 times.
3. Verifies that all are replied.
### EMAC multicast filter
Tests multicast filtering. Multicast filtering is an optional feature for the EMAC. The test does not fail if filtering is not implemented.

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2018, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
#include "emac_tests.h"
#include "emac_util.h"
#include "emac_ctp.h"
using namespace utest::v1;
void test_emac_unicast_long_cb(int opt)
{
static bool send_request = true;
static int no_response_cnt = 0;
static int retries = 0;
static int msg_len = 0;
static int test_step = 0;
// Timeout
if (opt == TIMEOUT && send_request) {
CTP_MSG_SEND(msg_len, emac_if_get_echo_server_addr(0), emac_if_get_own_addr(), emac_if_get_own_addr(), 0);
send_request = false;
no_response_cnt = 0;
} else if (opt == TIMEOUT) {
if (++no_response_cnt > 350) {
if (++retries > 5) {
printf("too many retries\r\n\r\n");
SET_ERROR_FLAGS(TEST_FAILED);
END_TEST_LOOP;
} else {
printf("retry count %i\r\n\r\n", retries);
send_request = true;
}
}
}
// Echo response received
if (opt == INPUT) {
if (++test_step > 50000) {
END_TEST_LOOP;
}
if (++test_step % 2000 == 0) {
printf("test step %i\r\n\r\n", test_step);
}
msg_len = rand() % ETH_MAX_LEN;
retries = 0;
send_request = true;
}
}
void test_emac_unicast_long()
{
RESET_ALL_ERROR_FLAGS;
SET_TRACE_LEVEL(TRACE_FAILURE);
if (ECHO_SERVER_ADDRESS_KNOWN) {
START_TEST_LOOP(test_emac_unicast_long_cb, 1);
}
PRINT_ERROR_FLAGS;
TEST_ASSERT_FALSE(ERROR_FLAGS);
RESET_OUTGOING_MSG_DATA;
}
#endif

View File

@ -23,6 +23,7 @@ void test_emac_broadcast();
void test_emac_unicast();
void test_emac_unicast_frame_len();
void test_emac_unicast_burst();
void test_emac_unicast_long();
void test_emac_multicast_filter();
void test_emac_memory();

View File

@ -252,7 +252,7 @@ bool emac_if_update_reply_to_outgoing_msg(int receipt_number, int length, int in
/* If length of the sent message is smaller than Ethernet minimum frame length, validates against
minimum frame length or sent length (in case frame has been converted to be longer than minimum
length does not validate length) */
if (length != ETH_FRAME_MIN_LEN && outgoing_msgs[outgoing_msg_index].length != length && length < ETH_FRAME_MIN_LEN ) {
if (length != ETH_FRAME_MIN_LEN && length != ETH_FRAME_PADD_LEN && outgoing_msgs[outgoing_msg_index].length != length && length < ETH_FRAME_MIN_LEN) {
outgoing_msgs[outgoing_msg_index].flags |= INVALID_LENGHT;
}
} else {

View File

@ -59,6 +59,7 @@ extern const unsigned char eth_mac_broadcast_addr[];
#define ETH_FRAME_HEADER_LEN 28
#define ETH_FRAME_MIN_LEN 60 + 4
#define ETH_FRAME_PADD_LEN 60
#define ETH_MAC_ADDR_LEN 6
#define TIMEOUT 1

View File

@ -70,6 +70,7 @@ Case cases[] = {
Case("EMAC unicast", test_emac_unicast),
Case("EMAC unicast frame length", test_emac_unicast_frame_len),
Case("EMAC unicast burst", test_emac_unicast_burst),
Case("EMAC unicast long", test_emac_unicast_long),
Case("EMAC multicast filter", test_emac_multicast_filter),
Case("EMAC memory", test_emac_memory)
};