Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
emac_test_unicast_long.cpp
00001 /* 00002 * Copyright (c) 2018, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "mbed.h" 00019 #include "greentea-client/test_env.h" 00020 #include "unity.h" 00021 #include "utest.h" 00022 00023 #include "emac_tests.h" 00024 #include "emac_util.h" 00025 #include "emac_ctp.h" 00026 00027 using namespace utest::v1; 00028 00029 void test_emac_unicast_long_cb(int opt) 00030 { 00031 static bool send_request = true; 00032 static int no_response_cnt = 0; 00033 static int retries = 0; 00034 static int msg_len = 0; 00035 static int test_step = 0; 00036 00037 // Timeout 00038 if (opt == TIMEOUT && send_request) { 00039 CTP_MSG_SEND(msg_len, emac_if_get_echo_server_addr(0), emac_if_get_own_addr(), emac_if_get_own_addr(), 0); 00040 send_request = false; 00041 no_response_cnt = 0; 00042 } else if (opt == TIMEOUT) { 00043 if (++no_response_cnt > 350) { 00044 if (++retries > 5) { 00045 printf("too many retries\r\n\r\n"); 00046 SET_ERROR_FLAGS(TEST_FAILED); 00047 END_TEST_LOOP; 00048 } else { 00049 printf("retry count %i\r\n\r\n", retries); 00050 send_request = true; 00051 } 00052 } 00053 } 00054 00055 // Echo response received 00056 if (opt == INPUT) { 00057 if (++test_step > 50000) { 00058 END_TEST_LOOP; 00059 } 00060 00061 if (++test_step % 2000 == 0) { 00062 printf("test step %i\r\n\r\n", test_step); 00063 } 00064 00065 msg_len = rand() % ETH_MAX_LEN; 00066 retries = 0; 00067 send_request = true; 00068 } 00069 } 00070 00071 void test_emac_unicast_long() 00072 { 00073 RESET_ALL_ERROR_FLAGS; 00074 SET_TRACE_LEVEL(TRACE_FAILURE); 00075 00076 if (ECHO_SERVER_ADDRESS_KNOWN) { 00077 START_TEST_LOOP(test_emac_unicast_long_cb, 1); 00078 } 00079 00080 PRINT_ERROR_FLAGS; 00081 TEST_ASSERT_FALSE(ERROR_FLAGS); 00082 RESET_OUTGOING_MSG_DATA; 00083 }
Generated on Tue Aug 9 2022 00:37:06 by
1.7.2