summaryrefslogtreecommitdiff
path: root/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases
diff options
context:
space:
mode:
authorlundinc <lundinc@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2020-08-12 19:11:51 +0000
committerlundinc <lundinc@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2020-08-12 19:11:51 +0000
commit42255af1e27a3157d541f0812eaca447c569ca49 (patch)
tree5c8702c2f0dc1cb9be1a4d5ff285897d96b97dd2 /FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases
parentf5221dff43de249079c2da081723cb7a456f981f (diff)
downloadfreertos-master.tar.gz
commit 70dcbe4527a45ab4fea6d58c016e7d3032f31e8cHEADmaster
Author: Ming Yue <mingyue86010@gmail.com> Date: Tue Aug 11 17:06:59 2020 -0700 Remove unused wolfSSL files. (#197) * Remove unused wolfSSL files. * Add back some removed ciphers. * Update VS project file. commit 0e0edd96e8236b2ea4a6e6018812807be828c77f Author: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Tue Aug 11 10:50:30 2020 -0700 Use new QEMU test project to improve stream/message buffer tests (#168) * Add Eclipse/GCC project that targets the LM3S8962 QEMU model. * Get the Cortex-M QEMU project working. * Continue working on making stream buffer demo more robust and QEMU project. * Rename directory CORTEX_LM3S8986_QEMU to CORTEX_LM3S6965_QEMU. Work on making the Stream Buffer tests more robust. Check in before adding in the trace recorder. * Rename CORTEX_LM3S6969_QEMU to CORTEX_LM3S6969_GCC_QEMU. * Make the StreamBufferDemo.c common demo file (test file) more robust to other test tasks running at an equally high priority. * Work in progress checkin only - comments in main.c are incorrect. * Correct comments at the top of FreeRTOS/Demo/CORTEX_LM3S6965_GCC_QEMU/main.c Make the message buffer tests more robust in the case the a message buffer becomes full when prvSenderTask() has a higher priority than the reader task. * Disable trace recorder in the LM3S6965 QEMU demo. * I'm dropping FreeRTOS-Kernel reference update, since this seems to break the CMBC CI. Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 157a7fc39f19583ac8481e93fa3e1c91b1e1860c Author: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Sun Aug 9 22:21:44 2020 -0700 Use chacheable RAM in IAR project for MPU_M7_NUCLEO_H743ZI2 project (#193) This change updates the IAR project for Nucleo H743ZI2 to use the cacheable DTC RAM and enables L1 cache. In order to ensure the correct functioning of cache, the project sets configTEX_S_C_B_SRAM in FreeRTOSConfig.h to not mark the RAM as shareable. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> commit f3e43556f90f01b82918ad533b0c616489331919 Author: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Sun Aug 9 16:23:53 2020 -0700 Add MPU demo projects for NUCLEO-H743ZI2 board (#155) * Add MPU demo projects for NUCLEO-H743ZI2 board It contains projects for Keil uVision, STM32CubeIDE and IAR EW. This demo shows the use of newly added support for 16 MPU regions. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Delete not needed CMSIS files Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> commit 94aa31c3cbae7c929b8a412768b74631f4a6b461 Author: TakayukiMatsuo <62984531+TakayukiMatsuo@users.noreply.github.com> Date: Sat Aug 8 07:58:14 2020 +0900 Update wolfSSL to the latest version(v.4.4.0) (#186) * deleted old version wolfSSL before updating * updated wolfSSL to the latest version(v4.4.0) * updated wolfSSL to the latest version(v4.4.0) * added macros for timing resistance Co-authored-by: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Co-authored-by: Ming Yue <mingyue86010@gmail.com> commit 68518f5866aac58793c737d9a46dd07a6a816aaf Author: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Fri Aug 7 14:59:24 2020 -0700 Removed a 16MByte flash image file that was checked in by mistake (several years ago). (#173) Remove the copies of lwIP that are no longer reference from demo projects. Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com> commit d4bf09480a2c77b1a25cce35b32293be61ab586f Author: m17336 <45935231+m17336@users.noreply.github.com> Date: Thu Aug 6 22:37:08 2020 +0300 Update previous AVR ATmega0 and AVR Dx projecs + addition of equivalent projects in MPLAB.X and IAR (#180) * Updated indentation in AVR_ATMega4809_Atmel_Studio and AVR_Dx_Atmel_Studio projects, plus small fixes in their readme files. * Added AVR_ATMega4809_IAR, AVR_ATMega4809_MPLAB.X, AVR_Dx_IAR and AVR_Dx_MPLAB.X demo projects. * Removed build artefacts and added .gitignore files in AVR_ATMega4809_MPLAB.X and AVR_Dx_MPLAB.X projects. Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit f32a0647c8228ddd066f5d69a85b2e49086e4c95 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon Aug 3 16:45:10 2020 -0700 Remove CBMC patch which is not used anymore (#187) * Delete 0002-Change-FreeRTOS_IP_Private.h-union-to-struct.patch * Delete 0002-Change-FreeRTOS_IP_Private.h-union-to-struct.patch commit 08af68ef9049279b265c3d00e9c48fb9594129a8 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Sat Aug 1 16:38:23 2020 -0700 Remove dependency of CBMC on Patches (#181) * Changes to DHCP * CBMC DNS changes * Changes for TCP_IP * Changes to TCP_WIN * Define away static to nothing * Remove patches * Changes after Mark's comments v1 * Update MakefileCommon.json * Correction! commit a7fec906a415363338449447daf10d7517b78848 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 29 17:39:36 2020 -0700 Misc changes (#183) commit 07cf5e07e4a05d6775a2f9e753269f43f82cf6ba Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 29 16:15:38 2020 -0700 MISRA compliance changes for FreeRTOS+TCP headers (#165) * misra changes * Update FreeRTOS_IP_Private.h * Update FreeRTOS_IP_Private.h commit e903ac0fed7ce59916899e404f3e5ae5b08d1478 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 29 16:03:14 2020 -0700 UPD MISRA changes (#164) Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 97551bf44e7dc7dc1e4484a8fd30f699255e8569 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 29 15:52:00 2020 -0700 MISRA changes in FreeRTOS_TCP_WIN.c (#162) commit f2611cc5e5999c4c87e040a8c2d2e6b5e77a16a6 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 29 15:38:37 2020 -0700 MISRA compliance changes in FreeRTOS_Sockets{.c/.h} (#161) * MISRA changes Sockets * add other changes * Update FreeRTOSIPConfig.h * Update FreeRTOSIPConfig.h * Update FreeRTOSIPConfig.h * Update FreeRTOSIPConfig.h * correction * Add 'U' * Update FreeRTOS_Sockets.h * Update FreeRTOS_Sockets.h * Update FreeRTOS_Sockets.c * Update FreeRTOS_Sockets.h * Update after Gary's comments * Correction reverted commit ae4d4d38d9b2685bae159b4c87619cdb157c0bf7 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 29 13:56:57 2020 -0700 MISRA compliance changes for FreeRTOS_TCP_IP.c (#160) * MISRA tcp-ip changes * Changes after Hein's comments on original PR * Update FreeRTOS_TCP_IP.c Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit a457f43c66eb0f4be9d8f8678c0e3fb8d7ebd57b Author: Carl Lundin <53273776+lundinc2@users.noreply.github.com> Date: Tue Jul 28 13:01:38 2020 -0700 Add missing error state assignment. (#166) commit 915af50524e15a78ceb6c62b3d33f6562621ee46 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Mon Jul 27 17:30:53 2020 -0700 Add Atmel Studio projects for ATMega4809 and AVR128DA48 (#159) * Added explicit cast to allow roll over and avoid integer promotion during cycles counters comparison in recmutex.c. * Fixed type mismatch between declaration and definition of function xAreSemaphoreTasksStillRunning( void ). * Added Atmel Studio demo projects for ATMega4809 and AVR128DA48. * Per https://www.freertos.org/upgrading-to-FreeRTOS-V8.html, I'm updating portBASE_TYPE to BaseType_t. Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> * Update register test for ATmega4809 - to cover r28, r29, r31. - call public API taskYIELD() instead of portYIELD(). * Update ATmega4809 readme.md to include info for serial port setup, and minor wording fix. Co-authored-by: Alexandru Niculae - M17336 <alexandru.niculae@microchip.com> commit 4a7a48790d64127f85cc763721b575c51c452833 Author: Carl Lundin <53273776+lundinc2@users.noreply.github.com> Date: Thu Jul 23 10:22:33 2020 -0700 Add Uncrustify file used for Kernel. (#163) commit e0d62163b08769fd74f020709c398f994088ca96 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 22 18:06:23 2020 -0700 Sync with +TCP amazon-FreeRTOS (#158) * DNS.c commit * IP.c commit * Add various source & header files commit 8e36bee30eef2107e128edb58e83ee46e8241a91 Author: Nathan Chong <52972368+nchong-at-aws@users.noreply.github.com> Date: Tue Jul 21 12:51:20 2020 -0400 Prove buffer lemmas (#124) * Prove buffer lemmas * Update queue proofs to latest kernel source All changes were syntactic due to uncrustify code-formatting * Strengthen prvCopyDataToQueue proof * Add extract script for diff comparison Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit c720c18ada40b502436ea811e8d03dca919726d8 Author: Hein Tibosch <hein_tibosch@yahoo.es> Date: Tue Jul 14 05:35:44 2020 +0800 FreeRTOS+TCP Adding the combined driver for SAM4E and SAME70 v2 (#78) * Adding a combined +TCP driver for SAM4E and SAME70 * Changes after review from Aniruddha Co-authored-by: Hein Tibosch <hein@htibosch.net> Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> commit 4237049b12d9bb6b03694fecf6ea26a353e637c8 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon Jul 13 12:07:56 2020 -0700 Add changes from 2225-2227 amazon-FreeRTOS (#134) commit 7caa32863458c4470d3c620945c30824199f524c Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Jul 10 23:32:30 2020 -0700 Add Full TCP test suite - not using secure sockets (#131) * Add Full-TCP suite * delete unnecessary files * Change after Joshua's comments commit d7667a0034841f2968f9f9f805030cc608bfbce1 Author: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Fri Jul 3 15:45:44 2020 -0700 Remove unnecessary semicolon from the linker file (#121) This was creating problem with the onboard LPCLink debug probe. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> commit 529c481c39506d0b331bfd0cdea35e5d1aeaaad0 Author: Nathan Chong <52972368+nchong-at-aws@users.noreply.github.com> Date: Thu Jul 2 15:55:20 2020 -0400 Add VeriFast kernel queue proofs (#117) commit d5fedeaa96b5b1d3c0f6b9b52a8064ab72ff2821 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jul 1 13:56:27 2020 -0700 Add checks in FreeRTOS_Socket.c (#104) * Add fail-safes to FreeRTOS_Socket.c * Use all 'pd' errors * Correction after Hein's comments * Correction after Hein's comments v2 * Changes after Hein's comments * Update after Gary's comments commit a9b2aac4e9fda2a259380156df9cc0af51384d2d Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Jun 26 12:09:36 2020 -0700 Folder structure change + Fix broken Projects (#103) * Update folder structure * Correct project files * Move test folder * Some changes after Yuki's comments commit 98bfc38bf3404414878dc68ea41753bea4e24c8e Author: Hein Tibosch <hein_tibosch@yahoo.es> Date: Thu Jun 25 13:01:45 2020 +0800 FreeRTOS+TCP : add memory statistics and dump packets, v3 (#83) * FreeRTOS+TCP : add memory statistics and dump packets, v3 * Two changes as requested by Aniruddha Co-authored-by: Hein Tibosch <hein@htibosch.net> Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> commit 072a173c9df31c75ff64bde440f3f316cedb9033 Author: S.Burch <8697966+wholl0p@users.noreply.github.com> Date: Mon Jun 22 23:39:26 2020 +0200 Fixed Imports for Infineon XMC1100 Board (#88) Co-authored-by: RichardBarry <3073890+RichardBarry@users.noreply.github.com> commit 2df5eeef5763045c4c74ff0e2a4091b7d19bea89 Author: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Mon Jun 8 14:22:46 2020 -0700 Feature/multiple direct to task notifications (#73) * Add TaskNotifyArray.c with the single task tests updated to use the task notification array up to the point where the timer is created. * Continue working on TaskNotifyArray.c to test the new task notification indexes. Next TaskNotifyArray.c will be refactored to break the tests up a bit. * Refactor and update the comments in TaskNotifyArray.c - no functional changes. * Change from the task notify "array" to task notification "indexed" nomenclature in the new task notification API functions that work on one particular task notification with the array of task notifications. * Update the implementation of the taskNOTIFY_TAKE() and taskNOTIFY_WAIT() trace macros to take the array index of the task notification they are acting on. Rename configNUMBER_OF_TASK_NOTIFICATIONS to configTASK_NOTIFICATION_ARRAY_ENTRIES. Add FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c to the Visual Studio project - the file implements tests specific to the behaviour of the indexed task notification functions and should be used in addition to the tests already provided in FreeRTOS/Demo/Common/Minimal/TaskNotify.c. commit b9e4ecfaf7286d8493d4a96a93fbb325534ad97b Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Jun 5 11:10:58 2020 -0700 Remove Empty and Un-referenced folder from Demo (#86) commit f11bcc8acc57a23fb03603762e758c25b9d0efb7 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Jun 3 16:52:31 2020 -0700 Fix a Bug and corresponding CBMC patch (#84) * Update remove-static-in-freertos-tcp-ip.patch * Update FreeRTOS_TCP_IP.c * Update remove-static-in-freertos-tcp-ip.patch * Update remove-static-in-freertos-tcp-ip.patch Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit bb9f92f771e5f6ea2b9b09c7e89130a75e562eb7 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Wed Jun 3 10:46:55 2020 -0700 Submodule FreeRTOS/Source 10bbbcf0b..6199b72fb (#82) commit 6efc39f44be5b269168836e95aebbdb8ae77dce3 Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Tue Jun 2 15:09:25 2020 -0700 Add Project for running integration tests v2 (#80) * Project for integration tests * relative paths in project files * relative paths in project files-1 * relative paths in project files-2 * addressed comments * addressed comments v2 Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 0eb5909fb02bac9dc074ff1bc2fe338d77f73764 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Thu May 28 17:05:24 2020 -0700 readme.md for ATmega328PB Xplained Mini. (#76) readme.md to get users jump started. commit cb7edd2323a77f3dbea144c1f48f95582becc99e Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Thu May 28 10:11:58 2020 -0700 Sync with a:FR (#75) * AFR sync * AFR sync: CBMC * AFR sync: CBMC: remove .bak files * AFR sync: CBMC: more cleanup * Corrected CBMC proofs * Corrected CBMC patches * Corrected CBMC patches-1 * Corrected CBMC patches-2 * remove .bak files (3) Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 6557291e5407ca7ec6beca53fced1aaa620c5c02 Author: alfred gedeon <alfred2g@hotmail.com> Date: Wed May 27 14:44:33 2020 -0700 Test: Add Linux Networking support with demo application (#71) * Test: Add Linux Networking support with demo application * Test: revert files affected by uncrustify * Test: revert files affected by uncrustify Co-authored-by: Alfred Gedeon <gedeonag@amazon.com> Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 8b079bc394e7b205d72210ce9e052404d782938f Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Wed May 27 10:44:03 2020 -0700 ATmega328PB Xplained Mini -- demo project for ATmega port. (#70) * Bootstrap a demo from START. No driver is added in this commit. * Add FreeRTOS source code to project. Remove unnecessary folder nesting. Heap_4 is used here. * Copy over main.c, FreeRTOSConfig.h, and regtest.{c, h}. This commit compiles, but will need some work on timer used. * This port has 2KB RAM. We are using 1KB for heap. Further decreasing minimum stack size, and also use stack overflow check 1 to save some stack space. * Preserve EEPROM set to false. * End of the line. * Reduce register test stack size. 32 8-bit register + 10 bytes for stack frame cost. Round up to 50. * Adding Queue test in Integer test. - g3 to easy debugging. - mainCHECK_PERIOD is set to 1000 ticks. Note that this port for now use WDT as tick timer, and period is set to 15ms. - vErrorChecks, is of highest priority. So if this task gets run before other tasks, the very first check will fail. * Avoid false alarm. Since we don't know in which order the tasks are scheduled, clearing any error for the first entry of vErrorChecks. Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> * ParTest.c to init, set, toggle onboard user LED at PB5. * Added a task to blink onboard user LED. Need a magic number for stack size. Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> * Explicitly setting timing slicing to 0. This is to avoid unecessary context switch when multiple tasks are of the same priority. Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> * Add taskYIELD() at the end of the loop in each register test task. This is to give other tasks of the same priority a chance to run, regardless of scheduling algorithm. Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> * minor, update comment in main.c. commit 95a3a02f95749fb7a600723076e291f9dee7426c Author: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri May 22 16:26:59 2020 -0700 FreeRTOS-Plus: Unit testing Infrastructure and examples (#72) * Added CMock as submodule * Makefile added * Removed TEMP from Makefile * Added configuration files and header files * Update Makefile * Test runner working * make clean * Example added with README * Update README.md * Restored +TCP files * Cleared +TCP changes * removed comments from Makefile * Update README.md * Update README.md * Update README.md * Updated Test/Unit-test/readme.md commit 5003d17feda25490e655c0f1c15d2b13e395c9f7 Author: Hein Tibosch <hein_tibosch@yahoo.es> Date: Wed May 6 14:16:56 2020 -0400 FreeRTOS+TCP : renewing DHCP lease while network is down (#53) Co-authored-by: Hein Tibosch <hein@htibosch.net> Co-authored-by: Gary Wicker <14828980+gkwicker@users.noreply.github.com> commit d95624c5d6ba95ec0474867d7165de2c28ed41b7 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Tue May 5 09:57:18 2020 -0700 Move CBMC proofs to FreeRTOS+ directory (#64) * move CBMC proofs to FreeRTOS+ directory * Failing proofs corrected * ParseDNSReply proof added back * removed queue_init.h from -Plus/Test Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 95ae7c65758a9473ea16ab08182f056f72331de2 Author: markrtuttle <tuttle@acm.org> Date: Wed Apr 29 04:27:45 2020 +0000 Change cbmc-viewer invocation in CBMC makefile (#63) * Exclude FreeRTOS/Demo from CBMC proof reports. The script cbmc-viewer generates the CBMC proof reports. The script searches source files for symbol definitions and annotates source files with coverage information. This patch causes cbmc-viewer to ignore the directory FreeRTOS/Demo containing 348M of data. The script now terminates in a few seconds. * Make report default target for CBMC Makefile. Modify the Makefile for CBMC proofs to generate the report by default (and not just property checking) and modify property checking to ignore failures (due to property assertions failing) and terminating report generation. Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com> commit d421ccc89f6f6473dfdd566a00567b0e1fd4cfc3 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Sat Apr 25 16:57:35 2020 -0700 Reword readme.md under ./Test. (#61) commit 38412865985235b90dbd9da9708b68c4de5918f5 Author: Carl Lundin <53273776+lundinc2@users.noreply.github.com> Date: Sat Apr 25 16:56:54 2020 -0700 Removed a:FR reference. (#60) commit 4db195c916c7b13c82ab3a34a499fe606f266810 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Tue Apr 21 15:40:08 2020 -0700 Adding FreeRTOS+TCP CBMC proofs to FreeRTOS/FreeRTOS (#56) ParseDNSReply is to be added in the next PR. commit 40a31b6d35a866a3a6c551d95bf08dae855da5bd Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon Apr 13 13:58:33 2020 -0700 'uL' -> 'UL' commit 5b3a289b69fc92089aa8bd4d1b44ab816f326f73 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon Apr 13 13:50:53 2020 -0700 Changes after Gary's comments commit edf68637dd22470a8d4f59fecc15b51379bcfeda Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Apr 10 16:26:03 2020 -0700 Update FreeRTOS_ARP.c commit 35f3ac32a8899dd714a8a48952a4224fbcebc4aa Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Apr 10 15:56:18 2020 -0700 correct debug output commit 5e12a70db4b6a8e68a434489683306f040252efa Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Apr 10 15:44:45 2020 -0700 Debugging flag check added commit 4e8ac8de25ac4088b9c789b88a77cd39df4d9167 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Thu Apr 9 16:57:19 2020 -0700 Comment style consistency and Yuhui's suggestions commit e43f7cd086096ad60491fedba69927a1e1a82f20 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Thu Apr 9 16:47:41 2020 -0700 Cleanup commit ab3b51c7a0d880a6bf453ec63ae604e15050f310 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Thu Apr 9 16:33:03 2020 -0700 Update after Gary's comments commit 97f7009699ffb972c0745dfdb526d1fa4e0faf84 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Apr 8 14:30:15 2020 -0700 Update after richard's comments commit a9fcafc074cec559dd67961ef44273df6180c2db Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Apr 8 14:07:39 2020 -0700 Corrected the formatting - visual studio had messed up the formatting commit c381861014a8043ce30723fc5a8cf5107719c8df Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Apr 8 13:01:12 2020 -0700 commit 2 after gary's comments commit 75677a8d85fa802cca9058d6e23796d5043a0982 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Apr 8 12:51:10 2020 -0700 Commit after Gary's comments commit 666c0da366030109db2c0c5e7253cebb2f899db7 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Apr 8 10:56:01 2020 -0700 Update after Yuhui's comments - removed (void) from before memcpy, memset etc. - corrected memcpy style as suggested by Yuhui - Added logging for xNetworkInterfaceOutput. No need to configASSERT commit 4a1148d15b6b8169d2412f8179f734683b179795 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Apr 1 16:05:36 2020 -0700 Coverity + MISRA compliance Modified code to conform to the MISRA directives more closely. commit fa74f7dccf6b1a356993c6a894f8e1173b8c8157 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Thu Apr 2 20:26:10 2020 -0700 Removing writes to read-only PLIC interrupt pending registers. Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> commit 5b9777e11e16609648fb98d2f9a47553ab238950 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Mar 31 10:45:23 2020 -0700 A readme file to introduce what ./Test directory is about. commit 211bb4cbd9ae6dfa95e8d8501f37d272bde5ab26 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Mar 24 15:14:24 2020 -0700 Ignore whitespace when working with patches. commit 8156f64d1c45dd59ef12279f19a99f03e79e1f8a Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Feb 25 18:04:23 2020 -0800 Copying CBMC proofs from aws/amazon-freertos repo ./tools/cbmc to this repo ./FreeRTOS/Test/CBMC as is. The commit ID in aws/amazon-freertos is 0c8e0217f2a43bdeb364b58ae01c6c259e03ef1b. commit 9f316c246baafa15c542a5aea81a94f26e3d6507 Author: David Vrabel <david.vrabel@cambridgeconsultants.com> Date: Mon Mar 16 11:21:46 2020 +0000 Demo/Posix_GCC: add demo application for Posix port using GCC This is largely a copy of the Windows demo application with a few key changes: - heap_3 (use malloc()/free()) so tools like valgrind "just work". - printf() wrapped in a mutex to prevent deadlocks on the internal pthread mutexes inside printf(). SCons (https://scons.org/) is used as the build system. This will be built as a 64-bit application, but note that the memory allocation trace points only record the lower 32-bits of the address. commit f78f919b3e2f0d707531a301a8ca07cd02bc4778 Author: Markus Rinne <markus.ka.rinne@gmail.com> Date: Thu Mar 19 21:00:24 2020 +0200 Fix function comments commit 1cd2d38d960a3576addb224582c88489bade5141 Author: David Chalco <david@chalco.io> Date: Fri Mar 20 10:29:05 2020 -0700 unix separators for path and remove .exe suffix from risc compiler (works on windows/mac) commit 938b19419eded12817737ab0644e94ed2ba7e95d Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Thu Mar 19 18:23:09 2020 -0700 Removing ./FreeRTOS-Labs directory, since: - IoT libraries are now in LTS branch. - FAT/POSIX/Light-weight MQTT are in https://github.com/FreeRTOS/FreeRTOS-Labs. commit 1a4abbc9e91b13fd6394464ade59d5e048320c7c Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Mar 17 19:30:02 2020 -0700 Maintenance -- clean up readme.txt and add url to GitHub. (#38) * Removing readme.txt, as now we have README.md in place. The only information missing from README.md is about FAQ. * Adding FAQ information in README.md. * Adding a .url to root to redict user to FreeRTOS github home page. commit 47bb466aa19395b7785bcb830e2e4dd35f6bafc5 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Mar 17 13:07:44 2020 -0700 Update issue templates Template maintenance. - adding title prefix. - adding examples to "additional context" section. commit f506290041f56867765f8efa70ed2862125bdb7c Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Mar 17 10:15:07 2020 -0700 Create SECURITY.md Apply the recommended SECURITY.md from AWS to our repo. commit 8982a2f80a80a2a0a47cf82de07b52101bd9d606 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Fri Mar 13 12:50:10 2020 -0700 Add ./lib directory to make sure Zynq project compiles. commit ecf0f12aa14ad6fdafe1ef37257cbb4e03e2abd5 Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Wed Mar 11 10:19:48 2020 -0700 Sync up with Amazon-freertos repo (10th March 2020) (#34) * Sync up with amazon-freertos * Sync up with amazon-freertos * Sync up with amazon-freertos commit 0acffef047973e2e61c2201fd69cd9bbd317f674 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Mar 10 10:20:48 2020 -0700 GitHub PR template. (#29) commit c40a6da2e4cb8042b56d1b174051cbbe9813781a Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon Mar 9 11:18:48 2020 -0700 pass payload length when calling UDP callback (#30) * pass payload length when calling UDP callback commit 12d580e93d4d9074b9a867632f0681a511b4ad12 Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Fri Mar 6 18:16:51 2020 -0800 Update issue templates Initial issue template. Created following https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser. If change is needed, we could go another round. commit 9debffb5e0e42ff716f58b2270b3af09652294af Author: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Fri Mar 6 17:27:46 2020 -0800 Update README.md to remove dead link. See the conversation https://github.com/FreeRTOS/FreeRTOS/commit/42c627b2b88cb3b487fea983d8b566a8bbae54fa#comments . Linkage for both ```./FreeRTOS/Source``` and ```./FreeRTOS/Demo``` are removed, since it looks weird to only provide linkage to Demo. commit 7e1a4bf563240501fc45167aee9d929c533939dd Author: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Fri Mar 6 15:18:09 2020 -0800 Fix DHCP option Client-identifier (#28) commit 42c627b2b88cb3b487fea983d8b566a8bbae54fa Author: Yuhui.Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Fri Mar 6 09:15:11 2020 -0800 Update readme and revert relative URL. (#27) * Reordering: bumping cloning instruction up. * Rewording readme.md to be clear kernel code is a submodule of this repository. * Reverting relative URL, since user cannot click through on GitHub page. (With URL, user could still download the correct version of the code. Reverting simply due to UI issue.) commit 5751ae9b60e248ebd0b4dd7c58df54364d2bb9d5 Author: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Fri Mar 6 09:11:42 2020 -0800 Update CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso project (#26) This commit updates the project for LPC55S69 so that it works with the latest version of MCUXpresso and SDK. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> commit a9ffffe1f01f45f79e127c15727784984077932f Author: Carl Lundin <53273776+lundinc2@users.noreply.github.com> Date: Thu Mar 5 17:16:13 2020 -0800 Using Relative URL For Submoduling. (#24) commit 52c82076b38fe73d1dc46c97abf74ae9b803696c Author: Carl Lundin <53273776+lundinc2@users.noreply.github.com> Date: Thu Mar 5 09:16:31 2020 -0800 use relative path to point to bundled toolchain instead (#25) commit b877e4ec478de2c24d07ab46241070d7c66f375c Author: lundinc2 <53273776+lundinc2@users.noreply.github.com> Date: Tue Feb 25 13:18:38 2020 -0800 Moved vulnerability reporting and code of conduct to top of CONTRIBUTING.md (#20) commit bef165d46799fb8faa58aaa224f80c16b6538e69 Author: Yuhui.Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Feb 18 22:06:38 2020 -0800 Linking test source file from relative path. (#19) commit 89e7bbe292afd3912d1f0b2402cc506878bad869 Author: Yuhui.Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Tue Feb 18 17:47:55 2020 -0800 A preliminary .gitignore file, to prevent us checking in files unnecessary. (#18) https://github.com/github/gitignore. commit c2a98127acb48c4562233230e66ca5c282688579 Author: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Sun Feb 16 13:19:53 2020 -0800 Minor wording changes in the 'previous releases' section of the readme.me file. (#17) commit 24c772d1439e5c291c0a29fce0a46996ca8afaa9 Author: Yuhui.Zheng <10982575+yuhui-zheng@users.noreply.github.com> Date: Fri Feb 14 12:47:01 2020 -0800 Submodule kernel directory. (#16) * Removing FreeRTOS/Source in readiness for submoduling. * Submoduling kernel. * README.md update due to submoduling. When releasing, please follow these steps: 1. in local directory, clean directory and check "git status" shows "nothing to commit, working tree clean" for ALL subdirectories. 2. copy source code and instructions only to an empty folder. Git related should not be in this folder -- this covers .git, .gitignore, .github, .gitmodules, gitmessages, ...... 3. zip the folder from step 2. (create both .zip and .7z) 4. attach .zip and .7z to the release. (e.g. attach these two in new release -- https://github.com/FreeRTOS/FreeRTOS/releases/new) 5. PLEASE download both, unzip, diff with your local git repo. (should not see any difference other than git related.) And, sanity check a couple of projects. commit c3f8b91652392dc55e0d7067b90a40de5f5f0837 Author: Rashed Talukder <9218468+rashedtalukder@users.noreply.github.com> Date: Thu Feb 13 17:47:14 2020 -0800 Update readme. Fixed typos and cli commands (#14) commit 4723b825f2989213c1cdb2ebf4d6793e0292e363 Author: Julian Poidevin <julian-poidevin@users.noreply.github.com> Date: Fri Feb 14 02:43:36 2020 +0100 Fixed wrong git clone SSH command (#13) Replaced bad https URL with proper SSH URL commit fc819b821715c42602819e58499846147a6394f5 Author: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Thu Feb 13 17:42:22 2020 -0800 Correct the xTimerCreate() documentation which said NULL was returned if the timer period was passed into the function as 0, whereas that is not the case. (#15) Add a note to the documentation for both the xTimerCreate() and xTimerCreateStatic() functions that the timer period must be greater than 0. commit 1c711ab530b5f0dbd811d7d62e0a3763706ffff4 Author: Rashed Talukder <9218468+rashedtalukder@users.noreply.github.com> Date: Wed Feb 12 23:00:18 2020 -0800 Updated contributions guidelines (#12) commit 84fcc0d5317d96c6b086034093c8c1c83e050819 Author: Cobus van Eeden <35851496+cobusve@users.noreply.github.com> Date: Wed Feb 12 15:05:06 2020 -0800 Updates to Markdown files and readme.txt (#11) git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2826 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases')
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/application_version.h36
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/clientcredential.h54
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/config_common.h299
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_framework.h44
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_runner.h72
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp.h49
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp_config.h73
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_utils.h100
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/unity_config.h280
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test.c92
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_framework.c97
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_freertos.c87
-rw-r--r--FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_tcp.c2560
13 files changed, 3843 insertions, 0 deletions
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/application_version.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/application_version.h
new file mode 100644
index 000000000..bf78174b1
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/application_version.h
@@ -0,0 +1,36 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+#ifndef _AWS_APPLICATION_VERSION_H_
+#define _AWS_APPLICATION_VERSION_H_
+
+#include "iot_appversion32.h"
+extern const AppVersion32_t xAppFirmwareVersion;
+
+#define APP_VERSION_MAJOR 0
+#define APP_VERSION_MINOR 9
+#define APP_VERSION_BUILD 0
+
+#endif
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/clientcredential.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/clientcredential.h
new file mode 100644
index 000000000..58d2ca4fa
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/clientcredential.h
@@ -0,0 +1,54 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+
+#ifndef __CLIENTCREDENTIAL__H__
+#define __CLIENTCREDENTIAL__H__
+
+ /*
+ * @brief Wi-Fi network to join.
+ *
+ * @todo If you are using Wi-Fi, set this to your network name.
+ */
+#define clientcredentialWIFI_SSID ""
+
+ /*
+ * @brief Password needed to join Wi-Fi network.
+ *
+ * @todo If you are using WPA, set this to your network password.
+ */
+#define clientcredentialWIFI_PASSWORD ""
+
+ /*
+ * @brief Wi-Fi network security type.
+ *
+ * @see WIFISecurity_t.
+ *
+ * @note Possible values are eWiFiSecurityOpen, eWiFiSecurityWEP, eWiFiSecurityWPA,
+ * eWiFiSecurityWPA2 (depending on the support of your device Wi-Fi radio).
+ */
+#define clientcredentialWIFI_SECURITY eWiFiSecurityWPA2
+
+#endif
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/config_common.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/config_common.h
new file mode 100644
index 000000000..2b1820f52
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/config_common.h
@@ -0,0 +1,299 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/* This file contains default configuration settings for the tests on FreeRTOS. */
+
+#ifndef IOT_CONFIG_COMMON_H_
+#define IOT_CONFIG_COMMON_H_
+
+/* FreeRTOS include. */
+#include "FreeRTOS.h"
+
+/* Credentials include. */
+#include <aws_clientcredential.h>
+#include <aws_clientcredential_keys.h>
+
+/* Unity framework includes. */
+#include "unity.h"
+
+/* Use platform types on FreeRTOS. */
+#include "platform/iot_platform_types_freertos.h"
+
+/* SDK version. */
+#define IOT_SDK_VERSION "4.0.0"
+
+/* This config file is for the tests. */
+#ifndef IOT_BUILD_TESTS
+ #define IOT_BUILD_TESTS ( 1 )
+#endif
+
+#if IOT_BUILD_TESTS != 1
+ #error "IOT_BUILD_TESTS must be 1 for this test project."
+#endif
+
+/* Unity on FreeRTOS does not provide malloc overrides. */
+#define IOT_TEST_NO_MALLOC_OVERRIDES ( 1 )
+
+/* Supported network types.*/
+#define AWSIOT_NETWORK_TYPE_NONE 0x00000000
+#define AWSIOT_NETWORK_TYPE_WIFI 0x00000001
+#define AWSIOT_NETWORK_TYPE_BLE 0x00000002
+
+/* Logging puts function. */
+#define IotLogging_Puts( str ) configPRINTF( ( "%s\r\n", str ) )
+
+/* Enable asserts in libraries. */
+#define IOT_METRICS_ENABLE_ASSERTS ( 1 )
+#define IOT_CONTAINERS_ENABLE_ASSERTS ( 1 )
+#define IOT_TASKPOOL_ENABLE_ASSERTS ( 1 )
+#define IOT_MQTT_ENABLE_ASSERTS ( 1 )
+#define AWS_IOT_SHADOW_ENABLE_ASSERTS ( 1 )
+#define AWS_IOT_DEFENDER_ENABLE_ASSERTS ( 1 )
+#define IOT_BLE_ENABLE_ASSERTS ( 1 )
+
+/* Assert functions. */
+#define IotMetrics_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+#define IotContainers_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+#define IotTaskPool_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+#define IotMqtt_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+#define AwsIotShadow_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+#define AwsIotDefender_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+#define IotBle_Assert( expression ) if( ( expression ) == 0 ) TEST_FAIL_MESSAGE( "Assertion failure" )
+
+/* Control the usage of dynamic memory allocation. */
+#ifndef IOT_STATIC_MEMORY_ONLY
+ #define IOT_STATIC_MEMORY_ONLY ( 0 )
+#endif
+
+/* Memory allocation configuration. Note that these functions will not be affected
+ * by IOT_STATIC_MEMORY_ONLY. */
+#define IotNetwork_Malloc pvPortMalloc
+#define IotNetwork_Free vPortFree
+#define IotThreads_Malloc pvPortMalloc
+#define IotThreads_Free vPortFree
+#define IotLogging_Malloc pvPortMalloc
+#define IotLogging_Free vPortFree
+#define IotBle_Malloc pvPortMalloc
+#define IotBle_Free vPortFree
+/* #define IotLogging_StaticBufferSize */
+#define IotTest_Malloc pvPortMalloc
+#define IotTest_Free vPortFree
+
+
+/* Memory allocation function configuration for the MQTT library. The MQTT library
+ * will be affected by IOT_STATIC_MEMORY_ONLY. */
+#if IOT_STATIC_MEMORY_ONLY == 0
+ #define IotMetrics_MallocTcpConnection pvPortMalloc
+ #define IotMetrics_FreeTcpConnection vPortFree
+ #define IotMetrics_MallocIpAddress pvPortMalloc
+ #define IotMetrics_FreeIpAddress vPortFree
+
+ #define IotTaskPool_MallocTaskPool pvPortMalloc
+ #define IotTaskPool_FreeTaskPool vPortFree
+ #define IotTaskPool_MallocJob pvPortMalloc
+ #define IotTaskPool_FreeJob vPortFree
+ #define IotTaskPool_MallocTimerEvent pvPortMalloc
+ #define IotTaskPool_FreeTimerEvent vPortFree
+
+ #define IotMqtt_MallocConnection pvPortMalloc
+ #define IotMqtt_FreeConnection vPortFree
+ #define IotMqtt_MallocMessage pvPortMalloc
+ #define IotMqtt_FreeMessage vPortFree
+ #define IotMqtt_MallocOperation pvPortMalloc
+ #define IotMqtt_FreeOperation vPortFree
+ #define IotMqtt_MallocSubscription pvPortMalloc
+ #define IotMqtt_FreeSubscription vPortFree
+
+ #define IotSerializer_MallocCborEncoder pvPortMalloc
+ #define IotSerializer_FreeCborEncoder vPortFree
+ #define IotSerializer_MallocCborParser pvPortMalloc
+ #define IotSerializer_FreeCborParser vPortFree
+ #define IotSerializer_MallocCborValue pvPortMalloc
+ #define IotSerializer_FreeCborValue vPortFree
+ #define IotSerializer_MallocDecoderObject pvPortMalloc
+ #define IotSerializer_FreeDecoderObject vPortFree
+
+ #define AwsIotShadow_MallocOperation pvPortMalloc
+ #define AwsIotShadow_FreeOperation vPortFree
+ #define AwsIotShadow_MallocString pvPortMalloc
+ #define AwsIotShadow_FreeString vPortFree
+ #define AwsIotShadow_MallocSubscription pvPortMalloc
+ #define AwsIotShadow_FreeSubscription vPortFree
+
+ #define AwsIotDefender_MallocReport pvPortMalloc
+ #define AwsIotDefender_FreeReport vPortFree
+ #define AwsIotDefender_MallocTopic pvPortMalloc
+ #define AwsIotDefender_FreeTopic vPortFree
+#endif /* if IOT_STATIC_MEMORY_ONLY == 0 */
+
+/* Require MQTT serializer overrides for the tests. */
+#define IOT_MQTT_ENABLE_SERIALIZER_OVERRIDES ( 1 )
+
+/* Platform and SDK name for AWS MQTT metrics. Only used when AWS_IOT_MQTT_ENABLE_METRICS is 1. */
+#define IOT_SDK_NAME "AmazonFreeRTOS"
+#ifdef configPLATFORM_NAME
+ #define IOT_PLATFORM_NAME configPLATFORM_NAME
+#else
+ #define IOT_PLATFORM_NAME "Unknown"
+#endif
+
+/* BLE_HAL test suites header file abstraction */
+#define IOT_LINEAR_CONTAINERS "iot_linear_containers.h"
+#define IOT_THREADS "platform/iot_threads.h"
+#define IOT_CLOCK "platform/iot_clock.h"
+#define IOT_PLATFORM_TYPES "types/iot_platform_types.h"
+#define IOT_BT_HAL_MANAGER_ADAPTER_BLE "bt_hal_manager_adapter_ble.h"
+#define IOT_BT_HAL_MANAGER_ADAPTER "bt_hal_manager.h"
+#define IOT_BT_HAL_GATT_SERVER "bt_hal_gatt_server.h"
+#define IOT_BT_HAL_GATT_TYPES "bt_hal_gatt_types.h"
+#define IOT_UNITY_FIXTURE "unity_fixture.h"
+#define IOT_UNITY "unity.h"
+#define IOT_LOG "iot_logging_setup.h"
+
+/* Cloud endpoint to which the device connects to. */
+#define IOT_CLOUD_ENDPOINT clientcredentialMQTT_BROKER_ENDPOINT
+
+/* Certificate for the device.*/
+#define IOT_DEVICE_CERTIFICATE keyCLIENT_CERTIFICATE_PEM
+
+/**
+ * @brief Unique identifier used to recognize a device by the cloud.
+ * This could be SHA-256 of the device certificate.
+ */
+extern const char * getDeviceIdentifier( void );
+#define IOT_DEVICE_IDENTIFIER getDeviceIdentifier()
+
+/**
+ * @brief Metrics emitted by the device.
+ */
+extern const char * getDeviceMetrics( void );
+#define AWS_IOT_METRICS_USERNAME getDeviceMetrics()
+
+/**
+ * @brief Length of the metrics emitted by device.
+ */
+extern uint16_t getDeviceMetricsLength( void );
+#define AWS_IOT_METRICS_USERNAME_LENGTH getDeviceMetricsLength()
+
+/* Set Thing Name. */
+#define AWS_IOT_TEST_SHADOW_THING_NAME clientcredentialIOT_THING_NAME
+#define AWS_IOT_TEST_DEFENDER_THING_NAME clientcredentialIOT_THING_NAME
+
+/* Configuration for defender demo: set format to CBOR. */
+#define AWS_IOT_DEFENDER_FORMAT AWS_IOT_DEFENDER_FORMAT_CBOR
+
+/* Configuration for defender demo: use long tag for readable output. Please use short tag for the real application. */
+#define AWS_IOT_DEFENDER_USE_LONG_TAG ( 1 )
+
+/* Define the data type of metrics connection id as same as Socket_t in aws_secure_socket.h */
+#define IotMetricsConnectionId_t void *
+
+/* For compatibility with the FreeRTOS test framework, UnityPrint and similar
+ * must be redefined. */
+extern int snprintf( char *,
+ size_t,
+ const char *,
+ ... );
+#define UnityPrint( X ) configPRINTF( ( X ) )
+#define UnityPrintNumber( X ) { char number[ 12 ] = { 0 }; snprintf( number, 12, "%d", X ); configPRINTF( ( number ) ); }
+#undef UNITY_PRINT_EOL
+#define UNITY_PRINT_EOL() configPRINTF( ( "\r\n" ) )
+
+/* Default platform thread stack size and priority. */
+#ifndef IOT_THREAD_DEFAULT_STACK_SIZE
+ #define IOT_THREAD_DEFAULT_STACK_SIZE 2048
+#endif
+#ifndef IOT_THREAD_DEFAULT_PRIORITY
+ #define IOT_THREAD_DEFAULT_PRIORITY tskIDLE_PRIORITY
+#endif
+
+/* Platform network configuration. */
+#ifndef IOT_NETWORK_RECEIVE_TASK_PRIORITY
+ #define IOT_NETWORK_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
+#endif
+#ifndef IOT_NETWORK_RECEIVE_TASK_STACK_SIZE
+ #define IOT_NETWORK_RECEIVE_TASK_STACK_SIZE IOT_THREAD_DEFAULT_STACK_SIZE
+#endif
+
+/* Use FreeRTOS Secure Sockets network for tests. */
+#ifndef IOT_TEST_NETWORK_HEADER
+ #define IOT_TEST_NETWORK_HEADER "platform/iot_network_freertos.h"
+#endif
+
+/* All tests use a secured connection. */
+#define IOT_TEST_SECURED_CONNECTION ( 1 )
+
+/* Allow the network interface to be chosen by at runtime. */
+struct IotNetworkInterface;
+extern const struct IotNetworkInterface * IotTestNetwork_GetNetworkInterface( void );
+#define IOT_TEST_NETWORK_INTERFACE IotTestNetwork_GetNetworkInterface()
+
+/* Allow the network serializer to be chosen by at runtime. */
+struct IotMqttSerializer;
+extern const struct IotMqttSerializer * IotTestNetwork_GetSerializer( void );
+#define IOT_TEST_MQTT_SERIALIZER IotTestNetwork_GetSerializer()
+
+/* Retry the MQTT Connections in the MQTT System unit tests for all hardware
+ * platforms supported in FreeRTOS.
+ * Set this to the number of connection attempts for the MQTT tests.
+ * If undefined, it should default to 1. */
+#define IOT_TEST_MQTT_CONNECT_RETRY_COUNT ( 3 )
+
+/* AWS IoT Service limits only allow 1 connection per MQTT client ID per second.
+ * Wait until 1100 ms have elapsed since the last connection. */
+#define IOT_TEST_MQTT_CONNECT_INIT_RETRY_DELAY_MS ( 1100 )
+
+/* Forward declarations of network types used in the tests. */
+typedef struct IotNetworkConnection IotTestNetworkConnection_t;
+typedef struct IotNetworkServerInfo IotTestNetworkServerInfo_t;
+typedef struct IotNetworkCredentials IotTestNetworkCredentials_t;
+
+/* Define test network initializers. */
+#define IOT_TEST_NETWORK_CONNECTION_INITIALIZER IOT_NETWORK_CONNECTION_AFR_INITIALIZER
+#define IOT_TEST_NETWORK_SERVER_INFO_INITIALIZER AWS_IOT_NETWORK_SERVER_INFO_AFR_INITIALIZER
+
+/* Define the credentials initializer based on the server port. Use ALPN if on
+ * 443, otherwise disable ALPN. */
+#if clientcredentialMQTT_BROKER_PORT == 443
+ #define IOT_TEST_NETWORK_CREDENTIALS_INITIALIZER AWS_IOT_NETWORK_CREDENTIALS_AFR_INITIALIZER
+#else
+ #define IOT_TEST_NETWORK_CREDENTIALS_INITIALIZER \
+ { \
+ .disableSni = false, \
+ .pAlpnProtos = NULL, \
+ .pRootCa = NULL, \
+ .pClientCert = keyCLIENT_CERTIFICATE_PEM, \
+ .pPrivateKey = keyCLIENT_PRIVATE_KEY_PEM, \
+ .rootCaSize = 0, \
+ .clientCertSize = sizeof( keyCLIENT_CERTIFICATE_PEM ), \
+ .privateKeySize = sizeof( keyCLIENT_PRIVATE_KEY_PEM ) \
+ }
+#endif /* if clientcredentialMQTT_BROKER_PORT == 443 */
+
+/* Network initialization and cleanup functions are not needed on FreeRTOS. */
+#define IotTestNetwork_Init() IOT_NETWORK_SUCCESS
+#define IotTestNetwork_Cleanup()
+
+#endif /* ifndef IOT_CONFIG_COMMON_H_ */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_framework.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_framework.h
new file mode 100644
index 000000000..2adaeab1c
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_framework.h
@@ -0,0 +1,44 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file aws_test_framework.h
+ * @brief Header file for test framework.
+ */
+
+#ifndef _AWS_TEST_FRAMEWORK_H_
+#define _AWS_TEST_FRAMEWORK_H_
+
+void TEST_CacheResult( char cResult );
+
+void TEST_SubmitResultBuffer( void );
+
+void TEST_NotifyTestStart( void );
+
+void TEST_NotifyTestFinished( void );
+
+void TEST_SubmitResult( const char * pcResult );
+
+#endif /* _AWS_TEST_FRAMEWORK_H_ */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_runner.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_runner.h
new file mode 100644
index 000000000..827164945
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_runner.h
@@ -0,0 +1,72 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file aws_test_runner.h
+ * @brief The function to be called to run all the tests.
+ */
+
+#ifndef _AWS_TEST_RUNNER_H_
+#define _AWS_TEST_RUNNER_H_
+
+/*
+ * @brief If set to 1, will run DQP_FR tests only.
+ */
+#define testrunnerTEST_FILTER 0
+
+
+/**
+ * @brief Size of shared array.
+ *
+ */
+#define testrunnerBUFFER_SIZE ( 4000 )
+
+/**
+ * @brief Buffer used for all tests.
+ *
+ * Since tests are run in series, they can use the same memory array.
+ * This makes significant heap savings.
+ */
+extern char cBuffer[ testrunnerBUFFER_SIZE ];
+
+/**
+ * @brief FreeRTOS heap measurement taken before tests are run.
+ */
+extern unsigned int xHeapBefore;
+
+/**
+ * @brief FreeRTOS heap measurement taken after all tests are run.
+ */
+extern unsigned int xHeapAfter;
+
+
+/**
+ * @brief Runs all the tests.
+ */
+void TEST_RUNNER_RunTests_task( void * pvParameters );
+
+
+
+#endif /* _AWS_TEST_RUNNER_H_ */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp.h
new file mode 100644
index 000000000..a2247784c
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp.h
@@ -0,0 +1,49 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+#ifndef TEST_TCP_H
+#define TEST_TCP_H
+
+ /* Non-Encrypted Echo Server.
+ * Update tcptestECHO_SERVER_ADDR# and
+ * tcptestECHO_PORT with IP address
+ * and port of unencrypted TCP echo server. */
+
+ /* You can find the code to setup an echo server in the Repo */
+
+ /* Assume ECHO server IP-address A.B.C.D And Port Z*/
+#define tcptestECHO_SERVER_ADDR0 ( 255 ) /* Replace with Your Echo Server Addr First Byte i.e. A */
+#define tcptestECHO_SERVER_ADDR1 ( 255 ) /* Replace with Your Echo Server Addr Second Byte i.e. B */
+#define tcptestECHO_SERVER_ADDR2 ( 255 ) /* Replace with Your Echo Server Addr Third Byte i.e. C */
+#define tcptestECHO_SERVER_ADDR3 ( 255 ) /* Replace with Your Echo Server Addr Fourth Byte i.e. D */
+#define tcptestECHO_PORT ( 0 ) /* Replace with Your Echo Server Port Number i.e. Z */
+
+#if tcptestECHO_PORT == 0
+#error "Use Correct Port number and Correct IP address by setting tcptestECHO_SERVER_ADDR[0-3] and tcptestECHO_PORT in test_tcp.h"
+#endif
+/* Number of times to retry a connection if it fails. */
+#define tcptestRETRY_CONNECTION_TIMES 6
+
+#endif /* ifndef TEST_TCP_H */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp_config.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp_config.h
new file mode 100644
index 000000000..057f107e3
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_tcp_config.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+#ifndef AWS_INTEGRATION_TEST_TCP_CONFIG_H
+#define AWS_INTEGRATION_TEST_TCP_CONFIG_H
+
+/**
+ * @file aws_integration_test_tcp_portable.h
+ * @brief Port-specific variables for TCP tests. */
+
+
+/**
+ * @brief Indicates how much longer than the specified timeout is acceptable for
+ * RCVTIMEO tests.
+ *
+ * This value can be used to compensate for clock differences, and other
+ * code overhead.
+ */
+#define integrationtestportableTIMEOUT_OVER_TOLERANCE 1
+
+/**
+ * @brief Indicates how much less time than the specified timeout is acceptable for
+ * RCVTIMEO tests.
+ *
+ * This value must be 0 unless networking is performs on a separate processor.
+ * If networking and tests are on different CPUs, an "under tolerance" is acceptable.
+ * For tests where same clock is used for networking and tests.
+ */
+#define integrationtestportableTIMEOUT_UNDER_TOLERANCE 0
+
+/**
+ * @brief Indicates how long receive needs to wait for data before Timeout happens.
+ *
+ */
+#define integrationtestportableRECEIVE_TIMEOUT 2000
+
+/**
+ * @brief Indicates how long send needs to wait before Timeout happens.
+ *
+ */
+#define integrationtestportableSEND_TIMEOUT 2000
+
+
+ /**
+ * @brief Choose a desired hostname to be resolved.
+ * Also, select the number of IP-addresses the test should expect by modifying
+ * dnstestNUM_UNIQUE_IP_ADDRESSES in test_tcp.c source file.
+ */
+#define HostNameUNIQUE_ADDRESSES_TEST "freertos.org"
+
+
+#endif /*AWS_INTEGRATION_TEST_TCP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_utils.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_utils.h
new file mode 100644
index 000000000..ec76b314b
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/test_utils.h
@@ -0,0 +1,100 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+#ifndef _TEST_UTILS_H_
+#define _TEST_UTILS_H_
+
+/**
+ * @brief Retry expression or statement with exponential backoff
+ *
+ * @param xCommand The expression or statement that should be
+ * retried
+ * @param xSuccessStatus The success status where a xCommand need not
+ * be retried any more
+ * @param ulStartingPeriodMs The initial delay period in milliseconds
+ * @param lRetries The number of times to retry. xCommand will
+ * be tried once, and then retried n times.
+ *
+ * @code
+ * int a = 0;
+ * RETRY_EXPONENTIAL( printf( "foo\n" ), 4, 150, 8 );
+ * RETRY_EXPONENTIAL( a = printf( "bar\n" ), 0, 250, 8 );
+ * RETRY_EXPONENTIAL( a = printf( "bar\n" ), 0, 250, 8 );
+ * RETRY_EXPONENTIAL( a = connect_to_server(), CONNECTION_SUCCESS, 250, 8 );
+ * RETRY_EXPONENTIAL( a++, 10, 250, 8 );
+ * @endcode
+ *
+ * @return None
+ */
+#define RETRY_EXPONENTIAL( \
+ xCommand, xSuccessStatus, ulStartingPeriodMs, lRetries ) \
+ { \
+ int32_t lRetried = 0; \
+ uint32_t ulPeriodMs = ulStartingPeriodMs; \
+ int32_t lStatus; \
+ for( ; lRetried <= lRetries; lRetried++ ) { \
+ if( lRetried ) { \
+ configPRINTF( ( "retrying \"%s\", %d of %d, in %d ms\n", \
+ # xCommand, lRetried, \
+ lRetries, ulPeriodMs ) ); \
+ vTaskDelay( pdMS_TO_TICKS( ulPeriodMs ) ); \
+ ulPeriodMs *= 2; \
+ } \
+ lStatus = xCommand; \
+ if( xSuccessStatus == lStatus ) { \
+ break; \
+ } \
+ configPRINTF( ( "expected %d, got %d\n", \
+ xSuccessStatus, lStatus ) ); \
+ } \
+ }
+
+/**
+ * @brief Returns the file name at the end of a windows path
+ *
+ * @param full_path The full path
+ *
+ * @return file name
+ */
+#define WIN_FILENAME( full_path ) \
+ ( strrchr( full_path, '\\' ) ? strrchr( full_path, '\\' ) + 1 : full_path )
+
+/**
+ * @brief Returns the file name at the end of a linux path
+ *
+ * @param full_path The full path
+ *
+ * @return file name
+ */
+#define NIX_FILENAME( full_path ) \
+ ( strrchr( full_path, '/' ) ? strrchr( full_path, '/' ) + 1 : full_path )
+
+/**
+ * The name of the current file, stripped of the path
+ */
+#define __FILENAME__ WIN_FILENAME( NIX_FILENAME( __FILE__ ) )
+
+
+#endif /* end of include guard: _AWS_TEST_UTILS_H_ */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/unity_config.h b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/unity_config.h
new file mode 100644
index 000000000..1c83e54e3
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/include/unity_config.h
@@ -0,0 +1,280 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/* Unity Configuration
+ * As of May 11th, 2016 at ThrowTheSwitch/Unity commit 837c529
+ * Update: December 29th, 2016
+ * See Also: Unity/docs/UnityConfigurationGuide.pdf
+ *
+ * Unity is designed to run on almost anything that is targeted by a C compiler.
+ * It would be awesome if this could be done with zero configuration. While
+ * there are some targets that come close to this dream, it is sadly not
+ * universal. It is likely that you are going to need at least a couple of the
+ * configuration options described in this document.
+ *
+ * All of Unity's configuration options are `#defines`. Most of these are simple
+ * definitions. A couple are macros with arguments. They live inside the
+ * unity_internals.h header file. We don't necessarily recommend opening that
+ * file unless you really need to. That file is proof that a cross-platform
+ * library is challenging to build. From a more positive perspective, it is also
+ * proof that a great deal of complexity can be centralized primarily to one
+ * place in order to provide a more consistent and simple experience elsewhere.
+ *
+ * Using These Options
+ * It doesn't matter if you're using a target-specific compiler and a simulator
+ * or a native compiler. In either case, you've got a couple choices for
+ * configuring these options:
+ *
+ * 1. Because these options are specified via C defines, you can pass most of
+ * these options to your compiler through command line compiler flags. Even
+ * if you're using an embedded target that forces you to use their
+ * overbearing IDE for all configuration, there will be a place somewhere in
+ * your project to configure defines for your compiler.
+ * 2. You can create a custom `unity_config.h` configuration file (present in
+ * your toolchain's search paths). In this file, you will list definitions
+ * and macros specific to your target. All you must do is define
+ * `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any
+ * further definitions it may need.
+ */
+
+#ifndef AWS_UNITY_CONFIG_H
+#define AWS_UNITY_CONFIG_H
+
+/* ************************* AUTOMATIC INTEGER TYPES ***************************
+ * C's concept of an integer varies from target to target. The C Standard has
+ * rules about the `int` matching the register size of the target
+ * microprocessor. It has rules about the `int` and how its size relates to
+ * other integer types. An `int` on one target might be 16 bits while on another
+ * target it might be 64. There are more specific types in compilers compliant
+ * with C99 or later, but that's certainly not every compiler you are likely to
+ * encounter. Therefore, Unity has a number of features for helping to adjust
+ * itself to match your required integer sizes. It starts off by trying to do it
+ * automatically.
+ **************************************************************************** */
+
+/* The first attempt to guess your types is to check `limits.h`. Some compilers
+ * that don't support `stdint.h` could include `limits.h`. If you don't
+ * want Unity to check this file, define this to make it skip the inclusion.
+ * Unity looks at UINT_MAX & ULONG_MAX, which were available since C89.
+ */
+/* #define UNITY_EXCLUDE_LIMITS_H */
+
+/* The second thing that Unity does to guess your types is check `stdint.h`.
+ * This file defines `UINTPTR_MAX`, since C99, that Unity can make use of to
+ * learn about your system. It's possible you don't want it to do this or it's
+ * possible that your system doesn't support `stdint.h`. If that's the case,
+ * you're going to want to define this. That way, Unity will know to skip the
+ * inclusion of this file and you won't be left with a compiler error.
+ */
+/* #define UNITY_EXCLUDE_STDINT_H */
+
+/* ********************** MANUAL INTEGER TYPE DEFINITION ***********************
+ * If you've disabled all of the automatic options above, you're going to have
+ * to do the configuration yourself. There are just a handful of defines that
+ * you are going to specify if you don't like the defaults.
+ **************************************************************************** */
+
+/* Define this to be the number of bits an `int` takes up on your system. The
+ * default, if not auto-detected, is 32 bits.
+ *
+ * Example:
+ */
+/* #define UNITY_INT_WIDTH 16 */
+
+/* Define this to be the number of bits a `long` takes up on your system. The
+ * default, if not autodetected, is 32 bits. This is used to figure out what
+ * kind of 64-bit support your system can handle. Does it need to specify a
+ * `long` or a `long long` to get a 64-bit value. On 16-bit systems, this option
+ * is going to be ignored.
+ *
+ * Example:
+ */
+/* #define UNITY_LONG_WIDTH 16 */
+
+/* Define this to be the number of bits a pointer takes up on your system. The
+ * default, if not autodetected, is 32-bits. If you're getting ugly compiler
+ * warnings about casting from pointers, this is the one to look at.
+ *
+ * Example:
+ */
+/* #define UNITY_POINTER_WIDTH 64 */
+
+/* Unity will automatically include 64-bit support if it auto-detects it, or if
+ * your `int`, `long`, or pointer widths are greater than 32-bits. Define this
+ * to enable 64-bit support if none of the other options already did it for you.
+ * There can be a significant size and speed impact to enabling 64-bit support
+ * on small targets, so don't define it if you don't need it.
+ */
+/* #define UNITY_INCLUDE_64 */
+
+
+/* *************************** FLOATING POINT TYPES ****************************
+ * In the embedded world, it's not uncommon for targets to have no support for
+ * floating point operations at all or to have support that is limited to only
+ * single precision. We are able to guess integer sizes on the fly because
+ * integers are always available in at least one size. Floating point, on the
+ * other hand, is sometimes not available at all. Trying to include `float.h` on
+ * these platforms would result in an error. This leaves manual configuration as
+ * the only option.
+ **************************************************************************** */
+
+/* By default, Unity guesses that you will want single precision floating point
+ * support, but not double precision. It's easy to change either of these using
+ * the include and exclude options here. You may include neither, just float,
+ * or both, as suits your needs.
+ */
+/* #define UNITY_EXCLUDE_FLOAT */
+/* #define UNITY_INCLUDE_DOUBLE */
+/* #define UNITY_EXCLUDE_DOUBLE */
+
+/* For features that are enabled, the following floating point options also
+ * become available.
+ */
+
+/* Unity aims for as small of a footprint as possible and avoids most standard
+ * library calls (some embedded platforms don't have a standard library!).
+ * Because of this, its routines for printing integer values are minimalist and
+ * hand-coded. To keep Unity universal, though, we eventually chose to develop
+ * our own floating point print routines. Still, the display of floating point
+ * values during a failure are optional. By default, Unity will print the
+ * actual results of floating point assertion failures. So a failed assertion
+ * will produce a message like "Expected 4.0 Was 4.25". If you would like less
+ * verbose failure messages for floating point assertions, use this option to
+ * give a failure message `"Values Not Within Delta"` and trim the binary size.
+ */
+/* #define UNITY_EXCLUDE_FLOAT_PRINT */
+
+/* If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C
+ * floats. If your compiler supports a specialty floating point type, you can
+ * always override this behavior by using this definition.
+ *
+ * Example:
+ */
+/* #define UNITY_FLOAT_TYPE float16_t */
+
+/* If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard
+ * C doubles. If you would like to change this, you can specify something else
+ * by using this option. For example, defining `UNITY_DOUBLE_TYPE` to `long
+ * double` could enable gargantuan floating point types on your 64-bit processor
+ * instead of the standard `double`.
+ *
+ * Example:
+ */
+/* #define UNITY_DOUBLE_TYPE long double */
+
+/* If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as
+ * documented in the Unity Assertion Guide, you will learn that they are not
+ * really asserting that two values are equal but rather that two values are
+ * "close enough" to equal. "Close enough" is controlled by these precision
+ * configuration options. If you are working with 32-bit floats and/or 64-bit
+ * doubles (the normal on most processors), you should have no need to change
+ * these options. They are both set to give you approximately 1 significant bit
+ * in either direction. The float precision is 0.00001 while the double is
+ * 10^-12. For further details on how this works, see the appendix of the Unity
+ * Assertion Guide.
+ *
+ * Example:
+ */
+/* #define UNITY_FLOAT_PRECISION 0.001f */
+/* #define UNITY_DOUBLE_PRECISION 0.001f */
+
+
+/* *************************** TOOLSET CUSTOMIZATION ***************************
+ * In addition to the options listed above, there are a number of other options
+ * which will come in handy to customize Unity's behavior for your specific
+ * toolchain. It is possible that you may not need to touch any of these but
+ * certain platforms, particularly those running in simulators, may need to jump
+ * through extra hoops to operate properly. These macros will help in those
+ * situations.
+ **************************************************************************** */
+
+/* By default, Unity prints its results to `stdout` as it runs. This works
+ * perfectly fine in most situations where you are using a native compiler for
+ * testing. It works on some simulators as well so long as they have `stdout`
+ * routed back to the command line. There are times, however, where the
+ * simulator will lack support for dumping results or you will want to route
+ * results elsewhere for other reasons. In these cases, you should define the
+ * `UNITY_OUTPUT_CHAR` macro. This macro accepts a single character at a time
+ * (as an `int`, since this is the parameter type of the standard C `putchar`
+ * function most commonly used). You may replace this with whatever function
+ * call you like.
+ *
+ * Example:
+ * Say you are forced to run your test suite on an embedded processor with no
+ * `stdout` option. You decide to route your test result output to a custom
+ * serial `RS232_putc()` function you wrote like thus:
+ */
+/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */
+/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */
+/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */
+/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */
+/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */
+/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
+
+/* For some targets, Unity can make the otherwise required `setUp()` and
+ * `tearDown()` functions optional. This is a nice convenience for test writers
+ * since `setUp` and `tearDown` don't often actually _do_ anything. If you're
+ * using gcc or clang, this option is automatically defined for you. Other
+ * compilers can also support this behavior, if they support a C feature called
+ * weak functions. A weak function is a function that is compiled into your
+ * executable _unless_ a non-weak version of the same function is defined
+ * elsewhere. If a non-weak version is found, the weak version is ignored as if
+ * it never existed. If your compiler supports this feature, you can let Unity
+ * know by defining `UNITY_SUPPORT_WEAK` as the function attributes that would
+ * need to be applied to identify a function as weak. If your compiler lacks
+ * support for weak functions, you will always need to define `setUp` and
+ * `tearDown` functions (though they can be and often will be just empty). The
+ * most common options for this feature are:
+ */
+/* #define UNITY_SUPPORT_WEAK weak */
+/* #define UNITY_SUPPORT_WEAK __attribute__((weak)) */
+/* #define UNITY_NO_WEAK */
+
+/* Some compilers require a custom attribute to be assigned to pointers, like
+ * `near` or `far`. In these cases, you can give Unity a safe default for these
+ * by defining this option with the attribute you would like.
+ *
+ * Example:
+ */
+/* #define UNITY_PTR_ATTRIBUTE __attribute__((far)) */
+/* #define UNITY_PTR_ATTRIBUTE near */
+
+#include "aws_test_framework.h"
+
+/* Redirect output to print task. */
+#ifndef UNITY_OUTPUT_CHAR
+ #define UNITY_OUTPUT_CHAR( a ) TEST_CacheResult( a )
+#endif
+#ifndef UNITY_OUTPUT_FLUSH
+ #define UNITY_OUTPUT_FLUSH() TEST_SubmitResultBuffer()
+#endif
+#ifndef UNITY_OUTPUT_START
+ #define UNITY_OUTPUT_START() TEST_NotifyTestStart()
+#endif
+#ifndef UNITY_OUTPUT_COMPLETE
+ #define UNITY_OUTPUT_COMPLETE() TEST_NotifyTestFinished()
+#endif
+
+#endif /* AWS_UNITY_CONFIG_H */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test.c
new file mode 100644
index 000000000..6bef263d2
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test.c
@@ -0,0 +1,92 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file iot_demo.c
+ * @brief Demo
+ */
+
+#include "FreeRTOS.h"
+
+
+/*-----------------------------------------------------------*/
+
+/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
+void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
+{
+ /* If the buffers to be provided to the Idle task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle
+ * task's state will be stored. */
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+ /* Pass out the array that will be used as the Idle task's stack. */
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+}
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief This is to provide the memory that is used by the RTOS daemon/time task.
+ *
+ * If configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
+ * implementation of vApplicationGetTimerTaskMemory() to provide the memory that is
+ * used by the RTOS daemon/time task.
+ */
+void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
+{
+ /* If the buffers to be provided to the Timer task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle
+ * task's state will be stored. */
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+ /* Pass out the array that will be used as the Timer task's stack. */
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+}
+/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_framework.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_framework.c
new file mode 100644
index 000000000..12e749fd1
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_framework.c
@@ -0,0 +1,97 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/* Standard includes. */
+#include <stdio.h>
+#include <string.h>
+
+/* FreeRTOS includes. */
+#include "FreeRTOS.h"
+#include "task.h"
+
+/* Test framework include */
+#include "test_framework.h"
+
+/* Unity include */
+#include "unity.h"
+
+#define TEST_RESULT_BUFFER_CAPACITY 1024
+
+/*-----------------------------------------------------------*/
+
+/* The buffer to store test result. The content will be printed if an eol character
+ * is received */
+static char pcTestResultBuffer[ TEST_RESULT_BUFFER_CAPACITY ];
+static int16_t xBufferSize = 0;
+
+/*-----------------------------------------------------------*/
+
+void TEST_CacheResult( char cResult )
+{
+ if( TEST_RESULT_BUFFER_CAPACITY - xBufferSize == 2 )
+ {
+ cResult = '\n';
+ }
+
+ pcTestResultBuffer[ xBufferSize++ ] = cResult;
+
+ if( ( '\n' == cResult ) )
+ {
+ TEST_SubmitResultBuffer();
+ }
+}
+/*-----------------------------------------------------------*/
+
+void TEST_SubmitResultBuffer()
+{
+ if( 0 != xBufferSize )
+ {
+ TEST_SubmitResult( pcTestResultBuffer );
+ memset( pcTestResultBuffer, 0, TEST_RESULT_BUFFER_CAPACITY );
+ xBufferSize = 0;
+ }
+}
+/*-----------------------------------------------------------*/
+
+void TEST_NotifyTestStart()
+{
+ TEST_SubmitResult( "---------STARTING TESTS---------\n" );
+}
+/*-----------------------------------------------------------*/
+
+void TEST_NotifyTestFinished()
+{
+ TEST_SubmitResult( "-------ALL TESTS FINISHED-------\n" );
+}
+/*-----------------------------------------------------------*/
+
+void TEST_SubmitResult( const char * pcResult )
+{
+ /* We want to print test result no matter configPRINTF is defined or not */
+ vLoggingPrintf( pcResult );
+
+ /* Wait for 0.1 seconds to let print task empty its buffer. */
+ vTaskDelay( pdMS_TO_TICKS( 100UL ) );
+}
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_freertos.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_freertos.c
new file mode 100644
index 000000000..27a33b042
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_freertos.c
@@ -0,0 +1,87 @@
+/*
+ * FreeRTOS V202002.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file iot_test_freertos.c
+ * @brief Common hooks file for platforms that have not implemented hooks.
+ */
+
+#include "FreeRTOS.h"
+#include "task.h"
+
+/* It is recommended to implement hooks that use platform specific APIs. This allows
+ * for better error messages and recovery. Should platform specific hooks be implemented,
+ * add this macro to iot_config.h to avoid compiling these symbols.*/
+#ifndef iotconfigUSE_PORT_SPECIFIC_HOOKS
+
+/**
+ * @brief Warn user if pvPortMalloc fails.
+ *
+ * Called if a call to pvPortMalloc() fails because there is insufficient
+ * free memory available in the FreeRTOS heap. pvPortMalloc() is called
+ * internally by FreeRTOS API functions that create tasks, queues, software
+ * timers, and semaphores. The size of the FreeRTOS heap is set by the
+ * configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h.
+ *
+ */
+ void vApplicationMallocFailedHook()
+ {
+ configPRINT_STRING( ( "ERROR: Malloc failed to allocate memory\r\n" ) );
+ taskDISABLE_INTERRUPTS();
+
+ /* Loop forever */
+ for( ; ; )
+ {
+ }
+ }
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief Loop forever if stack overflow is detected.
+ *
+ * If configCHECK_FOR_STACK_OVERFLOW is set to 1,
+ * this hook provides a location for applications to
+ * define a response to a stack overflow.
+ *
+ * Use this hook to help identify that a stack overflow
+ * has occurred.
+ *
+ */
+ void vApplicationStackOverflowHook( TaskHandle_t xTask,
+ char * pcTaskName )
+ {
+ /* Disable unused parameter warnings. */
+ ( void ) xTask;
+ ( void ) pcTaskName;
+
+ configPRINT_STRING( ( "ERROR: stack overflow with task \r\n" ) );
+ portDISABLE_INTERRUPTS();
+
+ /* Loop forever */
+ for( ; ; )
+ {
+ }
+ }
+#endif /* iotconfigUSE_PORT_SPECIFIC_HOOKS */
diff --git a/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_tcp.c b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_tcp.c
new file mode 100644
index 000000000..149364d89
--- /dev/null
+++ b/FreeRTOS-Plus/Test/FreeRTOS-Plus-TCP/Integration/Full-TCP-Suite/Test_Code/Test_Cases/test_tcp.c
@@ -0,0 +1,2560 @@
+/*
+ * FreeRTOS Secure Sockets V1.1.9
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/* Standard includes. */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* FreeRTOS includes. */
+#include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
+#include "event_groups.h"
+
+/* Test framework includes. */
+#include "unity_fixture.h"
+#include "test_runner.h"
+#include "test_utils.h"
+#include "test_tcp.h"
+
+#include "FreeRTOS_Sockets.h"
+#include "FreeRTOS_IP.h"
+
+/* Update this file with port-specific values. */
+#include "test_tcp_config.h"
+
+/* Update this file with AWS Crredentials. */
+#include "clientcredential.h"
+
+/* Verbose printing. */
+#define tcptestPRINTF( x )
+/* In case of test failures, FAILUREPRINTF may provide more detailed information. */
+#define tcptestFAILUREPRINTF( x ) vLoggingPrintf x
+/* Fail the test on tcptestASSERT. */
+#define tcptestASSERT( x ) configASSERT( x )
+/* Take measurements of the FreeRTOS heap before and after every test. */
+#define tcptestMEMORYWATCH 0
+
+/* Connection type. Add additional test servers here. */
+typedef enum
+{
+ eSecure, /* Secure test server. Uses tcptestECHO_SERVER_TLS. */
+ eNonsecure, /* Non secure test server. Uses tcptestECHO_SERVER. */
+ eAwsBroker /* AWS IoT Broker. Uses clientcredential. */
+} Server_t;
+
+/* The echo tasks create a socket, send out a number of echo requests, listen
+ * for the echo reply, then close the socket again before starting over. This
+ * delay is used between each iteration to ensure the network does not get too
+ * congested. */
+#define tcptestLOOP_DELAY_MS ( 150 )
+#define tcptestLOOP_DELAY ( ( TickType_t ) tcptestLOOP_DELAY_MS / portTICK_PERIOD_MS )
+
+/* The number of times FreeRTOS_connect_TCP opens and closes a socket. */
+/* Need to test at least 20 times. So bugs were not discovered with only 10 loops. */
+#define tcptestCONNECT_AND_CLOSE_LOOP ( 20 )
+
+/* Filler values in the RX and TX buffers used to check for undesirable
+ * buffer modification. */
+#define tcptestRX_BUFFER_FILLER 0xFF
+#define tcptestTX_BUFFER_FILLER 0xAA
+
+/* Size of pcTxBuffer and pcRxBuffer. */
+#define tcptestBUFFER_SIZE ( testrunnerBUFFER_SIZE / 2 )
+
+/* Global buffers are shared between tests to reduce RAM usage. */
+char * pcTxBuffer = &cBuffer[ 0 ];
+char * pcRxBuffer = &cBuffer[ tcptestBUFFER_SIZE ];
+
+/* Default Rx and Tx time outs are used to ensure the sockets do not
+ * wait too long for missing data. */
+static const TickType_t xReceiveTimeOut = pdMS_TO_TICKS( integrationtestportableRECEIVE_TIMEOUT );
+static const TickType_t xSendTimeOut = pdMS_TO_TICKS( integrationtestportableSEND_TIMEOUT );
+
+/* Primary socket, declared globally so that it can be closed in test tear down
+ * in the event that a test exits/fails before socket is closed. */
+volatile Socket_t xSocket = FREERTOS_INVALID_SOCKET;
+volatile BaseType_t xSocketOpen = pdFALSE;
+
+/*
+ * Uses a socket to send more than MSS bytes in one go to the standard echo
+ * port number 7. The echoed data is received on the same socket but in a
+ * different task (see prvEchoClientRxTask() below).
+ */
+static void prvEchoClientTxTask( void * pvParameters );
+
+/* TCP Echo Client tasks multi-task test parameters. These can be configured in aws_test_tcp_config.h. */
+#ifndef tcptestTCP_ECHO_TASKS_STACK_SIZE
+ #define tcptestTCP_ECHO_TASKS_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 )
+#endif
+#ifndef tcptestTCP_ECHO_TASKS_PRIORITY
+ #define tcptestTCP_ECHO_TASKS_PRIORITY ( tskIDLE_PRIORITY )
+#endif
+
+/* The queue used by prvEchoClientTxTask() to send the next socket to use to
+ * prvEchoClientRxTask(). */
+static volatile QueueHandle_t xSocketPassingQueue = NULL;
+
+/* The event group used by the prvEchoClientTxTask() and prvEchoClientRxTask()
+ * to synchronize prior to commencing a cycle using a new socket. */
+static volatile EventGroupHandle_t xSyncEventGroup = NULL;
+
+
+/* Bit definitions used with the xSyncEventGroup event group to allow the
+ * prvEchoClientTxTask() and prvEchoClientRxTask() tasks to synchronize before
+ * commencing a new cycle with a different socket. */
+#define tcptestTX_TASK_BIT ( 0x01 << 1 )
+#define tcptestRX_TASK_BIT ( 0x01 << 2 )
+
+
+/* Array setup for 2x an Ethernet II data section */
+#define tcptestTWICE_MAX_FRAME_SIZE ( 2 * 1500 )
+/* Array is defined as const so it can be located in flash. */
+static const char cTransmittedString[ tcptestTWICE_MAX_FRAME_SIZE ] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+ 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
+ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+ 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+ 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
+ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+ 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
+ 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
+ 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
+ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
+ 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+ 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
+ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
+ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+ 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235,
+ 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+ 248, 249, 250, 251, 252, 253, 254, 255, 0, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+ 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+ 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
+ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
+ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
+ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231,
+ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
+ 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+ 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
+ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+ 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+ 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
+ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+ 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
+ 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
+ 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
+ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
+ 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+ 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
+ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
+ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+ 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235,
+ 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+ 248, 249, 250, 251, 252, 253, 254, 255, 0, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+ 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+ 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
+ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
+ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
+ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+ 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
+ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+ 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+ 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
+ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+ 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
+ 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
+ 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
+ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
+ 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+ 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
+ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
+ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+ 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235,
+ 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+ 248, 249, 250, 251, 252, 253, 254, 255, 0, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+ 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+ 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
+ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
+ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
+ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231,
+ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
+ 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+ 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
+ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+ 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+ 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
+ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+ 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
+ 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
+ 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
+ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
+ 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
+ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+ 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
+ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
+ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+ 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235,
+ 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
+ 248, 249, 250, 251, 252, 253, 254, 255, 0, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
+ 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+ 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
+ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
+ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
+ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219
+};
+
+#ifndef tcptestECHO_TEST_SYNC_TIMEOUT
+ #define tcptestECHO_TEST_SYNC_TIMEOUT 80000
+#endif
+
+#ifndef tcptestECHO_TEST_RXTX_TIMEOUT
+ #define tcptestECHO_TEST_RXTX_TIMEOUT 5000
+#endif
+#define tcptestECHO_CLIENT_EVENT_MASK ( ( 1 << tcptestNUM_ECHO_CLIENTS ) - 1 )
+
+#define tcptestECHO_TEST_SYNC_TIMEOUT_TICKS ( pdMS_TO_TICKS( tcptestECHO_TEST_SYNC_TIMEOUT ) )
+static const TickType_t xEchoTestRxTxTimeOut = pdMS_TO_TICKS( tcptestECHO_TEST_RXTX_TIMEOUT );
+
+/* All the modes for the test SOCKETS_Echo_Client_Separate_Tasks */
+typedef enum
+{
+ LARGE_BUFFER_HIGH_PRIORITY,
+ SMALL_BUFFER_HIGH_PRIORITY,
+ LARGE_BUFFER_LOW_PRIORITY,
+ SMALL_BUFFER_LOW_PRIORITY,
+ tcptestMAX_ECHO_TEST_MODES
+} tcptestEchoTestModes_t;
+
+typedef struct
+{
+ uint16_t usTaskTag;
+ BaseType_t xResult;
+ TaskHandle_t xTaskHandle;
+} tcptestEchoClientsTaskParams_t;
+
+/* Number of time the test goes through all the modes. */
+#define tcptestMAX_LOOPS_ECHO_TEST tcptestMAX_ECHO_TEST_MODES
+
+#define tcptestECHO_TEST_LOW_PRIORITY tskIDLE_PRIORITY
+#define tcptestECHO_TEST_HIGH_PRIORITY ( configMAX_PRIORITIES - 1 )
+
+#ifndef ipconfigTCP_MSS
+ #define ipconfigTCP_MSS ( 256 )
+#endif
+#define tcptestNUM_ECHO_CLIENTS ( 2 )
+#define tcptestMAX_LOOPS_ECHO_CLIENTS_LOOP ( 10 )
+
+#define dnstestNUM_UNIQUE_IP_ADDRESSES ( 3 )
+
+static void prvThreadSafeDifferentSocketsDifferentTasks( void * pvParameters );
+/****************** Unity Test Code *********************************/
+size_t xHeapB;
+size_t xHeapA;
+/* Group declaration required by Unity framework. */
+TEST_GROUP( Full_TCP );
+
+/* Setup required by Unity framework. */
+TEST_SETUP( Full_TCP )
+{
+ #if ( tcptestMEMORYWATCH == 1 )
+ /* Give the print buffer time to empty */
+ vTaskDelay( 500 );
+ xHeapB = xPortGetFreeHeapSize();
+ #endif
+}
+
+/* Tear down required by Unity framework.
+ * Closes the global socket if it was left open by the test. */
+TEST_TEAR_DOWN( Full_TCP )
+{
+ int32_t lReturn;
+
+ if( TEST_PROTECT() )
+ {
+ if( xSocketOpen == pdTRUE )
+ {
+ lReturn = FreeRTOS_closesocket( xSocket );
+ xSocketOpen = pdFALSE;
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, lReturn, "SOCKETS_Close failed in tear down. \r\n" );
+ }
+ }
+
+ #if ( tcptestMEMORYWATCH == 1 )
+ /* Give the print buffer time to empty */
+ vTaskDelay( 500 );
+ xHeapA = xPortGetFreeHeapSize();
+
+ configPRINTF( ( "Heap before: %d, Heap After: %d \r\n", xHeapB, xHeapA ) );
+ #endif
+}
+
+
+/*-----------------------------------------------------------*/
+static void prvCreateTxData( char * cBuffer,
+ size_t xMessageLength,
+ uint32_t ulTxCount );
+static BaseType_t prvCheckRxTxBuffers( uint8_t * pucTxBuffer,
+ uint8_t * pucRxBuffer,
+ size_t xMessageLength );
+
+/*-----------------------------------------------------------*/
+
+/* Creates a TCP Socket.
+ * Causes a test failure if socket creation fails. */
+static Socket_t prvTcpSocketHelper( volatile BaseType_t * pxSocketOpen )
+{
+ Socket_t xSocketLocal;
+
+ /* Make socket. */
+ xSocketLocal = FreeRTOS_socket( FREERTOS_AF_INET,
+ FREERTOS_SOCK_STREAM,
+ FREERTOS_IPPROTO_TCP );
+
+ if( xSocketLocal != FREERTOS_INVALID_SOCKET )
+ {
+ /* Test variable for closing exits/fails before closing. */
+ *pxSocketOpen = pdTRUE;
+ }
+
+ return xSocketLocal;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvNonSecureConnectHelper( Socket_t xSocketLocal,
+ struct freertos_sockaddr* pxHostAddress )
+{
+ /* Disable unused parameter warning. */
+ ( void ) xSocketLocal;
+
+ /* Echo requests are sent to the echo server. The echo server is
+ * listening to tcptestECHO_PORT on this computer's IP address. */
+ pxHostAddress->sin_addr = FreeRTOS_inet_addr_quick( tcptestECHO_SERVER_ADDR0,
+ tcptestECHO_SERVER_ADDR1,
+ tcptestECHO_SERVER_ADDR2,
+ tcptestECHO_SERVER_ADDR3 );
+ pxHostAddress->sin_port = FreeRTOS_htons( tcptestECHO_PORT );
+ pxHostAddress->sin_len = sizeof( struct freertos_sockaddr );
+ pxHostAddress->sin_family = FREERTOS_AF_INET;
+
+ return pdFREERTOS_ERRNO_NONE;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvConnect( Socket_t xSocketLocal)
+{
+ BaseType_t xResult = pdFAIL;
+ struct freertos_sockaddr xAddress;
+
+ xResult = prvNonSecureConnectHelper( xSocketLocal, &xAddress );
+
+ if( xResult == pdFREERTOS_ERRNO_NONE )
+ {
+ xResult = FreeRTOS_connect( xSocketLocal,
+ &xAddress,
+ sizeof( xAddress ) );
+ }
+ else
+ {
+ tcptestFAILUREPRINTF( ("%s: Non Secure connect helper failed", __FUNCTION__) );
+ }
+
+ return xResult;
+}
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvConnectHelper( Socket_t xSocketLocal)
+{
+ BaseType_t xResult = pdFAIL;
+ uint32_t ulInitialRetryPeriodMs = tcptestLOOP_DELAY_MS;
+ BaseType_t xMaxRetries = tcptestRETRY_CONNECTION_TIMES;
+
+ RETRY_EXPONENTIAL( xResult = prvConnect( xSocketLocal),
+ pdFREERTOS_ERRNO_NONE,
+ ulInitialRetryPeriodMs,
+ xMaxRetries );
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvSetSockOptHelper( Socket_t xSocketLocal,
+ TickType_t xRxTimeOut,
+ TickType_t xTxTimeOut )
+{
+ BaseType_t xResult;
+
+ /* Set a time out so a missing reply does not cause the task to block
+ * indefinitely. */
+ xResult = FreeRTOS_setsockopt( xSocketLocal,
+ 0,
+ FREERTOS_SO_RCVTIMEO,
+ &xRxTimeOut,
+ sizeof( xRxTimeOut ) );
+
+ if( xResult == pdFREERTOS_ERRNO_NONE )
+ {
+ xResult = FreeRTOS_setsockopt( xSocketLocal,
+ 0,
+ FREERTOS_SO_SNDTIMEO,
+ &xTxTimeOut,
+ sizeof( xTxTimeOut ) );
+
+ if( xResult != pdFREERTOS_ERRNO_NONE )
+ {
+ tcptestFAILUREPRINTF( ( "%s: Socket set sock opt send timeout failed \r\n", __FUNCTION__ ) );
+ }
+ }
+ else
+ {
+ tcptestFAILUREPRINTF( ( "%s: Socket set sock opt receive timeout failed \r\n", __FUNCTION__ ) );
+ }
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvConnectHelperWithRetry( volatile Socket_t * pxSocket,
+ TickType_t xRxTimeOut,
+ TickType_t xTxTimeOut,
+ volatile BaseType_t * pxSocketIsAllocated )
+{
+ BaseType_t xIsConnected = pdFALSE;
+ BaseType_t xResult = pdFREERTOS_ERRNO_NONE;
+ BaseType_t xRetry = 0;
+ struct freertos_sockaddr xEchoServerAddress;
+ TickType_t xRetryTimeoutTicks = tcptestLOOP_DELAY;
+
+ do
+ {
+ /* Create the socket. */
+ *pxSocket = prvTcpSocketHelper( pxSocketIsAllocated );
+
+ if( FREERTOS_INVALID_SOCKET == *pxSocket )
+ {
+ xResult = FREERTOS_SOCKET_ERROR;
+ tcptestFAILUREPRINTF( ( "Failed to allocate Socket Descriptor \r\n" ) );
+ break;
+ }
+
+ /* Set the appropriate socket options for the destination. */
+ if( pdFREERTOS_ERRNO_NONE == xResult )
+ {
+ xResult = prvNonSecureConnectHelper( *pxSocket, &xEchoServerAddress );
+ }
+
+ /* Set socket timeout options. */
+ if( pdFREERTOS_ERRNO_NONE == xResult )
+ {
+ xResult = prvSetSockOptHelper( *pxSocket, xRxTimeOut, xTxTimeOut );
+ }
+
+ /* Attempt, with possible retries, to connect to the destination. */
+ if( pdFREERTOS_ERRNO_NONE == xResult )
+ {
+ xResult = FreeRTOS_connect( *pxSocket,
+ &xEchoServerAddress,
+ sizeof( xEchoServerAddress ) );
+
+ if( pdFREERTOS_ERRNO_NONE == xResult )
+ {
+ xIsConnected = pdTRUE;
+ }
+ else
+ {
+ if( xRetry < tcptestRETRY_CONNECTION_TIMES )
+ {
+ FreeRTOS_closesocket( *pxSocket );
+ *pxSocket = FREERTOS_INVALID_SOCKET;
+ xResult = pdFREERTOS_ERRNO_NONE;
+ xRetry++;
+ vTaskDelay( xRetryTimeoutTicks );
+ /* Exponentially backoff the retry times */
+ xRetryTimeoutTicks *= 2; /*Arbitrarily chose 2*/
+ }
+ else
+ {
+ /* Too many failures. Give up. */
+ break;
+ }
+ }
+ }
+ }
+ while( pdFALSE == xIsConnected );
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvSendHelper( Socket_t xSocketLocal,
+ uint8_t * pucTxBuffer,
+ size_t xLength )
+{
+ BaseType_t xNumBytesSentTotal;
+ BaseType_t xNumBytes;
+ BaseType_t xResult;
+
+ xResult = pdPASS;
+ xNumBytesSentTotal = 0;
+
+ while( ( size_t ) xNumBytesSentTotal < xLength )
+ {
+ xNumBytes = FreeRTOS_send( xSocketLocal, /* The socket being sent to. */
+ &pucTxBuffer[ xNumBytesSentTotal ], /* The data being sent. */
+ xLength - xNumBytesSentTotal, /* The length of the data being sent. */
+ 0 ); /* No flags. */
+
+ if( xNumBytes <= 0 )
+ {
+ xResult = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Error in FreeRTOS_send. Return value: %d \r\n", xNumBytes ) );
+ break;
+ }
+
+ xNumBytesSentTotal += xNumBytes;
+ }
+
+ if( ( size_t ) xNumBytesSentTotal != xLength )
+ {
+ xResult = pdFAIL;
+ }
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvRecvHelper( Socket_t xSocketLocal,
+ uint8_t * pucRxBuffer,
+ size_t xLength )
+{
+ BaseType_t xNumBytesRecvTotal;
+ BaseType_t xNumBytes;
+ BaseType_t xResult;
+
+ xResult = pdPASS;
+ xNumBytesRecvTotal = 0;
+
+ while( ( size_t ) xNumBytesRecvTotal < xLength )
+ {
+ xNumBytes = FreeRTOS_recv( xSocketLocal,
+ &pucRxBuffer[ xNumBytesRecvTotal ],
+ xLength - xNumBytesRecvTotal,
+ 0 );
+
+ if( xNumBytes == 0 )
+ {
+ tcptestFAILUREPRINTF( ( "Timed out receiving from echo server \r\n" ) );
+ xResult = pdFAIL;
+ break;
+ }
+ else if( xNumBytes < 0 )
+ {
+ tcptestFAILUREPRINTF( ( "Error %d while receiving from echo server\r\n", xNumBytes ) );
+ xResult = pdFAIL;
+ break;
+ }
+ else /* xNumBytes > 0 */
+ {
+ xNumBytesRecvTotal += xNumBytes;
+ }
+ }
+
+ if( ( size_t ) xNumBytesRecvTotal != xLength )
+ {
+ xResult = pdFAIL;
+ }
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvShutdownHelper( Socket_t xSocketLocal)
+{
+ BaseType_t xResult;
+
+ /* The caller is done with the connected socket; initiate a graceful close:
+ * send a FIN packet and wait for the server to stop sending. */
+ xResult = FreeRTOS_shutdown( xSocketLocal, FREERTOS_SHUT_RDWR );
+
+ if( 0 == xResult )
+ {
+ /* Keep calling receive until an error code is returned. */
+ do
+ {
+ xResult = FreeRTOS_recv( xSocketLocal, /* The socket being received from. */
+ pcRxBuffer, /* The buffer into which the received data will be written. */
+ tcptestBUFFER_SIZE, /* The size of the buffer provided to receive the data. */
+ 0 );
+ }
+ while( xResult >= 0 );
+
+ xResult = 0;
+ }
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvCloseHelper( Socket_t xSocketLocal,
+ volatile BaseType_t * pxSocketOpen )
+{
+ BaseType_t xResult;
+
+ xResult = FreeRTOS_closesocket( xSocketLocal );
+
+ *pxSocketOpen = pdFALSE;
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvCreateTxData( char * cBufferLocal,
+ size_t xMessageLength,
+ uint32_t ulTxCount )
+{
+ size_t xCharacter;
+ char cChar = '0';
+
+ /* Set the Tx buffer to a known filler value. */
+ memset( cBufferLocal, tcptestTX_BUFFER_FILLER, tcptestBUFFER_SIZE );
+
+ /* Fill the end of the buffer with ascending characters. */
+ if( xMessageLength > 25 )
+ {
+ for( xCharacter = 0; xCharacter < xMessageLength; xCharacter++ )
+ {
+ cBufferLocal[ xCharacter ] = cChar;
+ cChar++;
+
+ if( cChar > '~' )
+ {
+ cChar = '0';
+ }
+ }
+ }
+
+ /* Write as much of the identifying string as possible to the buffer. */
+ snprintf( cBufferLocal, xMessageLength, "%u TxRx with of length %u", ( unsigned ) ulTxCount, ( unsigned ) xMessageLength );
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvCheckRxTxBuffers( uint8_t * pucTxBuffer,
+ uint8_t * pucRxBuffer,
+ size_t xMessageLength )
+{
+ BaseType_t xReturn;
+ size_t xIndex;
+
+ xReturn = pdPASS;
+
+ /* Check that the message received is correct. */
+ for( xIndex = 0; xIndex < xMessageLength; xIndex++ )
+ {
+ if( pucTxBuffer[ xIndex ] != pucRxBuffer[ xIndex ] )
+ {
+ xReturn = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Message bytes received different than those sent. Message Length %d, Byte Index %d \r\n", xMessageLength, xIndex ) );
+ tcptestASSERT( xReturn == pdPASS );
+ }
+ }
+
+ /* Check that neither the Rx nor Tx buffers were modified/overflowed. */
+ for( xIndex = xMessageLength; xIndex < tcptestBUFFER_SIZE; xIndex++ )
+ {
+ if( pucRxBuffer[ xIndex ] != tcptestRX_BUFFER_FILLER )
+ {
+ xReturn = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Rx buffer padding modified byte. Message Length %d, Byte Index %d \r\n", xMessageLength, xIndex ) );
+ }
+
+ if( pucTxBuffer[ xIndex ] != tcptestTX_BUFFER_FILLER )
+ {
+ xReturn = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Tx buffer padding modified. Message Length %d, Byte Index %d \r\n", xMessageLength, xIndex ) );
+ }
+ }
+
+ tcptestASSERT( xReturn == pdPASS );
+
+ return xReturn;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvCheckBufferUnmodified( uint8_t * pucBuffer,
+ uint8_t ucFiller,
+ size_t xLength )
+{
+ BaseType_t xResult;
+ size_t xIndex;
+
+ xResult = pdPASS;
+
+ for( xIndex = 0; xIndex < xLength; xIndex++ )
+ {
+ if( pucBuffer[ xIndex ] != ucFiller )
+ {
+ xResult = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Buffer modified at byte %d \r\n", xIndex ) );
+ }
+ }
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+static BaseType_t prvCheckTimeout( TickType_t xStartTime,
+ TickType_t xEndTime,
+ TickType_t xTimeout )
+{
+ BaseType_t xResult = pdPASS;
+
+ /* Did the function run at least as long as the timeout?
+ * An "under tolerance" may be needed when the application timer
+ * and the network timer are sourced from separate clocks. */
+ if( ( int32_t ) ( xEndTime - xStartTime ) < ( int32_t ) ( xTimeout - integrationtestportableTIMEOUT_UNDER_TOLERANCE ) )
+ {
+ xResult = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Start Time: %d, End Time: %d, Timeout: %d \n", xStartTime, xEndTime, xTimeout ) );
+ }
+
+ /* Did the function exit after a reasonable amount of time?
+ * An "over tolerance" is used to allow for overhead surrounding the timeout. */
+ if( ( xEndTime - xStartTime ) > ( xTimeout + integrationtestportableTIMEOUT_OVER_TOLERANCE ) )
+ {
+ xResult = pdFAIL;
+ tcptestFAILUREPRINTF( ( "Start Time: %d, End Time: %d, Timeout: %d \n", xStartTime, xEndTime, xTimeout ) );
+ }
+
+ return xResult;
+}
+
+/*-----------------------------------------------------------*/
+
+TEST_GROUP_RUNNER( Full_TCP )
+{
+ RUN_TEST_CASE( Full_TCP, TCP_Socket );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_InvalidInputParams );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Setsockopt_InvalidParams );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Close_InvalidParams );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Shutdown_InvalidParams );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Create_Concurrent );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Connect_InvalidParams );
+ RUN_TEST_CASE( Full_TCP, TCP_htons_HappyCase );
+ RUN_TEST_CASE( Full_TCP, TCP_inet_addr_quick_HappyCase );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Send_InvalidParams );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Close_WithoutReceiving );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Shutdown_WithoutReceiving );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Recv_Invalid );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Recv_Unconnected );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Setsockopt_RCVTIMEO );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Recv_NonBlocking );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Shutdown );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Close );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_Recv_ByteByByte );
+ RUN_TEST_CASE( Full_TCP, TCP_Socket_SendRecv_VaryLength );
+ RUN_TEST_CASE( Full_TCP, TCP_test_dns_multiple_addresses );
+
+ /* Thread safety tests */
+ RUN_TEST_CASE( Full_TCP, TCP_Threadsafe_SameSocketDifferentTasks );
+ RUN_TEST_CASE( Full_TCP, TCP_Threadsafe_DifferentSocketsDifferentTasks );
+}
+
+/*-------------------------------------------------------------------*/
+/*-----------------------Begin Tests---------------------------------*/
+/*-------------------------------------------------------------------*/
+
+static void prvSOCKETS_CloseInvalidParams( void )
+{
+ BaseType_t xResult;
+
+ /* Try to close with an invalid socket. */
+ xResult = FreeRTOS_closesocket( FREERTOS_INVALID_SOCKET );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( 0, xResult, "Socket failed to close" );
+}
+
+TEST( Full_TCP, TCP_Socket_Close_InvalidParams )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_CloseInvalidParams();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_CloseWithoutReceiving( void )
+{
+ BaseType_t xResult;
+
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Send a lot of data to the echo server but never use the recv. */
+ xResult = FreeRTOS_send( xSocket, &cTransmittedString, tcptestTWICE_MAX_FRAME_SIZE, 0 );
+ TEST_ASSERT_GREATER_THAN_MESSAGE( 0, xResult, "Socket was not able to send" );
+
+ /* Try to close. */
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+}
+
+
+TEST( Full_TCP, TCP_Socket_Close_WithoutReceiving )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_CloseWithoutReceiving();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_ShutdownInvalidParams( void )
+{
+ BaseType_t xResult;
+
+ /* Ideally, we should test for all valid/invalid permutations
+ * of the parameters, but FreeRTOS_shutdown does not use the
+ * 2nd (xHow) parameter */
+
+ /* Call shutdown with invalid parameters. 2nd Parameter doesn't matter in this case */
+ xResult = FreeRTOS_shutdown( FREERTOS_INVALID_SOCKET, FREERTOS_SHUT_RDWR );
+ TEST_ASSERT_EQUAL_MESSAGE( -pdFREERTOS_ERRNO_EOPNOTSUPP, xResult, "Socket could shutdown with an invalid param" );
+}
+
+TEST( Full_TCP, TCP_Socket_Shutdown_InvalidParams )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_ShutdownInvalidParams();
+}
+
+
+/*-----------------------------------------------------------*/
+static void prvSOCKETS_ShutdownWithoutReceiving( void )
+{
+ BaseType_t xResult;
+
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Send a lot of data to the echo server but never use the recv. */
+ xResult = FreeRTOS_send( xSocket, &cTransmittedString, tcptestTWICE_MAX_FRAME_SIZE, 0 );
+ TEST_ASSERT_GREATER_THAN_MESSAGE( 0, xResult, "Socket was not able to send" );
+
+ xResult = FreeRTOS_shutdown( xSocket, FREERTOS_SHUT_RDWR);
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+}
+
+
+TEST( Full_TCP, TCP_Socket_Shutdown_WithoutReceiving )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_ShutdownWithoutReceiving();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvFreeRTOS_recv_On_Unconnected_Socket( void )
+{
+ BaseType_t xResult;
+ uint8_t ucBuf;
+ volatile BaseType_t xConnectedSocketOpen = pdFALSE;
+ volatile Socket_t xConnectedSocket;
+
+ if( TEST_PROTECT() )
+ {
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+
+ xResult = prvSetSockOptHelper( xSocket, xReceiveTimeOut, xSendTimeOut );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "SetSockOpt Failed" );
+
+
+ /* We connect another socket. The rational for this is a bug that was experienced in the past
+ * where the data would be received by from another socket. */
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xConnectedSocket, xReceiveTimeOut, xSendTimeOut, &xConnectedSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Send data from the connected socket. */
+ xResult = FreeRTOS_send( xConnectedSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_GREATER_THAN_MESSAGE( 0, xResult, "Socket was not able to send" );
+
+ /* Try to receive on unconnected socket. */
+ xResult = FreeRTOS_recv( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_MESSAGE( 0, xResult, "Socket was able to receive from unconnected socket" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* Close the other socket. */
+ xResult = prvShutdownHelper( xConnectedSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xConnectedSocket, &xConnectedSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ xConnectedSocketOpen = pdFALSE;
+ }
+
+ if( xConnectedSocketOpen == pdTRUE )
+ {
+ ( void ) prvShutdownHelper( xConnectedSocket );
+
+ xResult = prvCloseHelper( xConnectedSocket, &xConnectedSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close." );
+ }
+}
+
+TEST( Full_TCP, TCP_Socket_Recv_Unconnected )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvFreeRTOS_recv_On_Unconnected_Socket();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_Socket_TCP( void )
+{
+ BaseType_t xResult;
+
+ /* Make TCP socket. */
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET,
+ FREERTOS_SOCK_STREAM,
+ FREERTOS_IPPROTO_TCP );
+
+ TEST_ASSERT_NOT_EQUAL( xSocket, FREERTOS_INVALID_SOCKET );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+}
+
+TEST( Full_TCP, TCP_Socket )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_Socket_TCP();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_SetSockOpt_RCVTIMEO( void )
+{
+ BaseType_t xResult;
+ UBaseType_t uxOldPriority;
+ TickType_t xStartTime;
+ TickType_t xEndTime;
+ TickType_t xTimeout;
+ TickType_t xTimeouts[] = { 30, 100, 10000 }; /* TODO: Add 0, nonblocking tests */
+ uint8_t ucBuffer;
+ size_t xIndex;
+
+
+ xResult = pdPASS;
+ tcptestPRINTF( ( "Starting %s \r\n", __FUNCTION__ ) );
+ tcptestPRINTF( ( "This tests timeouts, so it takes a while! \r\n" ) );
+
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Record the priority of this task. */
+ uxOldPriority = uxTaskPriorityGet( NULL );
+
+ /*
+ * Set this task to be the highest possible priority.
+ * Since we are testing timeouts, we don't want other tasks
+ * running in the middle of it.
+ */
+ vTaskPrioritySet( NULL, configMAX_PRIORITIES - 1 );
+
+ /*
+ * Set the receive timeout, check the tick count,
+ * call receive (with no data sent), check the tick
+ * count again, make sure time elapsed is within
+ * time expected.
+ */
+ for( xIndex = 0; xIndex < sizeof( xTimeouts ) / sizeof( TickType_t ); xIndex++ )
+ {
+ xTimeout = pdMS_TO_TICKS( xTimeouts[ xIndex ] );
+ xResult = FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &xTimeout, sizeof( TickType_t ) );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to set receive timeout" );
+
+ xStartTime = xTaskGetTickCount();
+ xResult = FreeRTOS_recv( xSocket, &ucBuffer, 1, 0 );
+ xEndTime = xTaskGetTickCount();
+ TEST_ASSERT_LESS_THAN_MESSAGE( 1, xResult, "Receive call failed in receive timeout test" );
+ xResult = prvCheckTimeout( xStartTime, xEndTime, xTimeout );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdPASS, xResult, "Receive timeout was outside of acceptable range" );
+ }
+
+ /* Restore the old priority of this task. */
+ vTaskPrioritySet( NULL, uxOldPriority );
+ xResult = prvShutdownHelper( xSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+
+TEST( Full_TCP, TCP_Socket_Setsockopt_RCVTIMEO )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_SetSockOpt_RCVTIMEO();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_NonBlocking_Test( void )
+{
+ BaseType_t xResult;
+ int32_t lNumBytes;
+ TickType_t xStartTime;
+ TickType_t xEndTime;
+ TickType_t xTimeout = 0;
+ TickType_t xWaitTime = 1000;
+ uint8_t * pucTxBuffer = ( uint8_t * ) pcTxBuffer;
+ uint8_t * pucRxBuffer = ( uint8_t * ) pcRxBuffer;
+ size_t xMessageLength = 1200;
+ size_t xNumBytesReceived = 0;
+
+
+ xResult = pdPASS;
+ tcptestPRINTF( ( "Starting %s \r\n", __FUNCTION__ ) );
+ tcptestPRINTF( ( "This tests timeouts, so it takes a while! \r\n" ) );
+
+ if( TEST_PROTECT() )
+ {
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /*
+ * Set the receive timeout, check the tick count,
+ * call receive (with no data sent), check the tick
+ * count again, make sure time elapsed is within
+ * time expected.
+ */
+ xResult = FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &xTimeout, sizeof( TickType_t ) );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to set receive timeout" );
+
+ xStartTime = xTaskGetTickCount();
+ xResult = FreeRTOS_recv( xSocket, &pucRxBuffer, 1, 0 );
+ xEndTime = xTaskGetTickCount();
+ TEST_ASSERT_LESS_THAN_MESSAGE( 1, xResult, "Receive call failed in receive timeout test" );
+
+ xResult = prvCheckTimeout( xStartTime, xEndTime, xTimeout );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdPASS, xResult, "Receive timeout was outside of acceptable range" );
+
+ /*
+ * Send data and receive data in nonblocking mode
+ */
+ memset( pucTxBuffer, tcptestTX_BUFFER_FILLER, tcptestBUFFER_SIZE );
+ prvCreateTxData( ( char * ) pucTxBuffer, xMessageLength, 0 );
+
+ xResult = prvSendHelper( xSocket, pucTxBuffer, xMessageLength );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdPASS, xResult, "Data failed to send\r\n" );
+
+ memset( pucRxBuffer, tcptestRX_BUFFER_FILLER, tcptestBUFFER_SIZE );
+ xStartTime = xTaskGetTickCount();
+ xEndTime = xTaskGetTickCount();
+
+ do
+ {
+ lNumBytes = FreeRTOS_recv( xSocket, &pucRxBuffer[ xNumBytesReceived ], xMessageLength - xNumBytesReceived, 0 );
+
+ if( lNumBytes > 0 )
+ {
+ /*
+ * If xResult is negative, it's an error code. Because xNumBytesReceived is an
+ * unsigned int, it will become a large positive number, so the while loop
+ * would end prematurely. This if statement prevents that.
+ */
+ xNumBytesReceived += lNumBytes;
+ }
+
+ xEndTime = xTaskGetTickCount();
+ }
+ while( ( ( xEndTime - xStartTime ) < xWaitTime ) && ( xMessageLength > xNumBytesReceived ) );
+
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( xMessageLength, xNumBytesReceived, "Data was not received \r\n" );
+
+ xResult = prvCheckRxTxBuffers( pucTxBuffer, pucRxBuffer, xMessageLength );
+
+ xResult = prvShutdownHelper( xSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+ }
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+
+TEST( Full_TCP, TCP_Socket_Recv_NonBlocking )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_NonBlocking_Test();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSetSockOpt_InvalidParams( void )
+{
+ BaseType_t xResult;
+
+ if( TEST_PROTECT() )
+ {
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Try to set the invalid option. */
+ xResult = FreeRTOS_setsockopt( xSocket,
+ 0, /* lLevel - Not used. */
+ -1, /* Invalid option name. */
+ NULL, /* pvOptionValue - This is insignificant as the option name is invalid. */
+ 0 /* xOptionLength - zero for NULL value. */
+ );
+
+ /* Since the option name supplied in the previous
+ * call was invalid, we expect the call to the API
+ * SOCKETS_SetSockOpt to fail. */
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "SOCKETS_SetSockOpt with invalid option succeeded." );
+
+ /* Try to set a valid option on an invalid socket. */
+ xResult = FreeRTOS_setsockopt( FREERTOS_INVALID_SOCKET, /* Invalid socket. */
+ 0, /* lLevel - Not used. */
+ FREERTOS_SO_RCVTIMEO, /* Receive timeout. */
+ &( xReceiveTimeOut ),
+ sizeof( TickType_t ) );
+
+ /* Since the socket passed in the previous call was
+ * invalid, we expect the call to the API
+ * SOCKETS_SetSockOpt to fail. */
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "SOCKETS_SetSockOpt with invalid socket succeeded." );
+ }
+
+ /* If the code reaches here, it means that the socket
+ * was created successfully. Make sure to free it even
+ * if any of the above assertion fails. This is needed
+ * to avoid leaks. */
+ xResult = prvCloseHelper( xSocket, &( xSocketOpen ) );
+
+ /* If this fails there is nothing much we can do
+ * to avoid leaking. */
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "SOCKETS_Close failed. \r\n" );
+}
+
+TEST( Full_TCP, TCP_Socket_Setsockopt_InvalidParams )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSetSockOpt_InvalidParams();
+
+ tcptestPRINTF( ( "%s complete.\r\n", __FUNCTION__ ) );
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_SetSockOpt_SNDTIMEO( void )
+{
+ /* TODO: This is a stub function. */
+ TEST_FAIL_MESSAGE( "This test is not implemented." );
+}
+
+TEST( Full_TCP, FreeRTOSSetSockOpt_SNDTIMEO )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_SetSockOpt_SNDTIMEO();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_Shutdown( void )
+{
+ BaseType_t xResult;
+ uint8_t ucBuf;
+
+ xResult = pdPASS;
+
+ /* Shutdown: Read. */
+
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ xResult = FreeRTOS_shutdown( xSocket, FREERTOS_SHUT_RD );
+ TEST_ASSERT_EQUAL_INT32( pdFREERTOS_ERRNO_NONE, xResult );
+
+ do
+ {
+ xResult = FreeRTOS_recv( xSocket, &ucBuf, 1, 0 );
+ }
+ while( xResult >= 0 );
+
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* Shutdown: Write. Expected behavior of send after
+ * Shutdown/WRITE is ambiguous. Therefore, we cannot
+ * test anything except the read/recv. */
+}
+
+TEST( Full_TCP, TCP_Socket_Shutdown )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_Shutdown();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvTestSOCKETS_Close( void )
+{
+ BaseType_t xResult;
+ uint8_t ucBuf;
+
+ xResult = pdPASS;
+
+ /* Close an unconnected socket */
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* The secure sockets API abstraction requires that Socket_t be treated as
+ * opaque. It could be a pointer, a handle, an index, or whatever. In addition,
+ * SOCKETS_Close treats the socket only as input. Therefore, it is not a valid
+ * test to pass a socket that has been freed, via explicit close, to other
+ * downstream socket APIs. */
+ xSocket = FREERTOS_INVALID_SOCKET;
+
+ /* Closed socket should not connect, send or receive */
+ xResult = FreeRTOS_send( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+ xResult = FreeRTOS_recv( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+
+ /* Close a connected socket */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* See comment above. */
+ xSocket = FREERTOS_INVALID_SOCKET;
+
+ /* Closed socket should not connect, send or receive */
+ xResult = FreeRTOS_send( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+ xResult = FreeRTOS_recv( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+
+ /* Close a shutdown socket */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ xResult = prvShutdownHelper( xSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* See comment above. */
+ xSocket = FREERTOS_INVALID_SOCKET;
+
+ /* Closed socket should not connect, send or receive */
+ xResult = FreeRTOS_send( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+ xResult = FreeRTOS_recv( xSocket, &ucBuf, 1, 0 );
+ TEST_ASSERT_LESS_THAN_INT32( 0, xResult );
+
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+TEST( Full_TCP, TCP_Socket_Close )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvTestSOCKETS_Close();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvTestFreeRTOS_recv_ByteByByte( void )
+{
+ BaseType_t xResult = pdFAIL;
+ uint32_t ulTxCount;
+ size_t xBytesReceived;
+ uint8_t * pucTxBuffer = ( uint8_t * ) pcTxBuffer;
+ uint8_t * pucRxBuffer = ( uint8_t * ) pcRxBuffer;
+ size_t xMessageLengths[] = { 2, 7, 8, 9, 20 };
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ for( ulTxCount = 0; ulTxCount < sizeof( xMessageLengths ) / sizeof( xMessageLengths[ 0 ] ); ulTxCount++ )
+ {
+ xBytesReceived = 0;
+
+ prvCreateTxData( ( char * ) pucTxBuffer, xMessageLengths[ ulTxCount ], ulTxCount );
+ xResult = prvSendHelper( xSocket, pucTxBuffer, xMessageLengths[ ulTxCount ] );
+
+ while( ( xResult == pdPASS ) && ( xBytesReceived < xMessageLengths[ ulTxCount ] ) )
+ {
+ memset( pucRxBuffer, tcptestRX_BUFFER_FILLER, tcptestBUFFER_SIZE );
+ xResult = prvRecvHelper( xSocket, pucRxBuffer, 1 );
+
+ if( xResult == pdPASS )
+ {
+ if( pucRxBuffer[ 0 ] == pucTxBuffer[ xBytesReceived ] )
+ {
+ /* Check that all but the first byte of the RxBuffer is unmodified. */
+ xResult = prvCheckBufferUnmodified( pucRxBuffer + 1,
+ tcptestRX_BUFFER_FILLER,
+ tcptestBUFFER_SIZE - 1 );
+ }
+ else
+ {
+ xResult = pdFAIL;
+ tcptestPRINTF( ( "Byte %d was incorrectly received\r\n", ( xBytesReceived + 1 ) ) );
+ }
+ }
+
+ xBytesReceived++;
+ }
+ }
+
+ /* Close this socket before looping back to create another. */
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdPASS, xResult, "Failed received" );
+ xResult = prvShutdownHelper( xSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+}
+
+TEST( Full_TCP, TCP_Socket_Recv_ByteByByte )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvTestFreeRTOS_recv_ByteByByte();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvFreeRTOS_sendRecv_VaryLength( void )
+{
+ BaseType_t xResult;
+ uint32_t ulIndex;
+ uint32_t ulTxCount;
+ const uint32_t ulMaxLoopCount = 10;
+ uint32_t ulI;
+ uint8_t * pucTxBuffer = ( uint8_t * ) pcTxBuffer;
+ uint8_t * pucRxBuffer = ( uint8_t * ) pcRxBuffer;
+ size_t xMessageLengths[] = { 1, 2, 7, 8, 9, 1199, 1200, 1201 }; /* TODO: Add 0, send sizes larger than MTU. */
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ xResult = pdPASS;
+ ulTxCount = 0;
+
+ for( ulIndex = 0; ulIndex < sizeof( xMessageLengths ) / sizeof( size_t ); ulIndex++ )
+ {
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Send each message length ulMaxLoopCount times. */
+ for( ulI = 0; ulI < ulMaxLoopCount; ulI++ )
+ {
+ memset( pucTxBuffer, tcptestTX_BUFFER_FILLER, tcptestBUFFER_SIZE );
+
+ prvCreateTxData( ( char * ) pucTxBuffer,
+ xMessageLengths[ ulIndex ],
+ ulTxCount );
+ ulTxCount++;
+
+ xResult = prvSendHelper( xSocket,
+ pucTxBuffer,
+ xMessageLengths[ ulIndex ] );
+
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdPASS, xResult, "Data failed to send\r\n" );
+ memset( pucRxBuffer, tcptestRX_BUFFER_FILLER, tcptestBUFFER_SIZE );
+ xResult = prvRecvHelper( xSocket,
+ pucRxBuffer,
+ xMessageLengths[ ulIndex ] );
+
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdPASS, xResult, "Data was not received \r\n" );
+ xResult = prvCheckRxTxBuffers( pucTxBuffer,
+ pucRxBuffer,
+ xMessageLengths[ ulIndex ] );
+ }
+
+ xResult = prvShutdownHelper( xSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* Print feedback since this test takes a while! */
+ tcptestPRINTF( ( " Sending messages with length %d complete\r\n", xMessageLengths[ ulIndex ] ) );
+
+ /* Pause for a short while to ensure the network is not too
+ * congested. */
+ vTaskDelay( tcptestLOOP_DELAY );
+ }
+
+ /* Report Test Results. */
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+TEST( Full_TCP, TCP_Socket_SendRecv_VaryLength )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvFreeRTOS_sendRecv_VaryLength();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSOCKETS_Socket_InvalidInputParams( void )
+{
+ BaseType_t xResult;
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ /* Providing invalid domain. */
+ if( TEST_PROTECT() )
+ {
+ xSocket = FreeRTOS_socket( ( FREERTOS_AF_INET + 1 ),
+ FREERTOS_SOCK_STREAM,
+ FREERTOS_IPPROTO_TCP );
+
+ /* If the test code reaches here, it failed. */
+ TEST_FAIL_MESSAGE( "Invalid socket domain accepted" );
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ }
+
+ /* Providing invalid type. */
+ if( TEST_PROTECT() )
+ {
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET,
+ ( FREERTOS_SOCK_STREAM | FREERTOS_SOCK_DGRAM ),
+ FREERTOS_IPPROTO_TCP );
+
+ TEST_FAIL_MESSAGE( "Invalid socket type accepted" );
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ }
+
+ /* Providing invalid protocol. */
+ if( TEST_PROTECT() )
+ {
+ xSocket = FreeRTOS_socket(FREERTOS_AF_INET,
+ FREERTOS_SOCK_STREAM,
+ ( FREERTOS_IPPROTO_TCP | FREERTOS_IPPROTO_UDP ) );
+
+ TEST_FAIL_MESSAGE( "Invalid socket protocol accepted" );
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ }
+
+ if( TEST_PROTECT() )
+ {
+ /* Mixing DGRAM type with TCP protocol (instead of UDP). */
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET,
+ FREERTOS_SOCK_DGRAM,
+ FREERTOS_IPPROTO_TCP );
+
+ TEST_FAIL_MESSAGE( "Invalid socket created - mixed TCP with DGRAM " );
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ }
+
+ /* Mixing STREAM type with UDP protocol (instead of TCP). */
+ if( TEST_PROTECT() )
+ {
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET,
+ FREERTOS_SOCK_STREAM,
+ FREERTOS_IPPROTO_UDP );
+
+ TEST_FAIL_MESSAGE( "Invalid socket created - mixed UDP with STREAM" );
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ }
+
+ /* Report Test Results. */
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+TEST( Full_TCP, TCP_Socket_InvalidInputParams )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_Socket_InvalidInputParams();
+}
+
+/*-----------------------------------------------------------*/
+
+/*
+ * Verify the number of sockets that can be concurrently
+ * created up to a configured maximum. Return pdFAIL if
+ * fewer than that number are created. If more than the
+ * maximum can be created, a warning is printed, but this
+ * is not a failure condition. Some ports are limited only
+ * by free memory. For these ports, check that a reasonable
+ * number of sockets can be created concurrently.
+ */
+#ifdef integrationtestportableMAX_NUM_UNSECURE_SOCKETS
+ #define MAX_NUM_SOCKETS integrationtestportableMAX_NUM_UNSECURE_SOCKETS
+#else
+ #define MAX_NUM_SOCKETS 5u
+#endif
+static void prvSOCKETS_Socket_ConcurrentCount( void )
+{
+ BaseType_t xResult = pdFAIL;
+ Socket_t xCreatedSockets[ MAX_NUM_SOCKETS ];
+ BaseType_t xSocketsCreated;
+ Socket_t xSocketLocal;
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ xResult = pdPASS;
+
+ for( xSocketsCreated = 0; xSocketsCreated < MAX_NUM_SOCKETS; xSocketsCreated++ )
+ {
+ xSocketLocal = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
+
+ if( xSocketLocal == FREERTOS_INVALID_SOCKET )
+ {
+ xResult = pdFAIL;
+ tcptestPRINTF( ( "%s failed creating a socket number %d \r\n", __FUNCTION__, xSocketsCreated ) );
+ break;
+ }
+ else
+ {
+ xCreatedSockets[ xSocketsCreated ] = xSocketLocal;
+ }
+ }
+
+ #ifdef integrationtestportableMAX_NUM_UNSECURE_SOCKETS
+ if( xResult == pdPASS )
+ {
+ xSocketLocal = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP);
+
+ if( xSocketLocal != FREERTOS_INVALID_SOCKET )
+ {
+ SOCKETS_Close( xSocket );
+ tcptestPRINTF( ( "%s exceeded maximum number of sockets (%d > %d); is the value of " \
+ "integrationtestportableMAX_NUM_UNSECURE_SOCKETS correct?\r\n", __FUNCTION__,
+ ( MAX_NUM_SOCKETS + 1 ), MAX_NUM_SOCKETS ) );
+ }
+ }
+ #endif /* ifdef integrationtestportableMAX_NUM_UNSECURE_SOCKETS */
+
+ TEST_ASSERT_EQUAL_UINT32_MESSAGE(pdPASS, xResult, "Concurrent num sockets test failed");
+
+ /* Cleanup. */
+ while( xSocketsCreated > 0 )
+ {
+ --xSocketsCreated;
+ xResult = FreeRTOS_closesocket( xCreatedSockets[ xSocketsCreated ] );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(0, xResult, "Closing Socket in Multiple Concurrent Socket test failed\n");
+ }
+
+ /* Report Test Results. */
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+TEST( Full_TCP, TCP_Socket_Create_Concurrent )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_Socket_ConcurrentCount();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvFreeRTOS_connect_InvalidParams( void )
+{
+ BaseType_t xResult;
+ struct freertos_sockaddr xEchoServerAddress;
+
+ uint32_t ulEchoServerIP;
+
+ ulEchoServerIP = FreeRTOS_inet_addr_quick( tcptestECHO_SERVER_ADDR0,
+ tcptestECHO_SERVER_ADDR1,
+ tcptestECHO_SERVER_ADDR2,
+ tcptestECHO_SERVER_ADDR3 );
+
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+
+ /* Echo requests are sent to the echo server. The echo server is
+ * listening to tcptestECHO_PORT on this computer's IP address. */
+ xEchoServerAddress.sin_port = FreeRTOS_htons( tcptestECHO_PORT );
+ xEchoServerAddress.sin_addr = ulEchoServerIP;
+
+ /* Invalid socket. */
+ xResult = FreeRTOS_connect( FREERTOS_INVALID_SOCKET,
+ &xEchoServerAddress,
+ sizeof( xEchoServerAddress ) );
+
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Connect on an invalid socket succeeded\n" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+
+
+ /* Invalid IP address (0.0.0.0). TODO: Investigate reserved IP addresses */
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+
+ xEchoServerAddress.sin_addr = FreeRTOS_inet_addr_quick( 0, 0, 0, 0 );
+ xResult = FreeRTOS_connect( xSocket,
+ &xEchoServerAddress,
+ sizeof( xEchoServerAddress ) );
+
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Connect to IP Address 0.0.0.0 worked" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+
+
+ /* Invalid port (0). */
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+
+ xEchoServerAddress.sin_port = FreeRTOS_htons( 0 );
+ xEchoServerAddress.sin_addr = ulEchoServerIP;
+ xResult = FreeRTOS_connect( xSocket,
+ &xEchoServerAddress,
+ sizeof( xEchoServerAddress ) );
+
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Connect to Port 0 worked" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+
+
+ /* NULL Address. */
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+ xResult = FreeRTOS_connect( xSocket, NULL, 0 );
+
+ /* Ensure that the attempt to connect to NULL address fails. */
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Connect to NULL Address worked." );
+
+ /* TODO: Does port 0 mean connect to any available port? */
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+}
+
+TEST( Full_TCP, TCP_Socket_Connect_InvalidParams )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvFreeRTOS_connect_InvalidParams();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvSend_Invalid( void )
+{
+ BaseType_t xResult;
+ uint8_t * pucTxBuffer = ( uint8_t * ) pcTxBuffer;
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ /* Unconnected socket. */
+ if( TEST_PROTECT() )
+ {
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Invalid socket. */
+ xResult = FreeRTOS_send( FREERTOS_INVALID_SOCKET, pucTxBuffer, 300, 0 );
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Socket send fails with invalid socket" );
+
+ /* NULL Tx Buffer. */
+ xResult = FreeRTOS_send( xSocket, NULL, 300, 0 );
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Socket send should return error for NULL input buffer" );
+ }
+ else
+ {
+ TEST_FAIL_MESSAGE( "Sending on an TCP socket with NULL buffer triggered an assert " );
+ }
+
+ /* Cleanup. */
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+
+ /* Unconnected socket. */
+ if( TEST_PROTECT() )
+ {
+ xSocket = prvTcpSocketHelper( &xSocketOpen );
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( FREERTOS_INVALID_SOCKET, xSocket, "Socket creation failed" );
+
+ xResult = prvSetSockOptHelper( xSocket, xReceiveTimeOut, xSendTimeOut );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Set sockopt failed" );
+
+ xResult = FreeRTOS_send( xSocket, pucTxBuffer, 300, 0 );
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Socket send worked with an unconnected socket" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket close failed" );
+ }
+ else
+ {
+ TEST_FAIL_MESSAGE( "Sending on an unconnected TCP socket triggered an assert " );
+ }
+
+ /* Report Test Results. */
+ tcptestPRINTF( ( "%s passed\r\n", __FUNCTION__ ) );
+}
+
+TEST( Full_TCP, TCP_Socket_Send_InvalidParams )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSend_Invalid();
+}
+
+/*-------------------------------------------------------------------*/
+
+static void prvRecv_Invalid( void )
+{
+ BaseType_t xResult;
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xReceiveTimeOut, xSendTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Receive with NULL buffer should fail in FREERTOS_ZERO_COPY mode. */
+ xResult = FreeRTOS_recv( xSocket, NULL, 100, FREERTOS_ZERO_COPY );
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Socket receive with NULL receive buffer should have triggered error" );
+
+ /* Receive on invalid socket should fail. */
+ xResult = FreeRTOS_recv( FREERTOS_INVALID_SOCKET, pcRxBuffer, tcptestBUFFER_SIZE, 0 );
+ TEST_ASSERT_LESS_THAN_INT32_MESSAGE( 0, xResult, "Socket receive with invalid socket should have triggered error" );
+
+ /* Cleanup. */
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+}
+
+TEST( Full_TCP, TCP_Socket_Recv_Invalid )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvRecv_Invalid();
+}
+
+/*-------------------------------------------------------------------*/
+
+/** @brief This test will create a task the will send data to an echo server.
+ * The data coming back will be received in that task.
+ * The size of receiving buffer, the priority, the size of data send,
+ * will keep changing to cover a maximum cases.
+ */
+static void prvSOCKETS_Threadsafe_SameSocketDifferentTasks( void )
+{
+ BaseType_t xTotalReceived, xReturned = 0;
+ size_t xRecvLoop, xRecvLen;
+ tcptestEchoTestModes_t xMode;
+ BaseType_t xResult;
+ volatile char * pcReceivedString;
+ volatile BaseType_t xReceivedStringAllocated = pdFALSE;
+ volatile BaseType_t xSocketPassingQueueAllocated = pdFALSE;
+ volatile BaseType_t xSyncEventGroupAllocated = pdFALSE;
+ volatile TaskHandle_t xCreatedTask;
+
+ if( TEST_PROTECT() )
+ {
+ pcReceivedString = pvPortMalloc( ipconfigTCP_MSS * sizeof( char ) );
+ configASSERT( pcReceivedString != NULL );
+ xReceivedStringAllocated = pdTRUE;
+
+ /* Create the queue used to pass the socket to use from the Tx task to the
+ * Rx task. */
+ xSocketPassingQueue = xQueueCreate( 1, sizeof( Socket_t ) );
+ configASSERT( xSocketPassingQueue );
+ xSocketPassingQueueAllocated = pdTRUE;
+
+ /* Create the event group used by the Tx and Rx tasks to synchronize prior
+ * to commencing a cycle using a new socket. */
+ xSyncEventGroup = xEventGroupCreate();
+ configASSERT( xSyncEventGroup );
+ xSyncEventGroupAllocated = pdTRUE;
+
+ /* Create the task that sends to an echo server, but lets a different task
+ * receive the reply on the same socket. */
+ xResult = xTaskCreate( prvEchoClientTxTask, /* The function that implements the task. */
+ "EchoMultiTx", /* Just a text name for the task to aid debugging. */
+ tcptestTCP_ECHO_TASKS_STACK_SIZE, /* The stack size is defined in aws_demo_config.h. */
+ NULL, /* The task parameter, not used in this case. */
+ tcptestTCP_ECHO_TASKS_PRIORITY, /* The priority assigned to the task is defined in aws_demo_config.h. */
+ ( TaskHandle_t * ) &xCreatedTask );
+ TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xResult, "Task creation failed" );
+
+ for( xRecvLoop = 0; xRecvLoop < tcptestMAX_LOOPS_ECHO_TEST; xRecvLoop++ )
+ {
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xSocket, xEchoTestRxTxTimeOut, xEchoTestRxTxTimeOut, &xSocketOpen );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Failed to connect" );
+
+ /* Wait to receive the socket that will be used from the Tx task. */
+ if( xEventGroupSync( xSyncEventGroup, /* The event group used for the rendezvous. */
+ tcptestRX_TASK_BIT, /* The bit representing the Tx task reaching the rendezvous. */
+ ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ), /* Also wait for the Rx task. */
+ tcptestECHO_TEST_SYNC_TIMEOUT_TICKS ) != ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ) )
+ {
+ TEST_FAIL();
+ }
+
+ /* Nothing received yet. */
+ xTotalReceived = 0;
+
+ xMode = ( tcptestEchoTestModes_t ) ( xRecvLoop % tcptestMAX_ECHO_TEST_MODES ); /* % should be optimized to simple masking since only 4 modes are present.*/
+ /* Using % to avoid bug in case a new state is unknowingly added. */
+
+ xRecvLen = ipconfigTCP_MSS;
+ vTaskPrioritySet( NULL, tcptestECHO_TEST_HIGH_PRIORITY );
+
+ /* Set low priority if requested . */
+ if( ( xMode == LARGE_BUFFER_LOW_PRIORITY ) || ( xMode == SMALL_BUFFER_LOW_PRIORITY ) )
+ {
+ vTaskPrioritySet( NULL, tcptestECHO_TEST_LOW_PRIORITY );
+ }
+
+ if( ( xMode == SMALL_BUFFER_HIGH_PRIORITY ) || ( xMode == SMALL_BUFFER_LOW_PRIORITY ) )
+ {
+ xRecvLen = 1;
+ }
+
+ while( xTotalReceived < tcptestTWICE_MAX_FRAME_SIZE )
+ {
+ xReturned = FreeRTOS_recv( ( Socket_t ) xSocket, ( char * ) pcReceivedString, xRecvLen, 0 );
+
+ TEST_ASSERT_NOT_EQUAL_MESSAGE( 0, xReturned, "Timeout occurred" );
+ TEST_ASSERT_GREATER_THAN_MESSAGE( 0, xReturned, "Error occurred receiving large message" );
+
+ /* Data was received. */
+ TEST_ASSERT_EQUAL_MEMORY( &cTransmittedString[ xTotalReceived ], pcReceivedString, xReturned );
+
+ xTotalReceived += xReturned;
+ }
+
+ /* Rendezvous with the Tx task ready to start a new cycle with a
+ * different socket. */
+ if( xEventGroupSync( xSyncEventGroup, /* The event group used for the rendezvous. */
+ tcptestRX_TASK_BIT, /* The bit representing the Rx task reaching the rendezvous. */
+ ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ), /* Also wait for the Tx task. */
+ tcptestECHO_TEST_SYNC_TIMEOUT_TICKS ) != ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ) )
+ {
+ TEST_FAIL();
+ }
+
+ xResult = prvShutdownHelper( xSocket );
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to shutdown" );
+
+ xResult = prvCloseHelper( xSocket, &xSocketOpen );
+ TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE( pdFREERTOS_ERRNO_NONE, xResult, "Socket failed to close" );
+ }
+ }
+
+ /* Free all dynamic memory. */
+ if( xReceivedStringAllocated == pdTRUE )
+ {
+ vPortFree( ( char * ) pcReceivedString );
+ }
+
+ if( xSocketPassingQueueAllocated == pdTRUE )
+ {
+ vQueueDelete( xSocketPassingQueue );
+ }
+
+ if( xSyncEventGroupAllocated == pdTRUE )
+ {
+ vEventGroupDelete( xSyncEventGroup );
+ }
+
+ vTaskDelete( xCreatedTask );
+
+ /* Set priority back. */
+ vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
+}
+
+TEST( Full_TCP, TCP_Threadsafe_SameSocketDifferentTasks )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvSOCKETS_Threadsafe_SameSocketDifferentTasks();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvEchoClientTxTask( void * pvParameters )
+{
+ BaseType_t xReturned = 0;
+ BaseType_t xTransmitted;
+ BaseType_t xStatus;
+ size_t xLenToSend, xSendLoop;
+ size_t xMaxBufferSize;
+ tcptestEchoTestModes_t xMode;
+
+
+ /* Avoid warning about unused parameter. */
+ ( void ) pvParameters;
+
+ /* Offset by one so of sending and receiving task are not always the same. Sometimes both low/high or opposite. */
+
+ /* Recv task Sending task
+ * LARGE_BUFFER_HIGH_PRIORITY SMALL_BUFFER_HIGH_PRIORITY
+ * SMALL_BUFFER_HIGH_PRIORITY LARGE_BUFFER_LOW_PRIORITY
+ * LARGE_BUFFER_LOW_PRIORITY SMALL_BUFFER_LOW_PRIORITY
+ * SMALL_BUFFER_LOW_PRIORITY LARGE_BUFFER_HIGH_PRIORITY
+ */
+ for( xSendLoop = 1; xSendLoop < tcptestMAX_LOOPS_ECHO_TEST + 1; xSendLoop++ )
+ {
+ xMode = ( tcptestEchoTestModes_t ) ( xSendLoop % tcptestMAX_ECHO_TEST_MODES ); /* % should be optimized to simple masking since only 4 modes are present.*/
+ /* Using % to avoid bug in case a new state is unknowingly added. */
+
+ vTaskPrioritySet( NULL, tcptestECHO_TEST_HIGH_PRIORITY );
+ xMaxBufferSize = tcptestTWICE_MAX_FRAME_SIZE;
+
+ /* Set low priority if requested . */
+ if( ( xMode == LARGE_BUFFER_LOW_PRIORITY ) || ( xMode == SMALL_BUFFER_LOW_PRIORITY ) )
+ {
+ vTaskPrioritySet( NULL, tcptestECHO_TEST_LOW_PRIORITY );
+ }
+
+ /* Set buffer size to 1 if requested. */
+ if( ( xMode == SMALL_BUFFER_HIGH_PRIORITY ) || ( xMode == SMALL_BUFFER_LOW_PRIORITY ) )
+ {
+ xMaxBufferSize = 1;
+ }
+
+ /* Wait for the Rx task to create and connect the socket. */
+ if( xEventGroupSync( xSyncEventGroup, /* The event group used for the rendezvous. */
+ tcptestTX_TASK_BIT, /* The bit representing the Tx task reaching the rendezvous. */
+ ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ), /* Also wait for the Rx task. */
+ tcptestECHO_TEST_SYNC_TIMEOUT_TICKS ) != ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ) )
+ {
+ break;
+ }
+
+ xTransmitted = 0;
+ xStatus = pdTRUE;
+
+ /* Keep sending until the entire buffer has been sent. */
+ while( xTransmitted < tcptestTWICE_MAX_FRAME_SIZE )
+ {
+ /* How many bytes are left to send? Attempt to send them
+ * all at once (so the length is potentially greater than the
+ * MSS). */
+ xLenToSend = tcptestTWICE_MAX_FRAME_SIZE - xTransmitted;
+
+ /* Every loop switch the size of the packet from maximum to smallest. */
+ if( xLenToSend > xMaxBufferSize )
+ {
+ xLenToSend = xMaxBufferSize;
+ }
+
+ xReturned = FreeRTOS_send( xSocket, /* The socket being sent to. */
+ ( void * ) &( cTransmittedString[ xTransmitted ] ), /* The data being sent. */
+ xLenToSend, /* The length of the data being sent. */
+ 0 ); /* ulFlags. */
+
+ if( xReturned >= 0 )
+ {
+ /* Data was sent successfully. */
+ xTransmitted += xReturned;
+ }
+ else
+ {
+ xStatus = pdFAIL;
+ break;
+ }
+ }
+
+ /* Wait for the Rx task to recognize the socket is closing and stop
+ * using it. */
+
+ if( xEventGroupSync( xSyncEventGroup, /* The event group used for the rendezvous. */
+ tcptestTX_TASK_BIT, /* The bit representing the Tx task reaching the rendezvous. */
+ ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ), /* Also wait for the Rx task. */
+ tcptestECHO_TEST_SYNC_TIMEOUT_TICKS ) != ( tcptestTX_TASK_BIT | tcptestRX_TASK_BIT ) )
+ {
+ xStatus = pdFAIL;
+ }
+
+ if( xStatus == pdFAIL )
+ {
+ break;
+ }
+ }
+
+ vTaskSuspend( NULL ); /* Delete this task. */
+}
+
+/*-----------------------------------------------------------*/
+
+
+/** @brief This test will create x tasks that will send and receive to an
+ * echo server on different socket at the same time.
+ */
+void prvStartTCPEchoClientTasks_DifferentSockets( void )
+{
+ uint16_t usIndex;
+ tcptestEchoClientsTaskParams_t xTcptestEchoClientsTaskParams[ tcptestNUM_ECHO_CLIENTS ];
+ uint32_t ulEventMask;
+ volatile BaseType_t xSyncEventGroupAllocated = pdFALSE;
+ BaseType_t xResult;
+
+ if( TEST_PROTECT() )
+ {
+ /* Create the event group used by the Tx and Rx tasks to synchronize prior
+ * to commencing a cycle using a new socket. */
+ xSyncEventGroup = xEventGroupCreate();
+ configASSERT( xSyncEventGroup );
+ xSyncEventGroupAllocated = pdTRUE;
+
+ /* Create the echo client tasks. */
+ for( usIndex = 0; usIndex < tcptestNUM_ECHO_CLIENTS; usIndex++ )
+ {
+ xTcptestEchoClientsTaskParams[ usIndex ].usTaskTag = usIndex;
+ xTcptestEchoClientsTaskParams[ usIndex ].xResult = FREERTOS_SOCKET_ERROR;
+
+ xResult = xTaskCreate( prvThreadSafeDifferentSocketsDifferentTasks, /* The function that implements the task. */
+ "ClientTask", /* Just a text name for the task to aid debugging. */
+ tcptestTCP_ECHO_TASKS_STACK_SIZE, /* The stack size is defined in FreeRTOSIPConfig.h. */
+ &( xTcptestEchoClientsTaskParams[ usIndex ] ), /* The task parameter, not used in this case. */
+ tcptestTCP_ECHO_TASKS_PRIORITY, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
+ &( xTcptestEchoClientsTaskParams[ usIndex ].xTaskHandle ) ); /* The task handle is not used. */
+ TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xResult, "Task creation failed" );
+ }
+
+ ulEventMask = xEventGroupSync( xSyncEventGroup, /* The event group used for the rendezvous. */
+ 0,
+ tcptestECHO_CLIENT_EVENT_MASK,
+ tcptestECHO_TEST_SYNC_TIMEOUT_TICKS );
+
+ /* For each task not completed, delete the task. */
+ for( usIndex = 0; usIndex < tcptestNUM_ECHO_CLIENTS; usIndex++ )
+ {
+ if( ( ulEventMask & ( 1 << usIndex ) ) == 0 )
+ {
+ vTaskDelete( xTcptestEchoClientsTaskParams[ usIndex ].xTaskHandle );
+ }
+ }
+
+ for( usIndex = 0; usIndex < tcptestNUM_ECHO_CLIENTS; usIndex++ )
+ {
+ TEST_ASSERT_EQUAL_MESSAGE( pdFREERTOS_ERRNO_NONE,
+ xTcptestEchoClientsTaskParams[ usIndex ].xResult,
+ "Check iot_secure_sockets.h for error code" );
+ }
+ }
+
+ if( xSyncEventGroupAllocated == pdTRUE )
+ {
+ vEventGroupDelete( xSyncEventGroup );
+ }
+}
+
+
+TEST( Full_TCP, TCP_Threadsafe_DifferentSocketsDifferentTasks )
+{
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ prvStartTCPEchoClientTasks_DifferentSockets();
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvThreadSafeDifferentSocketsDifferentTasks( void * pvParameters )
+{
+ Socket_t xTaskSocket = FREERTOS_INVALID_SOCKET;
+ int32_t lLoopCount = 0UL;
+ BaseType_t xReceivedBytes, xReturned;
+ BaseType_t xTransmitted;
+ char * pcReceivedString;
+ BaseType_t xResult = FREERTOS_SOCKET_ERROR;
+ BaseType_t xReceivedStringAllocated = pdFALSE;
+ BaseType_t xSocketOpenLocal = pdFALSE;
+ tcptestEchoClientsTaskParams_t * pxTcptestEchoClientsTaskParams;
+
+ pxTcptestEchoClientsTaskParams = ( ( tcptestEchoClientsTaskParams_t * ) pvParameters );
+
+ pcReceivedString = pvPortMalloc( ipconfigTCP_MSS * sizeof( char ) );
+
+ if( pcReceivedString != NULL )
+ {
+ xReceivedStringAllocated = pdTRUE;
+ }
+ else
+ {
+ xResult = FREERTOS_SOCKET_ERROR;
+ tcptestFAILUREPRINTF( ( "%s: Task %d failed to alloc memory \r\n",
+ __FUNCTION__,
+ ( int ) pxTcptestEchoClientsTaskParams->usTaskTag ) );
+ }
+
+ if( pcReceivedString != NULL )
+ {
+ /* Send a number of echo requests. */
+ for( lLoopCount = 0; lLoopCount < tcptestMAX_LOOPS_ECHO_CLIENTS_LOOP; lLoopCount++ )
+ {
+ /* Attempt to establish the requested connection. */
+ xResult = prvConnectHelperWithRetry( &xTaskSocket,
+ xEchoTestRxTxTimeOut,
+ xEchoTestRxTxTimeOut,
+ &xSocketOpenLocal);
+
+ if( xResult != pdFREERTOS_ERRNO_NONE )
+ {
+ tcptestFAILUREPRINTF( ( "%s: Task %d failed to connect with error code %d on loop %d \r\n",
+ __FUNCTION__,
+ xResult,
+ lLoopCount,
+ ( int ) pxTcptestEchoClientsTaskParams->usTaskTag ) );
+ break;
+ }
+
+ /* Send the string to the socket. */
+ xTransmitted = FreeRTOS_send( xTaskSocket, /* The socket being sent to. */
+ ( void * ) cTransmittedString, /* The data being sent. */
+ ipconfigTCP_MSS, /* The length of the data being sent. */
+ 0 ); /* No flags. */
+
+ if( xTransmitted < ipconfigTCP_MSS )
+ {
+ tcptestFAILUREPRINTF( ( "%s: Task %d error %ld while transmitting data\r\n",
+ __FUNCTION__,
+ ( int ) pxTcptestEchoClientsTaskParams->usTaskTag,
+ xTransmitted ) );
+ xResult = FREERTOS_SOCKET_ERROR;
+ break;
+ }
+
+ /* Clear the buffer into which the echoed string will be
+ * placed. */
+ xReceivedBytes = 0;
+
+ /* Receive data echoed back to the socket. */
+ while( xReceivedBytes < xTransmitted )
+ {
+ xReturned = FreeRTOS_recv( xTaskSocket, /* The socket being received from. */
+ &( pcReceivedString[ xReceivedBytes ] ), /* The buffer into which the received data will be written. */
+ ipconfigTCP_MSS - xReceivedBytes, /* The size of the buffer provided to receive the data. */
+ 0 ); /* No flags. */
+
+ if( xReturned <= 0 )
+ {
+ break;
+ }
+
+ xReceivedBytes += xReturned;
+ }
+
+ /* If an error occurred it will be latched in xReceivedBytes,
+ * otherwise xReceived bytes will be just that - the number of
+ * bytes received from the echo server. */
+ if( xReceivedBytes == ipconfigTCP_MSS )
+ {
+ /* Compare the transmitted string to the received string. */
+ if( strncmp( pcReceivedString, cTransmittedString, xTransmitted ) != 0 )
+ {
+ tcptestFAILUREPRINTF( ( "%s: Task %d error while receiving data \r\n",
+ __FUNCTION__,
+ ( int ) pxTcptestEchoClientsTaskParams->usTaskTag ) );
+ xResult = FREERTOS_SOCKET_ERROR;
+ break;
+ }
+ }
+ else
+ {
+ tcptestFAILUREPRINTF( ( "%s: Task %d error not enough bytes received \r\n",
+ __FUNCTION__,
+ ( int ) pxTcptestEchoClientsTaskParams->usTaskTag ) );
+ xResult = FREERTOS_SOCKET_ERROR;
+ break;
+ }
+
+ /* Close this socket before looping back to create another. */
+ ( void ) prvShutdownHelper( xTaskSocket );
+ ( void ) prvCloseHelper( xTaskSocket, &xSocketOpenLocal);
+ }
+ }
+
+ /* Free all dynamic memory. */
+ if( xReceivedStringAllocated == pdTRUE )
+ {
+ vPortFree( pcReceivedString );
+ }
+
+ if( xSocketOpenLocal == pdTRUE )
+ {
+ ( void ) prvCloseHelper( xTaskSocket, &xSocketOpenLocal );
+ }
+
+ pxTcptestEchoClientsTaskParams->xResult = xResult;
+
+ /* Don't wait, just flag it reached that point. */
+ xEventGroupSync( xSyncEventGroup, /* The event group used for the rendezvous. */
+ ( 1 << pxTcptestEchoClientsTaskParams->usTaskTag ),
+ tcptestECHO_CLIENT_EVENT_MASK,
+ tcptestECHO_TEST_SYNC_TIMEOUT_TICKS );
+
+
+ vTaskDelete( NULL ); /* Delete this task. */
+}
+
+/*-----------------------------------------------------------*/
+
+TEST( Full_TCP, TCP_htons_HappyCase )
+{
+ uint16_t usNetworkOrderValue;
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ /* Convert the host order value to network order
+ * value. */
+ usNetworkOrderValue = FreeRTOS_htons( 0x1234 );
+
+ #if defined(ipconfigBYTE_ORDER) && ( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
+
+ /* If the platform we are running on, is little
+ * endian, bytes must have been swapped. */
+ TEST_ASSERT_EQUAL_INT16_MESSAGE( 0x3412, usNetworkOrderValue, "FreeRTOS_htons returned incorrect value." );
+ #else
+
+ /* If the platform we are running on, is big
+ * endian, the output value must be same as
+ * the input value. */
+ TEST_ASSERT_EQUAL_INT16_MESSAGE( 0x1234, usNetworkOrderValue, "FreeRTOS_htons returned incorrect value." );
+ #endif
+
+ tcptestPRINTF( ( "%s complete.\r\n", __FUNCTION__ ) );
+}
+/*-----------------------------------------------------------*/
+
+TEST( Full_TCP, TCP_test_dns_multiple_addresses )
+{
+ BaseType_t xResult = pdFAIL;
+ uint32_t i;
+ uint32_t j;
+ uint32_t ulIPAddress;
+ uint32_t ulUnique;
+ uint32_t ulNumUniqueIPAddresses = 0;
+
+ /* Resolve "freertos.org", which will have multiple IP addresses */
+
+ uint32_t ulIPAddresses[ dnstestNUM_UNIQUE_IP_ADDRESSES ] = { 0UL };
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ /*
+ * Resolve the endpoint to an array of IP addresses. Each subsequent
+ * call will return one of the addresses which the name resolves to.
+ *
+ * NOTE: Resolving addresses can take some time, so allow up to
+ * 60 seconds to collect all of them.
+ */
+ for( i = 0; ( i < 60 ) && ( ulNumUniqueIPAddresses < dnstestNUM_UNIQUE_IP_ADDRESSES ); i++ )
+ {
+ ulIPAddress = FreeRTOS_gethostbyname( HostNameUNIQUE_ADDRESSES_TEST );
+
+ for( j = 0, ulUnique = 1; j < ulNumUniqueIPAddresses; j++ )
+ {
+ if( ulIPAddresses[ j ] == ulIPAddress )
+ {
+ ulUnique = 0;
+ }
+ }
+
+ if( ( ulUnique == 1 ) && ( ulNumUniqueIPAddresses < dnstestNUM_UNIQUE_IP_ADDRESSES ) )
+ {
+ ulIPAddresses[ ulNumUniqueIPAddresses++ ] = ulIPAddress;
+ }
+
+ vTaskDelay( 1000 / portTICK_PERIOD_MS );
+ }
+
+ tcptestPRINTF( ( "%s: identified %d different IP addresses for %s.\r\n",
+ __FUNCTION__,
+ ulNumUniqueIPAddresses,
+ HostNameUNIQUE_ADDRESSES_TEST ) );
+
+ /* Require a minimum number of IP addresses for AWS IoT Core endpoints */
+ if( ulNumUniqueIPAddresses >= dnstestNUM_UNIQUE_IP_ADDRESSES )
+ {
+ xResult = pdPASS;
+ }
+ TEST_ASSERT_EQUAL_UINT32_MESSAGE( pdPASS, xResult, "Less number of IP addresses per entry than expected\n" );
+
+ tcptestPRINTF( ( "%s complete.\r\n", __FUNCTION__ ) );
+}
+
+/*-----------------------------------------------------------*/
+
+TEST( Full_TCP, TCP_inet_addr_quick_HappyCase )
+{
+ uint32_t ulPackedIpAddress;
+
+ tcptestPRINTF( ( "Starting %s.\r\n", __FUNCTION__ ) );
+
+ ulPackedIpAddress = FreeRTOS_inet_addr_quick( 192, 168, 2, 6 );
+
+ #if defined(ipconfigBYTE_ORDER) && ( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
+
+ /* The expected return value of FreeRTOS_inet_addr_quick
+ * on a little endian platform must be same as the correct
+ * hand calculated value. */
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( 0x0602A8C0, ulPackedIpAddress, "FreeRTOS_inet_addr_quick returned incorrect value." );
+ #else
+
+ /* The expected return value of FreeRTOS_inet_addr_quick
+ * on a big endian platform must be same as the correct
+ * hand calculated value. */
+ TEST_ASSERT_EQUAL_INT32_MESSAGE( 0xC0A80206, ulPackedIpAddress, "FreeRTOS_inet_addr_quick returned incorrect value." );
+ #endif
+
+ tcptestPRINTF( ( "%s complete.\r\n", __FUNCTION__ ) );
+}
+
+/* TODO: Investigate tests for loopback, other reserved IP addresses */
+/* TODO: Implement tests with a bad TCP connection (dropped packets, repeated packets, connection refused etc */
+/* TODO: Implement tests that have memory allocation errors (freertos heap is full) */
+/*-------------------------------------------------------------------*/
+/*-----------------------End Tests-----------------------------------*/
+/*-------------------------------------------------------------------*/