diff options
author | lundinc <lundinc@1d2547de-c912-0410-9cb9-b8ca96c0e9e2> | 2020-08-12 19:11:51 +0000 |
---|---|---|
committer | lundinc <lundinc@1d2547de-c912-0410-9cb9-b8ca96c0e9e2> | 2020-08-12 19:11:51 +0000 |
commit | 42255af1e27a3157d541f0812eaca447c569ca49 (patch) | |
tree | 5c8702c2f0dc1cb9be1a4d5ff285897d96b97dd2 /FreeRTOS-Plus/Test/CMock/test/system | |
parent | f5221dff43de249079c2da081723cb7a456f981f (diff) | |
download | freertos-master.tar.gz |
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/CMock/test/system')
37 files changed, 6236 insertions, 0 deletions
diff --git a/FreeRTOS-Plus/Test/CMock/test/system/systest_generator.rb b/FreeRTOS-Plus/Test/CMock/test/system/systest_generator.rb new file mode 100644 index 000000000..490a56eb1 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/systest_generator.rb @@ -0,0 +1,205 @@ +# ========================================== +# CMock Project - Automatic Mock Generation for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +require 'yaml' + +SYS_TEST_GEN_ROOT = File.expand_path( File.dirname( __FILE__ ) ) + '/' +GENERATED_PATH = SYS_TEST_GEN_ROOT + 'generated/' +BUILD_PATH = SYS_TEST_GEN_ROOT + 'build/' +CASES_PATH = SYS_TEST_GEN_ROOT + 'cases/' + +TYPES_H = 'types.h' +UNITY_H = 'unity.h' +CMOCK_H = 'cmock.h' +UNITY_HELPER_H = 'unity_helper.h' +UNITY_HELPER_C = 'unity_helper.c' +MOCKABLE_H = 'mockable.h' + +YAML_EXTENSION = '.yml' +TEST_PREFIX = 'test_' +MOCK_PREFIX = 'mock_' +H_EXTENSION = '.h' +C_EXTENSION = '.c' + + +class SystemTestGenerator + + def generate_files(test_cases) + test_cases.each do |filename| + yaml_hash = YAML.load_file(filename) + + name = File.basename(filename, YAML_EXTENSION) + namix = "#{name}_" + + generate_cmock_config(yaml_hash, namix) + generate_code(yaml_hash, namix, name) + end + end + + private + + def generate_cmock_config(yaml_hash, namix) + cmock_yaml = yaml_hash.clone + cmock_yaml.delete(:systest) + cmock = cmock_yaml[:cmock] + + cmock[:mock_path] = GENERATED_PATH + cmock[:includes] = (cmock[:includes] || []) + [namix + TYPES_H] + cmock[:mock_prefix] = MOCK_PREFIX + if not yaml_hash[:systest][:unity_helper].nil? + cmock[:includes] << namix + UNITY_HELPER_H + cmock[:unity_helper_path] = GENERATED_PATH + namix + UNITY_HELPER_H + end + + File.open(GENERATED_PATH + namix + 'cmock' + YAML_EXTENSION, 'w') do |out| + YAML.dump(cmock_yaml, out) + end + end + + def generate_code(yaml_hash, namix, name) + generate_types_file(yaml_hash, namix) + generate_mockable_file(yaml_hash, namix) + generate_unity_helper_files(yaml_hash, namix) + + generate_test_file(yaml_hash, namix, name) + generate_source_file(yaml_hash, namix, name) + generate_skeleton_file(yaml_hash, namix, name) + end + + def generate_types_file(yaml_hash, namix) + types = yaml_hash[:systest][:types] + return if types.nil? + + write_header_file(GENERATED_PATH + namix + TYPES_H, namix.upcase + 'TYPES_H') do |out| + out.puts(types) + end + end + + def generate_mockable_file(yaml_hash, namix) + mockable = yaml_hash[:systest][:mockable] + return if mockable.nil? + + write_header_file(GENERATED_PATH + namix + MOCKABLE_H, namix.upcase + 'MOCKABLE_H', [namix + TYPES_H]) do |out| + out.puts(mockable) + end + end + + def generate_unity_helper_files(yaml_hash, namix) + unity_helper = yaml_hash[:systest][:unity_helper] + return if unity_helper.nil? + + write_header_file(GENERATED_PATH + namix + UNITY_HELPER_H, namix.upcase + 'UNITY_HELPER_H', [namix + TYPES_H]) do |out| + out.puts(unity_helper[:header]) + end + + write_source_file(GENERATED_PATH + namix + UNITY_HELPER_C, ["unity.h", namix + UNITY_HELPER_H]) do |out| + out.puts(unity_helper[:code]) + end + end + + def generate_test_file(yaml_hash, namix, name) + tests = yaml_hash[:systest][:tests] + return if tests.nil? + + includes = [UNITY_H, CMOCK_H] + includes << [MOCK_PREFIX + namix + MOCKABLE_H] + includes << [name + H_EXTENSION] + + write_source_file(GENERATED_PATH + TEST_PREFIX + name + C_EXTENSION, includes.flatten) do |out| + out.puts(tests[:common]) + out.puts('') + + tests[:units].each_with_index do |test, index| + out.puts('// should ' + test[:should]) + out.puts(test[:code].gsub!(/test\(\)/, "void test#{index+1}(void)")) + out.puts('') + end + end + end + + def generate_source_file(yaml_hash, namix, name) + source = yaml_hash[:systest][:source] + return if source.nil? + + header_file = name + H_EXTENSION + + includes = yaml_hash[:systest][:types].nil? ? [] : [(namix + TYPES_H)] + + write_header_file(GENERATED_PATH + header_file, name.upcase, includes) do |out| + out.puts(source[:header]) + end + + includes = [] + includes << (namix + TYPES_H) if not yaml_hash[:systest][:types].nil? + includes << (namix + MOCKABLE_H) if not yaml_hash[:systest][:mockable].nil? + includes << header_file + + unless (source[:code].nil?) + write_source_file(GENERATED_PATH + name + C_EXTENSION, includes.flatten) do |out| + out.puts(source[:code]) + end + end + end + + def generate_skeleton_file(yaml_hash, namix, name) + source = yaml_hash[:systest][:skeleton] + return if source.nil? + + require 'cmock.rb' + cmock = CMock.new(GENERATED_PATH + namix + 'cmock' + YAML_EXTENSION) + cmock.setup_skeletons("#{$cfg['compiler']['source_path']}#{name}.h") + end + + def write_header_file(filename, upcase_name, include_list=[]) + File.open(filename, 'w') do |out| + out.puts("#ifndef _#{upcase_name}") + out.puts("#define _#{upcase_name}") + out.puts('') + include_list.each do |include| + out.puts("#include \"#{include}\"") + end + out.puts('') + out.puts("#if defined(__GNUC__) && !defined(__ICC)") + out.puts("#if !defined(__clang__)") + out.puts("#pragma GCC diagnostic ignored \"-Wpragmas\"") + out.puts("#endif") + out.puts('#pragma GCC diagnostic ignored "-Wunknown-pragmas"') + out.puts('#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"') + out.puts("#endif") + out.puts('') + yield(out) + out.puts('') + out.puts("#endif // _#{upcase_name}") + out.puts('') + end + end + + def write_source_file(filename, include_list=[]) + File.open(filename, 'w') do |out| + include_list.each do |include| + out.puts("#include \"#{include}\"") + end + out.puts('') + out.puts("#if defined(__GNUC__) && !defined(__ICC)") + out.puts("#if !defined(__clang__)") + out.puts("#pragma GCC diagnostic ignored \"-Wpragmas\"") + out.puts("#endif") + out.puts('#pragma GCC diagnostic ignored "-Wunknown-pragmas"') + out.puts('#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"') + out.puts("#endif") + out.puts('') + yield(out) + out.puts('') + end + end + +end + + +if ($0 == __FILE__) + SystemTestGenerator.new.generate_files(Dir[CASES_PATH + "*#{YAML_EXTENSION}"]) +end + diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/callingconv.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/callingconv.h new file mode 100644 index 000000000..beae0619f --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/callingconv.h @@ -0,0 +1,11 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef __stdcall +#define __stdcall +#endif + +int __stdcall this_uses_calling_conventions(int b); diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/config.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/config.yml new file mode 100644 index 000000000..787e2e1f6 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/config.yml @@ -0,0 +1,10 @@ +--- +:cmock: + :plugins: [] + :includes: [] + :mock_path: ./system/generated/ + :mock_prefix: mock_ + :treat_inlines: :include + :treat_as_void: + - OSEK_TASK + - VOID_TYPE_CRAZINESS diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/const.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/const.h new file mode 100644 index 000000000..71426bc3b --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/const.h @@ -0,0 +1,37 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#if defined(__GNUC__) && !defined(__ICC) +#if !defined(__clang__) +#pragma GCC diagnostic ignored "-Wpragmas" +#endif +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier" +#endif + +struct _DUMMY_T { unsigned int a; float b; }; + +void const_variants1( const char* a, int const, unsigned short const * c ); + +void const_variants2( + struct _DUMMY_T const * const param1, + const unsigned long int const * const param2, + const struct _DUMMY_T const * param3 ); + +const int * const_retval1(void); /* nicety version for pointer to constant int */ +int const * const_retval2(void); /* formal version for pointer to constant int */ +//int * const const_retval3(void); /* formal version for constant pointer to int */ +//int const * const const_retval4(void); /* formal version for constant pointer to constant int */ + +const int* const_retval5(void); /* sticky-left nicety version for pointer to constant int */ +int const* const_retval6(void); /* sticky-left formal version for pointer to constant int */ +//int* const const_retval7(void); /* sticky-left formal version for constant pointer to int */ +//int const* const const_retval8(void); /* sticky-left formal version for constant pointer to constant int */ + +const int *const_retval9(void); /* sticky-right nicety version for pointer to constant int */ +int const *const_retvalA(void); /* sticky-right formal version for pointer to constant int */ +//int *const const_retvalB(void); /* sticky-right formal version for constant pointer to int */ +//int const *const const_retvalC(void); /* sticky-right formal version for constant pointer to constant int */ diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/inline.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/inline.h new file mode 100644 index 000000000..06e33c184 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/inline.h @@ -0,0 +1,23 @@ + +static inline int dummy_func_0(void) { + return 5; +} + +inline static int dummy_func_1(int a) { + int a = dummy_func_0(); + int b = 10; + + return a + b; +} + +int inline static dummy_func_2(int a, char b, float c) { + c += 3.14; + b -= 32; + return a + (int)(b) + (int)c; +} + +void dummy_normal_func(int a); + +inline void dummy_func_3(void) { + //NOP +} diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/osek.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/osek.h new file mode 100644 index 000000000..f3abe7b57 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/osek.h @@ -0,0 +1,275 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +typedef unsigned char OSServiceIdType; +typedef void (*OSEKOS_VOIDFUNCPTR)(void); + +typedef unsigned char StatusType; +typedef unsigned char OSEK_U8; +typedef unsigned short OSEK_U16; +typedef unsigned long OSEK_U32; + +void OSEKOSDisableAll(void); +void OSEKOSEnableAll(void); + +typedef unsigned long * OSEKOSSaveType; +typedef void OSEK_TASK; +typedef OSEK_U8 OSEKOSPrioType; + +enum { +Task_DbgCAN +, +Task_ALS +, +CalibrateMagTask +, +Task_IAQ +, +SmartBeam +, +Task_QbertTestImage +, +Task_TestQbertMem +, +Task_Cyclic1000 +, +ProcessMagForCompass +, +ReadMag +, +Task_Cyclic10 +, +Task_Wdm +, +BackgroundTask +, +Task_Cyclic20 +, +Task_Cyclic2 +}; + +OSEK_TASK OSEKOS_T_Task_DbgCAN(void); +OSEK_TASK OSEKOS_T_Task_ALS(void); +OSEK_TASK OSEKOS_T_CalibrateMagTask(void); +OSEK_TASK OSEKOS_T_Task_IAQ(void); +OSEK_TASK OSEKOS_T_SmartBeam(void); +OSEK_TASK OSEKOS_T_Task_QbertTestImage(void); +OSEK_TASK OSEKOS_T_Task_TestQbertMem(void); +OSEK_TASK OSEKOS_T_Task_Cyclic1000(void); +OSEK_TASK OSEKOS_T_ProcessMagForCompass(void); +OSEK_TASK OSEKOS_T_ReadMag(void); +OSEK_TASK OSEKOS_T_Task_Cyclic10(void); +OSEK_TASK OSEKOS_T_Task_Wdm(void); +OSEK_TASK OSEKOS_T_BackgroundTask(void); +OSEK_TASK OSEKOS_T_Task_Cyclic20(void); +OSEK_TASK OSEKOS_T_Task_Cyclic2(void); +OSEK_TASK OSEKOS_Twrap_Task_DbgCAN(void); +OSEK_TASK OSEKOS_Twrap_Task_ALS(void); +OSEK_TASK OSEKOS_Twrap_CalibrateMagTask(void); +OSEK_TASK OSEKOS_Twrap_Task_IAQ(void); +OSEK_TASK OSEKOS_Twrap_SmartBeam(void); +OSEK_TASK OSEKOS_Twrap_Task_QbertTestImage(void); +OSEK_TASK OSEKOS_Twrap_Task_TestQbertMem(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic1000(void); +OSEK_TASK OSEKOS_Twrap_ProcessMagForCompass(void); +OSEK_TASK OSEKOS_Twrap_ReadMag(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic10(void); +OSEK_TASK OSEKOS_Twrap_Task_Wdm(void); +OSEK_TASK OSEKOS_Twrap_BackgroundTask(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic20(void); +OSEK_TASK OSEKOS_Twrap_Task_Cyclic2(void); + +typedef OSEK_U8 TaskType; +typedef OSEK_U8 TaskStateType; +typedef OSEK_U16 EventMaskType; +typedef OSEK_U8 ResourceType; + +void OSEKOSEnableSystemTimers(void); + +typedef OSEK_U8 CounterType; +typedef OSEK_U32 TickType; +typedef OSEK_U8 AlarmType; + +void OSEKOS_ISR_CanTxInterrupt(void); +void OSEKOS_ISR_CanRxInterrupt(void); +void OSEKOS_ISR_CanErrInterrupt(void); +void OSEKOS_ISR_SCIRxInterrupt(void); +void OSEKOS_ISR_SCITxInterrupt(void); +void OSEKOS_ISR_UP_DMA_Interrupt_0(void); +void OSEKOS_ISR_UP_DMA_Interrupt_1(void); +void OSEKOS_ISR_UP_DMA_Interrupt_2(void); +void OSEKOS_ISR_UP_DMA_Interrupt_3(void); +void OSEKOS_ISR_CompFreqHandler(void); +void OSEKOS_ISR_AmbientReturnInt(void); +void OSEKOS_ISR_GlareReturnInt(void); +void OSEKOS_ISR_ALSTimeoutInt(void); +void OSEKOS_ISR_LINTimerInt(void); +void OSEKOS_ISR_LINDelayInt(void); +void OSEKOS_ISR_TimerMExpire(void); +void OSEKOS_ISR_LINRxTx_SCI1(void); +void OSEKOS_ISR_CanRxInterrupt_1(void); +void OSEKOS_ISR_LINError_SCI1(void); +void OSEKOS_ISR_SysCounter(void); + + +// defined multiple times (slightly different forms) These should be ignored because they are externed +extern void OSEKOS_ISR_CanTxInterrupt( void ); +extern void OSEKOS_ISR_CanRxInterrupt( void ); + + +unsigned long OSEKOSrtcGetSeconds ( void ); +void OSEKOSrtcIncrement ( unsigned long nsec ); + +enum +{ + E_OS_ACCESS = 1, + E_OS_CALLEVEL = 2, + E_OS_ID = 3, + E_OS_LIMIT = 4, + E_OS_NOFUNC = 5, + E_OS_RESOURCE = 6, + E_OS_STATE = 7, + E_OS_VALUE = 8, + E_OS_SYS_StackOverflow = 20, + E_OS_SYS_StackUnderflow = 21, + E_OS_SYS_INIT = 22, + E_OS_SYS_CONFIG = 23, + E_OS_SYS_CODE = 24, + E_OS_SYS_TOOL = 25, + E_OS_SYS_TimerRange = 26 +}; + +enum +{ + SUSPENDED = 0x00, + READY = 0x01, + RUNNING = 0x02, + WAITING = 0x03, + INTSTART = 0x08, + SETSTART = 0x10, + NPRTASK = 0x20, + USEFP = 0x40 +}; + +typedef struct +{ + TickType maxallowedvalue; + TickType ticksperbase; +} AlarmBaseType; + +typedef TaskType *TaskRefType; +typedef TaskStateType *TaskStateRefType; +typedef EventMaskType *EventMaskRefType; +typedef TickType *TickRefType; +typedef AlarmBaseType *AlarmBaseRefType; +typedef OSEK_U8 AppModeType; +typedef OSEK_U8 OSEKOSTaskActCntType; + +TaskType OSEKOStidact; +OSEKOSPrioType OSEKOSrunprio; + +StatusType OSEKOSError ( register StatusType ); +void ErrorHook ( StatusType ); +void StartupHook ( void ); +void ShutdownHook ( StatusType ); + +int getUsedTaskStack ( TaskType ); +int getUnusedTaskStack ( TaskType ); +int getUsedIsrStack ( void ); +int getUnusedIsrStack ( void ); +void OSEKOStaskStackCheckInit ( void ); +signed char OSEKOStaskStackCheck ( OSEK_U8 * ); +signed char OSEKOSisrStackCheck ( OSEK_U8 * ); +void OSEKOStaskStackCheckFatal ( OSEK_U8 * ); +void OSEKOSisrStackCheckFatal ( OSEK_U8 * ); +OSEK_U8 * OSEKOSgetStackPointer ( void ); +void OSEKOSTaskSwitch ( void ); +StatusType OSEKOSReturn ( StatusType ); +StatusType OSEKOSActivateTask ( register TaskType ); +void OSEKOSTerminateTask ( TaskType, TaskType ); + + extern void OSEKOSGetResource ( ResourceType ); + extern void OSEKOSReleaseResource ( ResourceType ); + +int OSEKOSSetEvent ( TaskType, EventMaskType ); +int OSEKOSWaitEvent ( EventMaskType ); +TickType OSEKOSGetAlarm(register AlarmType); +void OSEKOSSetAlarm ( AlarmType, TickType, TickType ); +StatusType OSEKOSSetAbsAlarm ( AlarmType a, TickType b, TickType c ); + +StatusType OSEKOSCancelAlarm ( register AlarmType ); +void OSEKOSAdvCntr ( void ); +AppModeType GetActiveApplicationMode ( void ); + +void StartOS ( AppModeType ); + +void OSEKOSShutdownOS ( StatusType ); + +StatusType ActivateTask ( TaskType A ); +StatusType TerminateTask ( void ); +StatusType ChainTask ( TaskType A ); +StatusType GetTaskState ( TaskType A, TaskStateRefType B ); +StatusType GetTaskID ( TaskRefType A ); +StatusType Schedule ( void ); +StatusType GetResource ( ResourceType A ); +StatusType ReleaseResource ( ResourceType A ); +StatusType SetEvent ( TaskType A, EventMaskType B ); +StatusType ClearEvent ( EventMaskType A ); +StatusType WaitEvent ( EventMaskType A ); +StatusType GetEvent ( TaskType A, EventMaskRefType B ); +StatusType GetAlarm ( AlarmType A, TickRefType B ); +StatusType GetAlarmBase ( AlarmType A, AlarmBaseRefType B ); +StatusType SetRelAlarm ( AlarmType A, TickType B, TickType C ); +StatusType SetAbsAlarm ( AlarmType A, TickType B, TickType C ); +StatusType CancelAlarm ( AlarmType A ); +StatusType AdvCntr ( CounterType A ); +StatusType IAdvCntr ( CounterType A ); +void SuspendOSInterrupts ( void ); +void ResumeOSInterrupts ( void ); +void SuspendAllInterrupts ( void ); +void ResumeAllInterrupts ( void ); +void DisableAllInterrupts ( void ); +void EnableAllInterrupts ( void ); + +void OSEKOSDisable(void); +void OSEKOSEnable(void); +void OSEKOSAsmIDispatch(unsigned long *); +void OSEKOSAsmDispatch(OSEKOSPrioType p); +void OSEKOSStartupEnable(void); +void OSEKOSNop(void); +unsigned int OSEKOSV850CheckIsrSwitch(void); +void OSEKOSV850InitInterrupts(void); +void OSEKOSV850SetupInterrupts(); +void OSEKOSV850SyncContextLoad(OSEKOSSaveType); +void OSEKOSV850SyncContextLoadFromIRQ(OSEKOSSaveType); +void OSEKOSV850ASyncContextLoad(OSEKOSSaveType); +void OSEKOSV850ASyncContextLoadFromIRQ(OSEKOSSaveType); + +// arrays of function pointers - they look like function prototypes +void ( ( * const OSEKOStaskStartAddress [10] ) ( void ) ); +StatusType (* OSEKOStaskStatuses [10][5]) ( void ); + +void OSEKOSV850StartContext +( + OSEK_TASK (( * const ) ( void )), + OSEK_U8 * const +); +void OSEKOSV850StartContextFromIRQ +( + OSEK_TASK (( * const ) ( void )), + OSEK_U8 * const +); + +void OSEKOSSuspendOSInterrupts(void); +void OSEKOSResumeOSInterrupts(void); +void OSEKOSSuspendAllInterrupts(void); +void OSEKOSResumeAllInterrupts(void); +void OSEKOScheckSuspendResumeNesting(void); + + +void OSEKOSgetSR(void); +void OSEKOSEnableInterrupt_intern(int nr); +void OSEKOSDisableInterrupt_intern(int nr); diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/parsing.h b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/parsing.h new file mode 100644 index 000000000..d4734f448 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_compilation/parsing.h @@ -0,0 +1,89 @@ +/* ========================================== + CMock Project - Automatic Mock Generation for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +typedef unsigned short U16; +typedef signed int int32_t; + +/* CMock should handle UTF-8 characters in comments. The world is an awesomely diverse place! */ +/* my µC Rocks! Open Source, not ©! My language has no Ümlauts! ǺƜǝƧǾɱɛ! */ /**! Illegal: åäö */ + +typedef struct _POINT_T +{ + int x; + int y; +} POINT_T; + +// typedef edge case; +// not ANSI C but it has been done and will break cmock if not handled +typedef void VOID_TYPE_CRAZINESS; + +/* fun parsing & mock generation cases */ + +void var_args1(int a, ...); +void var_args2(int a, int b, ...); + +VOID_TYPE_CRAZINESS void_type_craziness1(int, float, double, char, short, long, long int, long long, void*); +int void_type_craziness2( VOID_TYPE_CRAZINESS ); + + void crazy_whitespace ( int lint, double shot , short stack ) ; + +char + crazy_multiline +( + int a, + unsigned int b); + +U16 *ptr_return1(int a); +U16* ptr_return2(int a); +U16 * ptr_return3(int a); + +unsigned int** ptr_ptr_return1(unsigned int** a); +unsigned int* *ptr_ptr_return2(unsigned int* *a); +unsigned int **ptr_ptr_return3(unsigned int **a); +unsigned int ** ptr_ptr_return4(unsigned int ** a); + +extern unsigned long int incredible_descriptors(register const unsigned short a); + +int32_t example_c99_type(int32_t param1); + +void I2CIntRegister(uint32_t ui32Base, void (*pfnHandler)(void)); + +/* these are function pointers, not function declarations USING a function pointer, and so should NOT get mocked */ +int (* func_pointer)(void); +extern int (*another_func_pointer)(unsigned int argument); +struct struct_to_be_ignored { + union { + int i32; + void *p; + } variant; + void (*a_function_pointer_in_a_struct)(void *); +}; + +typedef struct +{ + uint32_t a; + struct + { + uint32_t bb; + float bc; + float bd; + } b; + int (*another_function_pointer_in_a_struct) (void); +} another_thing_that_should_get_ignored; + +inline int stuff(int num) +{ + int reg = 0x12; + if (num > 0) + { + reg |= (0x0Eu); + } + else + { + reg |= (0x07u); + } + return reg; +} diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/all_plugins_but_other_limits.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/all_plugins_but_other_limits.yml new file mode 100644 index 000000000..9349c00f6 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/all_plugins_but_other_limits.yml @@ -0,0 +1,375 @@ +--- +#this test is different than all_plugins_coexist primarily because of these options +:cmock: + :enforce_strict_ordering: 1 + :treat_externs: :include + :plugins: + - :array + - :cexception + - :ignore + - :callback + - :return_thru_ptr + - :ignore_arg + - :expect_any_args + +:systest: + :types: | + typedef struct _POINT_T { + int x; + int y; + } POINT_T; + + :mockable: | + #include "CException.h" + void foo(POINT_T* a); + POINT_T* bar(void); + void fooa(POINT_T a[]); + void foos(const char * a); + extern const char* bars(void); + void no_pointers(int a, const char* b); + int mixed(int a, int* b, int c); + void no_args(void); + + :source: + :header: | + #include "CException.h" + void function_a(void); + void function_b(void); + void function_c(void); + int function_d(void); + void function_e(void); + + :code: | + void function_a(void) + { + foo(bar()); + } + + void function_b(void) { + fooa(bar()); + } + + void function_c(void) { + CEXCEPTION_T e; + Try { + foos(bars()); + } Catch(e) { foos("err"); } + } + + int function_d(void) { + int test_list[] = { 1, 2, 3, 4, 5 }; + no_pointers(1, "silly"); + return mixed(6, test_list, 7); + } + + void function_e(void) { + foos("Hello"); + foos("Tuna"); + foos("Oranges"); + } + + :tests: + :common: | + #include "CException.h" + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle the situation where we pass nulls to pointers' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we expected nulls to pointers but did not get that' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we did not expect nulls to pointers but got null' + :code: | + test() + { + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(NULL); + foo_Expect(&ex); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_Expect(&ex); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single object with expect and use array handler' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 1); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and use array handler and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 1); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass multiple objects with expect and use array handler' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 4}, {5, 6}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong at end' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 4}, {5, 9}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single array element with expect' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + fooa_Expect(&ex); + + function_b(); + } + + - :pass: TRUE + :should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, passing' + :code: | + test() + { + const char* constretval = "This is a\0 silly string"; + char* retval = (char*)constretval; + bars_ExpectAndReturn(retval); + foos_Expect("This is a\0 wacky string"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, finding failures' + :code: | + test() + { + const char* constretval = "This is a silly string"; + char* retval = (char*)constretval; + bars_ExpectAndReturn(retval); + foos_Expect("This is a wacky string"); + + function_c(); + } + + - :pass: TRUE + :should: 'handle creating array expects when we have mixed arguments for single object' + :code: | + test() + { + int expect_list[] = { 1, 9 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectAndReturn(6, expect_list, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: FALSE + :should: 'handle creating array expects when we have mixed arguments and handle failures for single object' + :code: | + test() + { + int expect_list[] = { 9, 1 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectAndReturn(6, expect_list, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'handle creating array expects when we have mixed arguments for multiple objects' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: FALSE + :should: 'handle creating array expects when we have mixed arguments and handle failures for multiple objects' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectWithArrayAndReturn(6, expect_list, 5, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'handle an exception being caught' + :code: | + test() + { + const char* constretval = "This is a\0 silly string"; + char* retval = (char*)constretval; + bars_ExpectAndReturn(retval); + foos_ExpectAndThrow("This is a\0 wacky string", 55); + foos_Expect("err"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle an exception being caught but still catch following errors' + :code: | + test() + { + const char* constretval = "This is a\0 silly string"; + char* retval = (char*)constretval; + bars_ExpectAndReturn(retval); + foos_ExpectAndThrow("This is a\0 wacky string", 55); + foos_Expect("wrong error"); + + function_c(); + } + + - :pass: FALSE + :should: 'fail strict ordering problems even though we would otherwise have passed' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + no_pointers_Expect(1, "silly"); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'properly ExpectAnyArgs first function but the other will work properly' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_ExpectAnyArgs(); + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'properly ExpectAnyArgs last function but the other will work properly' + :code: | + test() + { + no_pointers_Expect(1, "silly"); + mixed_ExpectAnyArgsAndReturn(13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'be ok if we ExpectAnyArgs a call each because we are counting calls' + :code: | + test() + { + foos_ExpectAnyArgs(); + foos_ExpectAnyArgs(); + foos_ExpectAnyArgs(); + + function_e(); + } + + - :pass: TRUE + :should: 'be ok if we ExpectAnyArgs and Expect intermixed because we are counting calls' + :code: | + test() + { + foos_Expect("Hello"); + foos_ExpectAnyArgs(); + foos_ExpectAnyArgs(); + + function_e(); + } + + - :pass: FALSE + :should: 'be able to detect Expect problem if we ExpectAnyArgs and Expect intermixed' + :code: | + test() + { + foos_Expect("Hello"); + foos_ExpectAnyArgs(); + foos_Expect("Wrong"); + + function_e(); + } + + - :pass: FALSE + :should: 'fail if we do not ExpectAnyArgs a call once because we are counting calls' + :code: | + test() + { + foos_ExpectAnyArgs(); + foos_ExpectAnyArgs(); + + function_e(); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/all_plugins_coexist.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/all_plugins_coexist.yml new file mode 100644 index 000000000..f1c4e38a4 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/all_plugins_coexist.yml @@ -0,0 +1,460 @@ +--- +:cmock: + :enforce_strict_ordering: 1 + :plugins: + - :array + - :cexception + - :ignore + - :callback + - :return_thru_ptr + - :ignore_arg + - :expect_any_args + :callback_after_arg_check: true + :callback_include_count: false + :treat_externs: :include + :treat_inlines: :include + +:systest: + :types: | + typedef struct _POINT_T { + int x; + int y; + } POINT_T; + + :mockable: | + #include "CException.h" + extern void foo(POINT_T* a); + POINT_T* bar(void); + void fooa(POINT_T a[]); + void foos(const char * a); + const char * bars(void); + void no_pointers(int a, const char* b); + int mixed(int a, int* b, int c); + void no_args(void); + + :source: + :header: | + #include "CException.h" + void function_a(void); + void function_b(void); + void function_c(void); + int function_d(void); + void function_e(void); + int function_f(void); + + :code: | + void function_a(void) + { + foo(bar()); + } + + void function_b(void) { + fooa(bar()); + } + + void function_c(void) { + CEXCEPTION_T e; + Try { + foos(bars()); + } Catch(e) { foos("err"); } + } + + int function_d(void) { + int test_list[] = { 1, 2, 3, 4, 5 }; + no_pointers(1, "silly"); + return mixed(6, test_list, 7); + } + + void function_e(void) { + foos("Hello"); + foos("Tuna"); + foos("Oranges"); + } + + int function_f(void) { + int a = 1; + int b = 2; + int c; + POINT_T* pt = bar(); + c = pt->x; + c = mixed(a, &b, c); + return b + c; + } + + :tests: + :common: | + #include "CException.h" + void setUp(void) {} + void tearDown(void) {} + void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); } + int my_mixed_callback(int a, int* b, int c) { return a + *b + c; } + + :units: + - :pass: TRUE + :should: 'handle the situation where we pass nulls to pointers' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we expected nulls to pointers but did not get that' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we did not expect nulls to pointers but got null' + :code: | + test() + { + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(NULL); + foo_Expect(&ex); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_Expect(&ex); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single object with expect and use array handler' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 1); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and use array handler and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 1); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass multiple objects with expect and use array handler' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 4}, {5, 6}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong at end' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 4}, {5, 9}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single array element with expect' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + fooa_Expect(&ex); + + function_b(); + } + + - :pass: TRUE + :should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, passing' + :code: | + test() + { + const char* retval = "This is a\0 silly string"; + bars_ExpectAndReturn((char*)retval); + foos_Expect("This is a\0 wacky string"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, finding failures' + :code: | + test() + { + const char* retval = "This is a silly string"; + bars_ExpectAndReturn((char*)retval); + foos_Expect("This is a wacky string"); + + function_c(); + } + + - :pass: TRUE + :should: 'handle creating array expects when we have mixed arguments for single object' + :code: | + test() + { + int expect_list[] = { 1, 9 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectAndReturn(6, expect_list, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: FALSE + :should: 'handle creating array expects when we have mixed arguments and handle failures for single object' + :code: | + test() + { + int expect_list[] = { 9, 1 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectAndReturn(6, expect_list, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'handle creating array expects when we have mixed arguments for multiple objects' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: FALSE + :should: 'handle creating array expects when we have mixed arguments and handle failures for multiple objects' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectWithArrayAndReturn(6, expect_list, 5, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'handle an exception being caught' + :code: | + test() + { + const char* retval = "This is a\0 silly string"; + bars_ExpectAndReturn((char*)retval); + foos_ExpectAndThrow("This is a\0 wacky string", 55); + foos_Expect("err"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle an exception being caught but still catch following errors' + :code: | + test() + { + const char* retval = "This is a\0 silly string"; + bars_ExpectAndReturn((char*)retval); + foos_ExpectAndThrow("This is a\0 wacky string", 55); + foos_Expect("wrong error"); + + function_c(); + } + + - :pass: FALSE + :should: 'fail strict ordering problems even though we would otherwise have passed' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + no_pointers_Expect(1, "silly"); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'that we can properly ignore last function but the other will work properly' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + no_pointers_Ignore(); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'that we can properly ignore first function but the other will work properly' + :code: | + test() + { + mixed_IgnoreAndReturn(13); + no_pointers_Expect(1, "silly"); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'that we just have to ignore a call once because we are not counting calls' + :code: | + test() + { + foos_Ignore(); + + function_e(); + } + + - :pass: TRUE + :should: 'that we can use a callback and an expect' + :code: | + test() + { + POINT_T pt1 = {2, 3}; + POINT_T pt2 = {2, 3}; + bar_ExpectAndReturn(&pt1); + foo_Expect(&pt2); + foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback); + + function_a(); + } + + - :pass: FALSE + :should: 'that we can fail even when using a callback if we want to expect call but did not and we are checking that' + :code: | + test() + { + POINT_T pt = {2, 3}; + bar_ExpectAndReturn(&pt); + foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback); + + function_a(); + } + + - :pass: FALSE + :should: 'that we can fail even when using a callback if args are wrong and we are checking those' + :code: | + test() + { + POINT_T pt1 = {2, 3}; + POINT_T pt2 = {1, 3}; + bar_ExpectAndReturn(&pt1); + foo_Expect(&pt2); + foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback); + + function_a(); + } + + - :pass: FALSE + :should: 'that we can fail from the callback itself' + :code: | + test() + { + POINT_T pt = {3, 3}; + bar_ExpectAndReturn(&pt); + foo_Expect(&pt); + foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback); + + function_a(); + } + + - :pass: TRUE + :should: 'that a callback return value overrides the one from ExpectAndReturn' + :code: | + test() + { + int b = 2; + POINT_T pt1 = {3, 4}; + bar_ExpectAndReturn(&pt1); + mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback); + mixed_ExpectAndReturn(1,&b,3,100); + + TEST_ASSERT_EQUAL(8, function_f()); + } + + - :pass: TRUE + :should: 'that a callback return value overrides the one from ExpectAndReturn AND ReturnThruPtr still works' + :code: | + test() + { + int b_in = 2; + int b_out = 3; + POINT_T pt1 = {3, 4}; + bar_ExpectAndReturn(&pt1); + mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback); + mixed_ExpectAndReturn(1,&b_in,3,100); + mixed_ReturnThruPtr_b(&b_out); + + TEST_ASSERT_EQUAL(9, function_f()); // (a=1, bin=2, c=pt.x=3, bout=3, sum=9) + } + + - :pass: TRUE + :should: 'that a callback return value overrides the one from ExpectAnyArgs' + :code: | + test() + { + POINT_T pt1 = {5, 4}; + bar_ExpectAndReturn(&pt1); + mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback); + mixed_ExpectAnyArgsAndReturn(100); + + TEST_ASSERT_EQUAL(10, function_f()); // (a=1, bin=2, c=pt.x=5, bout=2, sum=10) + } + + - :pass: TRUE + :should: 'that a callback return value overrides the one from ExpectAnyArgs AND ReturnThruPtr still works' + :code: | + test() + { + int b_out = 3; + POINT_T pt1 = {5, 4}; + bar_ExpectAndReturn(&pt1); + mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback); + mixed_ExpectAnyArgsAndReturn(100); + mixed_ReturnThruPtr_b(&b_out); + + TEST_ASSERT_EQUAL(11, function_f()); // (a=1, bin=2, c=pt.x=5, bout=3, sum=11) + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/array_and_pointer_handling.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/array_and_pointer_handling.yml new file mode 100644 index 000000000..ce8928741 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/array_and_pointer_handling.yml @@ -0,0 +1,446 @@ +--- +:cmock: + :when_ptr: :smart + :plugins: + - :array + +:systest: + :types: | + typedef struct _POINT_T { + int x; + int y; + } POINT_T; + #define ARRAY_A_SIZE (5) + + :mockable: | + void foo(POINT_T* a); + POINT_T* bar(void); + void fooa(POINT_T a[ARRAY_A_SIZE+1-1]); + void foos(const char * a); + const char * bars(void); + void no_pointers(int a, const char* b); + int mixed(int a, int* b, int c); + void potential_packing_problem(short *a); + void voidpointerfunc(void* a); + + :source: + :header: | + void function_a(void); + void function_b(void); + void function_c(void); + int function_d(void); + void function_e(void); + void function_f(void); + + :code: | + void function_a(void) + { + foo(bar()); + } + + void function_b(void) { + fooa(bar()); + } + + void function_c(void) { + foos(bars()); + } + + int function_d(void) { + int test_list[] = { 1, 2, 3, 4, 5 }; + no_pointers(1, "silly"); + return mixed(6, test_list, 7); + } + + void function_e(void) { + short test_list[] = {-1, -2, -3, -4}; + potential_packing_problem(&test_list[1]); + } + + void function_f(void) { + char arg[6] = "hello"; + voidpointerfunc(arg); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle the situation where we pass nulls to pointers' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we expected nulls to pointers but did not get that' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we did not expect nulls to pointers but got null' + :code: | + test() + { + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(NULL); + foo_Expect(&ex); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where it falls back to pointers because you asked it to compare 0 elements' + :code: | + test() + { + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&ex); + foo_ExpectWithArray(&ex, 0); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where it fails because you asked it to compare zero elements and the pointers do not match' + :code: | + test() + { + POINT_T ex = {1, 2}; + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 0); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single object with expect' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(&ex); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_Expect(&ex); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single object with expect and use array handler' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 1); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and use array handler and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_ExpectWithArray(&ex, 1); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass multiple objects with expect and use array handler' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 4}, {5, 6}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong at start' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{9, 2}, {3, 4}, {5, 6}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong at end' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 4}, {5, 9}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong in middle' + :code: | + test() + { + POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}}; + POINT_T ex[] = {{1, 2}, {3, 9}, {5, 6}}; + bar_ExpectAndReturn(pt); + foo_ExpectWithArray(ex, 3); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass nulls to pointers and fail' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass nulls to arrays' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + fooa_Expect(NULL); + + function_b(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single array element with expect' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + fooa_Expect(&ex); + + function_b(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single array element with expect and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + fooa_Expect(&ex); + + function_b(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass nulls to arrays and fail' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + fooa_Expect(NULL); + + function_b(); + } + + - :pass: TRUE + :should: 'handle standard c string as null terminated on not do crappy memory compares of a byte, passing' + :code: | + test() + { + const char* retval = "This is a\0 silly string"; + bars_ExpectAndReturn((char*)retval); + foos_Expect("This is a\0 wacky string"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle standard c string as null terminated on not do crappy memory compares of a byte, finding failures' + :code: | + test() + { + const char* retval = "This is a silly string"; + bars_ExpectAndReturn((char*)retval); + foos_Expect("This is a wacky string"); + + function_c(); + } + + - :pass: TRUE + :should: 'handle creating array expects when we have mixed arguments for single object' + :code: | + test() + { + int expect_list[] = { 1, 9 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectAndReturn(6, expect_list, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: FALSE + :should: 'handle creating array expects when we have mixed arguments and handle failures for single object' + :code: | + test() + { + int expect_list[] = { 9, 1 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectAndReturn(6, expect_list, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'handle creating array expects when we have mixed arguments for multiple objects' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: FALSE + :should: 'handle creating array expects when we have mixed arguments and handle failures for multiple objects' + :code: | + test() + { + int expect_list[] = { 1, 2, 3, 4, 6 }; + no_pointers_Expect(1, "silly"); + mixed_ExpectWithArrayAndReturn(6, expect_list, 5, 7, 13); + + TEST_ASSERT_EQUAL(13, function_d()); + } + + - :pass: TRUE + :should: 'handle a passing version of a potential packing problem (particularly try with ARM simulators)' + :code: | + test() + { + short expect_list[] = { -2, -3, -4 }; + potential_packing_problem_ExpectWithArray(expect_list, 3); + + function_e(); + } + + - :pass: FALSE + :should: 'handle a failing version of a potential packing problem (particularly try with ARM simulators)' + :code: | + test() + { + short expect_list[] = { -2, -3, 4 }; + potential_packing_problem_ExpectWithArray(expect_list, 3); + + function_e(); + } + + - :pass: TRUE + :should: 'handle a void pointers as arguments and still be able to use the array plugin' + :code: | + test() + { + char expect_list[6] = "hello"; + voidpointerfunc_ExpectWithArray(expect_list, 5); + + function_f(); + } + + - :pass: TRUE + :should: 'handle a void pointers as arguments and still be able to use the array plugin (short)' + :code: | + test() + { + char expect_list[6] = "help!"; + voidpointerfunc_ExpectWithArray(expect_list, 3); + + function_f(); + } + + - :pass: FALSE + :should: 'handle a void pointers as arguments and still be able to use the array plugin (fail)' + :code: | + test() + { + char expect_list[6] = "help!"; + voidpointerfunc_ExpectWithArray(expect_list, 4); + + function_f(); + } + + - :pass: TRUE + :should: 'handle a void pointer with a standard expectation (pass)' + :code: | + test() + { + char expect_list[2] = "h"; + voidpointerfunc_Expect(expect_list); + + function_f(); + } + + - :pass: FALSE + :should: 'handle a void pointer with a standard expectation (fail)' + :code: | + test() + { + char expect_list[2] = "g"; + voidpointerfunc_Expect(expect_list); + + function_f(); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/basic_expect_and_return.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/basic_expect_and_return.yml new file mode 100644 index 000000000..38d4edff4 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/basic_expect_and_return.yml @@ -0,0 +1,124 @@ +--- +:cmock: + :plugins: + - # none + +:systest: + :types: | + #define UINT32 unsigned int + + typedef signed int custom_type; + + :mockable: | + UINT32 foo(custom_type a); + UINT32 bar(custom_type b); + UINT32 foo_varargs(custom_type a, ...); + const char* foo_char_strings(const char a[], const char* b); + + :source: + :header: | + UINT32 function_a(int a, int b); + void function_b(void); + UINT32 function_c(int a); + const char* function_d(const char a[], const char* b); + + :code: | + UINT32 function_a(int a, int b) + { + return foo((custom_type)a) + bar((custom_type)b); + } + + void function_b(void) { } + + UINT32 function_c(int a) + { + return foo_varargs((custom_type)a, "ignored", 5); + } + + const char* function_d(const char a[], const char* b) + { + return foo_char_strings(a, b); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully exercise two simple ExpectAndReturn mock calls' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because bar() is not called but is expected' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because bar() is called but is not expected' + :code: | + test() + { + bar_ExpectAndReturn((custom_type)1, 10); + function_b(); + } + + - :pass: TRUE + :should: 'consume var args passed to mocked function' + :code: | + test() + { + foo_varargs_ExpectAndReturn((custom_type)3, 10); + TEST_ASSERT_EQUAL(10, function_c(3)); + } + + - :pass: TRUE + :should: 'handle char strings' + :code: | + test() + { + const char* retval = "moe"; + foo_char_strings_ExpectAndReturn("larry", "curly", (char*)retval); + TEST_ASSERT_EQUAL_STRING("moe", function_d("larry", "curly")); + } + + - :pass: TRUE + :should: 'successfully exercise multiple cycles of expecting and mocking and pass' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + + foo_ExpectAndReturn((custom_type)3, 30); + bar_ExpectAndReturn((custom_type)4, 40); + TEST_ASSERT_EQUAL(70, function_a(3, 4)); + } + + - :pass: FALSE + :should: 'successfully exercise multiple cycles of expecting and mocking and fail' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + + foo_ExpectAndReturn((custom_type)3, 30); + bar_ExpectAndReturn((custom_type)4, 40); + TEST_ASSERT_EQUAL(70, function_a(3, 5)); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/const_primitives_handling.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/const_primitives_handling.yml new file mode 100644 index 000000000..2fc1b2132 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/const_primitives_handling.yml @@ -0,0 +1,87 @@ +--- +:cmock: + :plugins: + - # none + +:systest: + :types: | + + :mockable: | + // no argument names + void foo(char const*, char* const, const char*); + + // argument names + void bar(char const* param1, char* const param2, const char* param3); + + :source: + :header: | + void exercise_const1(char const* param1, char* const param2, const char* param3); + void exercise_const2(char const* param1, char* const param2, const char* param3); + + :code: | + char value1 = '1'; + char value2 = '2'; + + const char* A = &value1; + char* const B = &value2; + const char* C = "C"; + const char* D = "D"; + + void exercise_const1(char const* param1, char* const param2, const char* param3) + { + foo(param1, param2, param3); + } + + void exercise_const2(char const* param1, char* const param2, const char* param3) + { + bar(param1, param2, param3); + } + + :tests: + :common: | + extern const char* A; + extern char* const B; + extern const char* C; + extern const char* D; + + void setUp(void) {} + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'successfully pass several const parameters' + :code: | + test() + { + foo_Expect( A, B, C ); + exercise_const1( A, B, C ); + } + + - :pass: FALSE + :should: 'should fail upon wrong const arguments passed' + :code: | + test() + { + foo_Expect( A, B, C ); + exercise_const1( (const char*)B, (char * const)A, C ); + } + + - :pass: FALSE + :should: 'should fail upon wrong const arguments passed' + :code: | + test() + { + foo_Expect( A, B, C ); + exercise_const1( A, B, D ); + } + + - :pass: FALSE + :should: 'should fail upon wrong const arguments passed' + :code: | + test() + { + bar_Expect( A, B, C ); + exercise_const2( A, (char * const)C, (const char *)B ); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/doesnt_leave_details_behind.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/doesnt_leave_details_behind.yml new file mode 100644 index 000000000..a077839e1 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/doesnt_leave_details_behind.yml @@ -0,0 +1,308 @@ +--- +:cmock: + :enforce_strict_ordering: 1 + :plugins: + - :array + - :cexception + - :ignore + - :callback + - :return_thru_ptr + - :ignore_arg + - :expect_any_args + :callback_after_arg_check: false + :callback_include_count: false + :treat_externs: :include + +:systest: + :types: | + typedef struct _POINT_T { + int x; + int y; + } POINT_T; + + :mockable: | + #include "CException.h" + extern void foo(POINT_T* a); + POINT_T* bar(void); + void no_args(void); + + :source: + :header: | + #include "CException.h" + void function_a(void); + int function_b(void); + + :code: | + void function_a(void) + { + foo(bar()); + no_args(); + } + + int function_b(void) + { + POINT_T pt = { 1, 2 }; + foo(&pt); + return (pt.x + pt.y); + } + + :tests: + :common: | + #include "CException.h" + void setUp(void) {} + void tearDown(void) {} + void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); } + + :units: + - :pass: TRUE + :should: 'just pass if we do not insert anything ugly into it' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + no_args_Expect(); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after an expect and return' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + foo_Expect(NULL); + no_args_Expect(); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after an expect' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + no_args_Expect(); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after throw expectation' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + CEXCEPTION_T e; + + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + no_args_ExpectAndThrow(5); + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + + Try { function_a(); } Catch(e) {} + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after a mock call' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + no_args_Expect(); + + function_a(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after throw' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + CEXCEPTION_T e; + + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + no_args_ExpectAndThrow(5); + + Try { function_a(); } Catch(e) {} + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after ignore' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + no_args_Ignore(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after ignored mock' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + no_args_Ignore(); + + function_a(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after callback setup' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + POINT_T pt = { 2, 2 }; + bar_ExpectAndReturn(&pt); + foo_StubWithCallback(my_foo_callback); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + + no_args_Expect(); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after mock with callback' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + POINT_T pt = { 2, 2 }; + bar_ExpectAndReturn(&pt); + foo_StubWithCallback(my_foo_callback); + no_args_Expect(); + + function_a(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after expect any args' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + POINT_T pt = { 2, 2 }; + bar_ExpectAndReturn(&pt); + foo_ExpectAnyArgs(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + + no_args_Expect(); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after mock which expected any args' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + POINT_T pt = { 2, 2 }; + bar_ExpectAndReturn(&pt); + foo_ExpectAnyArgs(); + no_args_Expect(); + + function_a(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after ignored arg' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + POINT_T pt = { 2, 2 }; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + foo_IgnoreArg_a(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + + no_args_Expect(); + + function_a(); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after mock which ignored an arg' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + POINT_T pt = { 2, 2 }; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + foo_IgnoreArg_a(); + no_args_Expect(); + + function_a(); + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after mock which threw a CException' + :verify_error: 'FAIL: Expected 1 Was 2. CustomFail' + :code: | + test() + { + CEXCEPTION_T e; + bar_ExpectAndThrow(0x12); + + Try { + function_a(); + } + Catch(e) {} + + TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail"); + } + + - :pass: FALSE + :should: 'not contain mock details in failed assertion after mock which used a return thru ptr' + :verify_error: 'FAIL: Expected 3 Was 7. CustomFail' + :code: | + test() + { + POINT_T pt1 = { 1, 2 }; + POINT_T pt2 = { 3, 4 }; + + foo_Expect(&pt1); + foo_ReturnThruPtr_a(&pt2); + + TEST_ASSERT_EQUAL_INT_MESSAGE(3, function_b(), "CustomFail"); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/enforce_strict_ordering.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/enforce_strict_ordering.yml new file mode 100644 index 000000000..7d777a4ec --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/enforce_strict_ordering.yml @@ -0,0 +1,247 @@ +--- +:cmock: + :enforce_strict_ordering: 1 + :plugins: + - :ignore + - :cexception + +:systest: + :types: | + #define UINT32 unsigned int + + typedef signed int custom_type; + + :mockable: | + #include "CException.h" + UINT32 foo(custom_type a); + UINT32 bar(custom_type b); + void baz(custom_type c); + + :source: + :header: | + #include "CException.h" + UINT32 function_a(int a, int b); + void function_b(void); + void function_c(void); + void function_d(void); + + :code: | + UINT32 function_a(int a, int b) + { + return foo((custom_type)a) + bar((custom_type)b); + } + + void function_b(void) + { + baz((custom_type)1); + foo((custom_type)2); + bar((custom_type)3); + baz((custom_type)4); + foo((custom_type)5); + bar((custom_type)6); + baz((custom_type)7); + } + + void function_c(void) + { + foo((custom_type)1); + foo((custom_type)2); + bar((custom_type)3); + bar((custom_type)4); + foo((custom_type)5); + } + + void function_d(void) + { + CEXCEPTION_T e; + Try + { + foo((custom_type)1); + } + Catch(e) {} + Try + { + bar((custom_type)2); + } + Catch(e) {} + Try + { + foo((custom_type)3); + } + Catch(e) {} + } + + :tests: + :common: | + #include "CException.h" + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully exercise two simple ExpectAndReturn mock calls' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because bar() is called but is not expected' + :verify_error: 'Called more times than expected' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because bar() is called twice but is expected once' + :verify_error: 'Called fewer times than expected' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + bar_ExpectAndReturn((custom_type)3, 30); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because bar and foo called in reverse order' + :verify_error: 'Called earlier than expected' + :code: | + test() + { + bar_ExpectAndReturn((custom_type)2, 20); + foo_ExpectAndReturn((custom_type)1, 10); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: TRUE + :should: 'pass because bar and foo called in order with multiple params' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)2, 10); + bar_ExpectAndReturn((custom_type)3, 20); + bar_ExpectAndReturn((custom_type)4, 10); + foo_ExpectAndReturn((custom_type)5, 10); + function_c(); + } + + - :pass: FALSE + :should: 'fail because bar and foo called out of order at end' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)2, 10); + bar_ExpectAndReturn((custom_type)3, 20); + foo_ExpectAndReturn((custom_type)5, 10); + bar_ExpectAndReturn((custom_type)4, 10); + function_c(); + } + + - :pass: FALSE + :should: 'fail because bar and foo called out of order at start' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)2, 10); + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)3, 20); + bar_ExpectAndReturn((custom_type)4, 10); + foo_ExpectAndReturn((custom_type)5, 10); + function_c(); + } + + - :pass: TRUE + :should: 'pass because we are properly ignoring baz' + :code: | + test() + { + baz_Ignore(); + foo_ExpectAndReturn((custom_type)2, 10); + bar_ExpectAndReturn((custom_type)3, 20); + foo_ExpectAndReturn((custom_type)5, 10); + bar_ExpectAndReturn((custom_type)6, 10); + function_b(); + } + + - :pass: FALSE + :should: 'fail because bar and foo out of order, even though baz is ignored' + :code: | + test() + { + baz_Ignore(); + foo_ExpectAndReturn((custom_type)2, 10); + foo_ExpectAndReturn((custom_type)5, 10); + bar_ExpectAndReturn((custom_type)3, 20); + bar_ExpectAndReturn((custom_type)6, 10); + function_b(); + } + + - :pass: TRUE + :should: 'pass when using cexception, as long as the order is right' + :code: | + test() + { + foo_ExpectAndThrow((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + foo_ExpectAndReturn((custom_type)3, 10); + function_d(); + } + + - :pass: FALSE + :should: 'fail when an throw call is made out of order' + :code: | + test() + { + bar_ExpectAndReturn((custom_type)2, 20); + foo_ExpectAndThrow((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)3, 10); + function_d(); + } + + - :pass: TRUE + :should: 'successfully handle back to back ExpectAndReturn setup and mock calls' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + + foo_ExpectAndReturn((custom_type)3, 30); + bar_ExpectAndReturn((custom_type)4, 40); + TEST_ASSERT_EQUAL(70, function_a(3, 4)); + + foo_ExpectAndReturn((custom_type)1, 50); + bar_ExpectAndReturn((custom_type)9, 60); + TEST_ASSERT_EQUAL(110, function_a(1, 9)); + } + + - :pass: FALSE + :should: 'successfully catch errors during back to back ExpectAndReturn setup and mock calls' + :verify_error: 'Called earlier than expected' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + bar_ExpectAndReturn((custom_type)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + + foo_ExpectAndReturn((custom_type)3, 30); + bar_ExpectAndReturn((custom_type)4, 40); + TEST_ASSERT_EQUAL(70, function_a(3, 4)); + + bar_ExpectAndReturn((custom_type)9, 60); + foo_ExpectAndReturn((custom_type)1, 50); + TEST_ASSERT_EQUAL(110, function_a(1, 9)); + } +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_return_custom_types.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_return_custom_types.yml new file mode 100644 index 000000000..5d9d44678 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_return_custom_types.yml @@ -0,0 +1,108 @@ +--- +:cmock: + :plugins: + - # none + :memcmp_if_unknown: false + :unity_helper_path: expect_and_return_custom_types_unity_helper.h + +:systest: + :types: | + typedef struct _EXAMPLE_STRUCT_T { int x; int y; } EXAMPLE_STRUCT_T; + + :mockable: | + EXAMPLE_STRUCT_T foo(EXAMPLE_STRUCT_T a); + + :source: + :header: | + EXAMPLE_STRUCT_T function_a(EXAMPLE_STRUCT_T a, EXAMPLE_STRUCT_T b); + EXAMPLE_STRUCT_T function_b(EXAMPLE_STRUCT_T a, EXAMPLE_STRUCT_T b); + + :code: | + EXAMPLE_STRUCT_T function_a(EXAMPLE_STRUCT_T a, EXAMPLE_STRUCT_T b) + { + EXAMPLE_STRUCT_T retval = foo(a); + retval.x += b.x; + retval.y += b.y; + return retval; + } + + EXAMPLE_STRUCT_T function_b(EXAMPLE_STRUCT_T a, EXAMPLE_STRUCT_T b) + { + EXAMPLE_STRUCT_T retval = foo(b); + retval.x *= a.x; + retval.y *= a.y; + return retval; + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully exercise simple ExpectAndReturn mock calls' + :code: | + test() + { + EXAMPLE_STRUCT_T c = {1,2}; + EXAMPLE_STRUCT_T d = {3,4}; + EXAMPLE_STRUCT_T e = {2,4}; + EXAMPLE_STRUCT_T f = {5,8}; + foo_ExpectAndReturn(c, e); + TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(f, function_a(c,d)); + } + + - :pass: FALSE + :should: 'fail because it is expecting to call foo with c not d' + :code: | + test() + { + EXAMPLE_STRUCT_T c = {1,2}; + EXAMPLE_STRUCT_T d = {3,4}; + EXAMPLE_STRUCT_T e = {2,4}; + EXAMPLE_STRUCT_T f = {5,8}; + foo_ExpectAndReturn(d, e); + TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(f, function_a(c,d)); + } + + - :pass: TRUE + :should: 'successfully exercise simple ExpectAndReturn mock calls on other function' + :code: | + test() + { + EXAMPLE_STRUCT_T c = {1,2}; + EXAMPLE_STRUCT_T d = {3,4}; + EXAMPLE_STRUCT_T e = {2,4}; + EXAMPLE_STRUCT_T f = {2,8}; + foo_ExpectAndReturn(d, e); + TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(f, function_b(c,d)); + } + + - :pass: FALSE + :should: 'fail because it is expecting to call foo with d not c' + :code: | + test() + { + EXAMPLE_STRUCT_T c = {1,2}; + EXAMPLE_STRUCT_T d = {3,4}; + EXAMPLE_STRUCT_T e = {2,4}; + EXAMPLE_STRUCT_T f = {2,8}; + foo_ExpectAndReturn(c, e); + TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(f, function_b(c,d)); + } + + :unity_helper: + :header: | + void AssertEqualExampleStruct(EXAMPLE_STRUCT_T expected, EXAMPLE_STRUCT_T actual, unsigned short line); + #define UNITY_TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual, line, message) {AssertEqualExampleStruct(expected, actual, (unsigned short)line);} + #define TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual) UNITY_TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual, __LINE__, NULL); + + :code: | + void AssertEqualExampleStruct(EXAMPLE_STRUCT_T expected, EXAMPLE_STRUCT_T actual, unsigned short line) + { + UNITY_TEST_ASSERT_EQUAL_INT(expected.x, actual.x, line, "Example Struct Failed For Field x"); + UNITY_TEST_ASSERT_EQUAL_INT(expected.y, actual.y, line, "Example Struct Failed For Field y"); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_return_treat_as.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_return_treat_as.yml new file mode 100644 index 000000000..2c24f35d8 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_return_treat_as.yml @@ -0,0 +1,173 @@ +--- +:cmock: + :plugins: + - # none + :treat_as: + MY_STRING: STRING + MY_INT: INT + PTR_INT: INT* + MY_HEX: HEX32 + +:systest: + :types: | + typedef const char* MY_STRING; + typedef int MY_INT; + typedef unsigned int MY_HEX; + typedef int* PTR_INT; + + :mockable: | + MY_INT foo(MY_HEX a); + MY_INT bar(MY_HEX b); + MY_STRING foo_char_strings(MY_STRING a, MY_STRING b); + float float_adder(float a, float b); + MY_INT* pointer_foo(MY_HEX* a); + void pointer_bar(PTR_INT a); + + :source: + :header: | + MY_INT function_a(MY_INT a, MY_INT b); + MY_STRING function_b(MY_STRING a, MY_STRING b); + float function_c(float a, float b); + MY_INT function_d(MY_HEX a); + void function_e(PTR_INT a); + + :code: | + MY_INT function_a(MY_INT a, MY_INT b) + { + return foo((MY_HEX)a) + bar((MY_HEX)b); + } + + MY_STRING function_b(MY_STRING a, MY_STRING b) + { + return foo_char_strings(a, b); + } + + float function_c(float a, float b) + { + return float_adder(b, a); + } + + MY_INT function_d(MY_HEX a) + { + MY_HEX b = a; + MY_INT* c = pointer_foo(&b); + return *c; + } + + void function_e(PTR_INT a) + { + pointer_bar(a); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully exercise two simple ExpectAndReturn mock calls' + :code: | + test() + { + foo_ExpectAndReturn((MY_HEX)1, 10); + bar_ExpectAndReturn((MY_HEX)2, 20); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because bar() is expected but not called' + :code: | + test() + { + foo_ExpectAndReturn((MY_HEX)1, 10); + TEST_ASSERT_EQUAL(30, function_a(1, 2)); + } + + - :pass: FALSE + :should: 'fail because foo_char_strings() is called but is not expected' + :code: | + test() + { + foo_char_strings_ExpectAndReturn((MY_STRING)"jello", (MY_STRING)"jiggle", (MY_STRING)"boing!"); + function_a(1,2); + } + + - :pass: TRUE + :should: 'handle char strings' + :code: | + test() + { + foo_char_strings_ExpectAndReturn((MY_STRING)"jello", (MY_STRING)"jiggle", (MY_STRING)"boing!"); + TEST_ASSERT_EQUAL_STRING("boing!", function_b((MY_STRING)"jello", (MY_STRING)"jiggle")); + } + + - :pass: TRUE + :should: 'handle floating point numbers with Unity support: pass' + :code: | + test() + { + float_adder_ExpectAndReturn(1.2345f, 6.7890f, 8.0235f); + TEST_ASSERT_EQUAL_FLOAT(8.0235f, function_c(6.7890f, 1.2345f)); + } + + - :pass: FALSE + :should: 'handle floating point numbers with Unity support: fail' + :code: | + test() + { + float_adder_ExpectAndReturn(1.2345f, 6.7892f, 8.0235f); + TEST_ASSERT_EQUAL_FLOAT(8.0235f, function_c(6.7890f, 1.2345f)); + } + + - :pass: TRUE + :should: 'handle pointers to treat_as values just as cleanly as the treat_as itself for passes' + :code: | + test() + { + MY_HEX TestHex = (MY_HEX)45; + MY_INT TestInt = (MY_INT)33; + pointer_foo_ExpectAndReturn(&TestHex, &TestInt); + TEST_ASSERT_EQUAL_INT(33, function_d(45)); + } + + - :pass: FALSE + :should: 'handle pointers to treat_as values just as cleanly as the treat_as itself for failures' + :verify_error: 'Element 0 Expected 0x0000002D Was 0x0000002B' + :code: | + test() + { + MY_HEX TestHex = (MY_HEX)45; + MY_INT TestInt = (MY_INT)33; + pointer_foo_ExpectAndReturn(&TestHex, &TestInt); + TEST_ASSERT_EQUAL_INT(33, function_d(43)); + } + + - :pass: TRUE + :should: 'handle treat_as values containing pointers for passes' + :code: | + test() + { + MY_INT ExpInt = (MY_INT)33; + PTR_INT ExpPtr = (PTR_INT)(&ExpInt); + MY_INT ActInt = (MY_INT)33; + PTR_INT ActPtr = (PTR_INT)(&ActInt); + pointer_bar_Expect(ExpPtr); + function_e(ActPtr); + } + + - :pass: FALSE + :should: 'handle treat_as values containing pointers for failures' + :verify_error: 'Element 0 Expected 33 Was 45' + :code: | + test() + { + MY_INT ExpInt = (MY_INT)33; + PTR_INT ExpPtr = (PTR_INT)(&ExpInt); + MY_INT ActInt = (MY_INT)45; + PTR_INT ActPtr = (PTR_INT)(&ActInt); + pointer_bar_Expect(ExpPtr); + function_e(ActPtr); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_throw.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_throw.yml new file mode 100644 index 000000000..c22524c64 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_and_throw.yml @@ -0,0 +1,170 @@ +--- +:cmock: + :plugins: + - :cexception + +:systest: + :types: | + #define UINT32 unsigned int + typedef signed int custom_type; + + :mockable: | + #include "CException.h" + UINT32 foo(custom_type a); + UINT32 bar(custom_type b); + UINT32 foo_varargs(custom_type a, ...); + + :source: + :header: | + #include "CException.h" + UINT32 function_a(int a); + void function_b(char a); + + :code: | + UINT32 function_a(int a) + { + UINT32 r = 0; + CEXCEPTION_T e; + + Try + { + r = (UINT32)foo((custom_type)a); + } + Catch(e) + { + r = (UINT32)e*2; + } + return r; + } + + void function_b(char a) + { + if (a) + { + Throw((CEXCEPTION_T)a); + } + } + + :tests: + :common: | + #include "CException.h" + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully exercise a simple ExpectAndReturn mock calls' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + TEST_ASSERT_EQUAL(10, function_a(1)); + } + + - :pass: TRUE + :should: 'successfully throw an error on first call' + :code: | + test() + { + foo_ExpectAndThrow((custom_type)1, 55); + TEST_ASSERT_EQUAL(110, function_a(1)); + } + + - :pass: TRUE + :should: 'successfully throw an error on later calls' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)2, 20); + foo_ExpectAndThrow((custom_type)3, 15); + foo_ExpectAndReturn((custom_type)4, 40); + TEST_ASSERT_EQUAL(10, function_a(1)); + TEST_ASSERT_EQUAL(20, function_a(2)); + TEST_ASSERT_EQUAL(30, function_a(3)); + TEST_ASSERT_EQUAL(40, function_a(4)); + } + + - :pass: TRUE + :should: 'pass because we nothing happens' + :code: | + test() + { + function_b(0); + } + + - :pass: FALSE + :should: 'fail because we did not expect function B to throw' + :code: | + test() + { + function_b(1); + } + + - :pass: TRUE + :should: 'fail because we expect function B to throw' + :code: | + test() + { + CEXCEPTION_T e; + Try + { + function_b(3); + TEST_FAIL_MESSAGE("Should Have Thrown"); + } + Catch(e) + { + TEST_ASSERT_EQUAL(3, e); + } + } + + - :pass: TRUE + :should: 'successfully throw an error on consecutive calls' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)1, 20); + foo_ExpectAndThrow((custom_type)1, 15); + foo_ExpectAndThrow((custom_type)3, 40); + TEST_ASSERT_EQUAL(10, function_a(1)); + TEST_ASSERT_EQUAL(20, function_a(1)); + TEST_ASSERT_EQUAL(30, function_a(1)); + TEST_ASSERT_EQUAL(80, function_a(3)); + } + + - :pass: TRUE + :should: 'successfully throw an error on later calls and after a previous mock call' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)1, 20); + foo_ExpectAndThrow((custom_type)1, 15); + TEST_ASSERT_EQUAL(10, function_a(1)); + TEST_ASSERT_EQUAL(20, function_a(1)); + TEST_ASSERT_EQUAL(30, function_a(1)); + + foo_ExpectAndReturn((custom_type)2, 20); + foo_ExpectAndThrow((custom_type)3, 40); + TEST_ASSERT_EQUAL(20, function_a(2)); + TEST_ASSERT_EQUAL(80, function_a(3)); + } + + - :pass: TRUE + :should: 'successfully throw an error if expects and mocks called before it' + :code: | + test() + { + foo_ExpectAndReturn((custom_type)1, 10); + foo_ExpectAndReturn((custom_type)1, 20); + TEST_ASSERT_EQUAL(10, function_a(1)); + TEST_ASSERT_EQUAL(20, function_a(1)); + + foo_ExpectAndReturn((custom_type)2, 20); + foo_ExpectAndThrow((custom_type)3, 40); + TEST_ASSERT_EQUAL(20, function_a(2)); + TEST_ASSERT_EQUAL(80, function_a(3)); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_any_args.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_any_args.yml new file mode 100644 index 000000000..06eb6bb27 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/expect_any_args.yml @@ -0,0 +1,238 @@ +--- +:cmock: + :plugins: + - 'expect_any_args' + +:systest: + :types: | + + :mockable: | + int foo(int a); + void bar(int b); + + :source: + :header: | + int function(int a, int b, int c); + void func_b(int a); + :code: | + int function(int a, int b, int c) + { + bar(b); + return foo(a) + foo(b) + foo(c); + } + void func_b(int a) + { + bar(a); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'successfully exercise simple ExpectAndReturn mock calls' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 10); + foo_ExpectAndReturn(2, 20); + foo_ExpectAndReturn(3, 30); + TEST_ASSERT_EQUAL(60, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'ignore foo() call details' + :code: | + test() + { + bar_Expect(4); + foo_ExpectAnyArgsAndReturn(10); + foo_ExpectAnyArgsAndReturn(40); + foo_ExpectAnyArgsAndReturn(80); + TEST_ASSERT_EQUAL(130, function(3, 4, 3)); + } + + - :pass: FALSE + :should: 'ignore foo() call details and notice if we called foo() more times than expected' + :code: | + test() + { + bar_Expect(4); + foo_ExpectAnyArgsAndReturn(20); + foo_ExpectAnyArgsAndReturn(30); + TEST_ASSERT_EQUAL(50, function(3, 4, 9)); + } + + - :pass: FALSE + :should: 'ignore foo() call details and notice if we called foo() fewer times than expected' + :code: | + test() + { + bar_Expect(4); + foo_ExpectAnyArgsAndReturn(20); + foo_ExpectAnyArgsAndReturn(10); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAnyArgsAndReturn(60); + TEST_ASSERT_EQUAL(70, function(3, 4, 9)); + } + + - :pass: TRUE + :should: 'ignore bar() and foo() call details' + :code: | + test() + { + bar_ExpectAnyArgs(); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAnyArgsAndReturn(50); + TEST_ASSERT_EQUAL(150, function(0, 0, 0)); + } + + - :pass: TRUE + :should: 'be able to handle an expect after ignore calls since we are ignoring args only' + :code: | + test() + { + bar_ExpectAnyArgs(); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAndReturn(3, 50); + TEST_ASSERT_EQUAL(150, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'be able to handle an ignore after an expect call since we are ignoring args only' + :code: | + test() + { + bar_ExpectAnyArgs(); + foo_ExpectAndReturn(1, 50); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAnyArgsAndReturn(50); + TEST_ASSERT_EQUAL(150, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'be able to handle an ignore within expect calls since we are ignoring args only' + :code: | + test() + { + bar_ExpectAnyArgs(); + foo_ExpectAndReturn(1, 50); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAndReturn(3, 50); + TEST_ASSERT_EQUAL(150, function(1, 2, 3)); + } + + - :pass: FALSE + :should: 'be able to detect problems with an expect even when using ignores' + :code: | + test() + { + bar_ExpectAnyArgs(); + foo_ExpectAndReturn(1, 50); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAndReturn(4, 50); + TEST_ASSERT_EQUAL(150, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'be able to handle a lone ExpectAnyArg call' + :code: | + test() + { + bar_ExpectAnyArgs(); + func_b(1); + } + + - :pass: FALSE + :should: 'be able to handle a lone ExpectAnyArg call that does not get called' + :code: | + test() + { + bar_ExpectAnyArgs(); + } + + - :pass: FALSE + :should: 'be able to handle a missing ExpectAnyArg call' + :code: | + test() + { + func_b(1); + } + + - :pass: TRUE + :should: 'ignore foo() calls over multiple mock calls' + :code: | + test() + { + bar_ExpectAnyArgs(); + foo_ExpectAnyArgsAndReturn(50); + foo_ExpectAnyArgsAndReturn(60); + foo_ExpectAnyArgsAndReturn(70); + TEST_ASSERT_EQUAL(180, function(0, 0, 0)); + + bar_ExpectAnyArgs(); + foo_ExpectAnyArgsAndReturn(30); + foo_ExpectAnyArgsAndReturn(80); + foo_ExpectAnyArgsAndReturn(10); + TEST_ASSERT_EQUAL(120, function(0, 0, 0)); + + bar_ExpectAnyArgs(); + foo_ExpectAnyArgsAndReturn(70); + foo_ExpectAnyArgsAndReturn(20); + foo_ExpectAnyArgsAndReturn(20); + TEST_ASSERT_EQUAL(110, function(0, 0, 0)); + } + + - :pass: TRUE + :should: 'have multiple cycles of expects still pass when this plugin enabled' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: FALSE + :should: 'have multiple cycles of expects still fail when this plugin enabled' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(0, 8, 9)); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/fancy_pointer_handling.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/fancy_pointer_handling.yml new file mode 100644 index 000000000..2a47d23f7 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/fancy_pointer_handling.yml @@ -0,0 +1,210 @@ +--- +:cmock: + :plugins: + - # none + :treat_as: + INT_PTR: INT* + +:systest: + :types: | + typedef struct _POINT_T { + int x; + int y; + } POINT_T; + typedef int* INT_PTR; + + :mockable: | + void foo(POINT_T* a); + POINT_T* bar(void); + void fooa(POINT_T a[]); + void foos(const char *a); + const char* bars(void); + INT_PTR zoink(INT_PTR a); + + :source: + :header: | + void function_a(void); + void function_b(void); + void function_c(void); + int function_d(void); + + :code: | + void function_a(void) + { + foo(bar()); + } + + void function_b(void) { + fooa(bar()); + } + + void function_c(void) { + foos(bars()); + } + + int function_d(void) { + int i = 456; + INT_PTR ptr = (INT_PTR)(&i); + return (int)(*(zoink(ptr))); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle the situation where we pass nulls to pointers' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + foo_Expect(NULL); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single object with expect' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(&ex); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single object with expect and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + foo_Expect(&ex); + + function_a(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass nulls to pointers and fail' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + foo_Expect(NULL); + + function_a(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass nulls to arrays' + :code: | + test() + { + bar_ExpectAndReturn(NULL); + fooa_Expect(NULL); + + function_b(); + } + + - :pass: TRUE + :should: 'handle the situation where we pass single array element with expect' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 2}; + bar_ExpectAndReturn(&pt); + fooa_Expect(&ex); + + function_b(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass single array element with expect and it is wrong' + :code: | + test() + { + POINT_T pt = {1, 2}; + POINT_T ex = {1, 3}; + bar_ExpectAndReturn(&pt); + fooa_Expect(&ex); + + function_b(); + } + + - :pass: FALSE + :should: 'handle the situation where we pass nulls to arrays and fail' + :code: | + test() + { + POINT_T pt = {1, 2}; + bar_ExpectAndReturn(&pt); + fooa_Expect(NULL); + + function_b(); + } + + - :pass: TRUE + :should: 'handle standard c string as null terminated on not do crappy memory compares of a byte, passing' + :code: | + test() + { + const char* retval = "This is a\0 silly string"; + bars_ExpectAndReturn((char*)retval); + foos_Expect("This is a\0 wacky string"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle standard c string as null terminated on not do crappy memory compares of a byte, finding failures' + :code: | + test() + { + const char* retval = "This is a silly string"; + bars_ExpectAndReturn((char*)retval); + foos_Expect("This is a wacky string"); + + function_c(); + } + + - :pass: TRUE + :should: 'handle handle typedefs that ARE pointers by using treat_as' + :code: | + test() + { + int e = 456; + int r = 789; + INT_PTR ptr_e = (INT_PTR)(&e); + INT_PTR ptr_r = (INT_PTR)(&r); + + zoink_ExpectAndReturn(ptr_e, ptr_r); + + TEST_ASSERT_EQUAL(r, function_d()); + } + + - :pass: FALSE + :should: 'handle handle typedefs that ARE pointers by using treat_as and catch failures' + :code: | + test() + { + int e = 457; + int r = 789; + INT_PTR ptr_e = (INT_PTR)(&e); + INT_PTR ptr_r = (INT_PTR)(&r); + + zoink_ExpectAndReturn(ptr_e, ptr_r); + + TEST_ASSERT_EQUAL(r, function_d()); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/function_pointer_handling.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/function_pointer_handling.yml new file mode 100644 index 000000000..d286bdb25 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/function_pointer_handling.yml @@ -0,0 +1,83 @@ +--- +:cmock: + :plugins: + - # none + :treat_as: + FUNCTION_T: PTR + +:systest: + :types: | + typedef void (*FUNCTION_T)(void); + + :mockable: | + void takes_function_type( FUNCTION_T myfunc ); + void takes_function_ptr( unsigned int (*func_ptr)(int, char) ); + void takes_function_ptr_shorthand( unsigned int func_ptr(int, char*) ); + void takes_const_function_ptr( unsigned int (* const)(int, char) ); + unsigned short (*returns_function_ptr( const char op_code ))( int, long int ); + + :source: + :header: | + void exercise_function_pointer_param(void); + unsigned short (*exercise_function_pointer_return( const char op_code ))( int, long int ); + + // functions for function pointer tests + unsigned int dummy_function1(int a, char b); + unsigned short dummy_function2(int a, long int b); + + :code: | + /* + * functions used in tests + */ + + unsigned int dummy_function1(int a, char b) + { + // prevent compiler warnings by using everything + return (unsigned int)a + (unsigned int)b; + } + + unsigned short dummy_function2(int a, long int b) + { + // prevent compiler warnings by using everything + return (unsigned short)a + (unsigned short)b; + } + + /* + * functions executed by tests + */ + + void exercise_function_pointer_param(void) + { + takes_function_ptr(dummy_function1); + } + + unsigned short (*exercise_function_pointer_return( const char op_code ))( int, long int ) + { + return returns_function_ptr(op_code); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'expect a function pointer param' + :code: | + test() + { + takes_function_ptr_Expect(dummy_function1); + exercise_function_pointer_param(); + } + + - :pass: TRUE + :should: 'return a function pointer' + :code: | + test() + { + returns_function_ptr_ExpectAndReturn('z', dummy_function2); + TEST_ASSERT_EQUAL_PTR(dummy_function2, exercise_function_pointer_return('z')); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/ignore_and_return.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/ignore_and_return.yml new file mode 100644 index 000000000..17f95beef --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/ignore_and_return.yml @@ -0,0 +1,329 @@ +--- +:cmock: + :plugins: + - 'ignore' + +:systest: + :types: | + + :mockable: | + int foo(int a); + void bar(int b); + + :source: + :header: | + int function(int a, int b, int c); + :code: | + int function(int a, int b, int c) + { + bar(b); + return foo(a) + foo(b) + foo(c); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'successfully exercise simple ExpectAndReturn mock calls' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 10); + foo_ExpectAndReturn(2, 20); + foo_ExpectAndReturn(3, 30); + TEST_ASSERT_EQUAL(60, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'ignore foo() calls' + :code: | + test() + { + bar_Expect(4); + foo_IgnoreAndReturn(10); + foo_IgnoreAndReturn(40); + foo_IgnoreAndReturn(80); + TEST_ASSERT_EQUAL(130, function(3, 4, 3)); + } + + - :pass: TRUE + :should: 'ignore the situation where foo() is not called even though we explicitly ignored it' + :code: | + test() + { + foo_IgnoreAndReturn(20); + //notice we do not call foo + } + + - :pass: TRUE + :should: 'ignore foo() calls and always return last item if we run out' + :code: | + test() + { + bar_Expect(4); + foo_IgnoreAndReturn(20); + foo_IgnoreAndReturn(30); + TEST_ASSERT_EQUAL(80, function(3, 4, 9)); + } + + - :pass: TRUE + :should: 'ignore foo() calls and always return only item if only one specified' + :code: | + test() + { + bar_Expect(4); + foo_IgnoreAndReturn(20); + TEST_ASSERT_EQUAL(60, function(3, 4, 9)); + } + + - :pass: TRUE + :should: 'ignore bar() and foo() calls' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(50); + TEST_ASSERT_EQUAL(150, function(0, 0, 0)); + } + + - :pass: TRUE + :should: 'ignore foo() calls over multiple mock calls' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(50); + foo_IgnoreAndReturn(60); + foo_IgnoreAndReturn(70); + TEST_ASSERT_EQUAL(180, function(0, 0, 0)); + + bar_Ignore(); + foo_IgnoreAndReturn(30); + foo_IgnoreAndReturn(80); + foo_IgnoreAndReturn(10); + TEST_ASSERT_EQUAL(120, function(0, 0, 0)); + + foo_IgnoreAndReturn(70); + foo_IgnoreAndReturn(20); + TEST_ASSERT_EQUAL(110, function(0, 0, 0)); + } + + - :pass: TRUE + :should: 'multiple cycles of expects still pass when ignores enabled' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: FALSE + :should: 'multiple cycles of expects still fail when ignores enabled' + :code: | + test() + { + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(0, 8, 9)); + } + + - :pass: FALSE + :should: 'With "fail_on_unexpected_calls" enabled, Expect/Ignore/... of bar is required and test fails.' + :code: | + test() + { + function(1, 2, 3); + } + + - :pass: TRUE + :should: 'we can override an ignore with an expect and pass' + :code: | + test() + { + bar_Ignore(); + + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: FALSE + :should: 'we can override an ignore with an expect and fail' + :code: | + test() + { + bar_Ignore(); + + bar_Expect(2); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(9); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: TRUE + :should: 'we can override an ignore and return with an expect and pass' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(30); + TEST_ASSERT_EQUAL(90, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(8); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: FALSE + :should: 'we can override an ignore and return with an expect and fail' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(0); + TEST_ASSERT_EQUAL(0, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_ExpectAndReturn(6, 10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Expect(9); + foo_ExpectAndReturn(7, 70); + foo_ExpectAndReturn(8, 20); + foo_ExpectAndReturn(9, 20); + TEST_ASSERT_EQUAL(110, function(7, 8, 9)); + } + + - :pass: TRUE + :should: 'we can override an an expect with an ignore' + :code: | + test() + { + bar_Expect(5); + bar_Ignore(); + foo_ExpectAndReturn(1, 50); + foo_ExpectAndReturn(2, 60); + foo_ExpectAndReturn(3, 70); + TEST_ASSERT_EQUAL(180, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'we can override an expect with an ignore and return and pass' + :code: | + test() + { + bar_Ignore(); + foo_IgnoreAndReturn(0); + TEST_ASSERT_EQUAL(0, function(1, 2, 3)); + + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 80); + foo_IgnoreAndReturn(10); + TEST_ASSERT_EQUAL(120, function(4, 5, 6)); + + bar_Ignore(); + foo_IgnoreAndReturn(60); + TEST_ASSERT_EQUAL(180, function(7, 8, 9)); + } + + - :pass: FALSE + :should: 'we can override an expect with an ignore and return and fail after' + :code: | + test() + { + bar_Expect(5); + foo_ExpectAndReturn(4, 30); + foo_ExpectAndReturn(5, 50); + foo_IgnoreAndReturn(20); + TEST_ASSERT_EQUAL(100, function(4, 5, 6)); + + bar_Expect(5); + foo_ExpectAndReturn(9, 30); //THIS ONE WILL FAIL + foo_ExpectAndReturn(2, 80); + foo_ExpectAndReturn(3, 60); + TEST_ASSERT_EQUAL(170, function(1, 2, 3)); + } + + - :pass: TRUE + :should: 'we can override an expect with an ignore and return and the expected values are ignored' + :code: | + test() + { + bar_Expect(5); + foo_ExpectAndReturn(2, 30); //NOTE THIS WOULD NORMALLY FAIL + foo_ExpectAndReturn(5, 50); + foo_IgnoreAndReturn(20); //BUT WE SAID WE NO LONGER CARE + TEST_ASSERT_EQUAL(100, function(4, 5, 6)); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/ignore_strict_mock_calling.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/ignore_strict_mock_calling.yml new file mode 100644 index 000000000..bcfe04c5e --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/ignore_strict_mock_calling.yml @@ -0,0 +1,37 @@ +--- +:cmock: + :plugins: + - 'ignore' + :fail_on_unexpected_calls: FALSE + +:systest: + :types: | + + :mockable: | + int foo(int a); + void bar(int b); + + :source: + :header: | + int function(int a, int b, int c); + :code: | + int function(int a, int b, int c) + { + bar(b); + return foo(a) + foo(b) + foo(c); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'With "fail_on_unexpected_calls" disabled, Expect/Ignore/... of bar is NOT required.' + :code: | + test() + { + function(1, 2, 3); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/newer_standards_stuff1.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/newer_standards_stuff1.yml new file mode 100644 index 000000000..6843eae60 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/newer_standards_stuff1.yml @@ -0,0 +1,52 @@ +--- +#The purpose of this test is to pull in some standard library stuff from C99 +:cmock: + :includes: + - "<stdint.h>" + - "<limits.h>" + +:systest: + :types: | + #include <stdint.h> + #include <limits.h> + + + :mockable: | + int32_t foo(int32_t a); + + :source: + :header: | + int8_t function_a(void); + + :code: | + int8_t function_a(void) { + return (int8_t)(INT_MIN == foo(INT_MAX)); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle handle a simple comparison of C99 types which pass' + :code: | + test() + { + foo_ExpectAndReturn(INT_MAX, INT_MIN); + + TEST_ASSERT_TRUE(function_a()); + } + + - :pass: FALSE + :should: 'handle handle a simple comparison of C99 types which fail' + :code: | + test() + { + foo_ExpectAndReturn(INT_MIN, INT_MIN); + + TEST_ASSERT_TRUE(function_a()); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/nonstandard_parsed_stuff_1.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/nonstandard_parsed_stuff_1.yml new file mode 100644 index 000000000..01538ea32 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/nonstandard_parsed_stuff_1.yml @@ -0,0 +1,91 @@ +--- +#The purpose of this test is to play with things like "const char const *" which isn't supported by some compilers +:cmock: + :enforce_strict_ordering: 1 + :plugins: + - :array + - :cexception + - :ignore + +:systest: + :types: | + typedef struct _POINT_T { + int x; + int y; + } POINT_T; + + :mockable: | + #include "CException.h" + void foos(const char const * a); + const char const * bars(void); + + :source: + :header: | + #include "CException.h" + void function_a(void); + void function_b(void); + void function_c(void); + int function_d(void); + + :code: | + void function_c(void) { + CEXCEPTION_T e; + Try { + foos(bars()); + } Catch(e) { foos("err"); } + } + + :tests: + :common: | + #include "CException.h" + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle standard c string as null terminated on not do crappy memory compares of a byte, passing' + :code: | + test() + { + bars_ExpectAndReturn("This is a\0 silly string"); + foos_Expect("This is a\0 wacky string"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle standard c string as null terminated on not do crappy memory compares of a byte, finding failures' + :code: | + test() + { + bars_ExpectAndReturn("This is a silly string"); + foos_Expect("This is a wacky string"); + + function_c(); + } + + - :pass: TRUE + :should: 'handle an exception being caught' + :code: | + test() + { + bars_ExpectAndReturn("This is a\0 silly string"); + foos_ExpectAndThrow("This is a\0 wacky string", 55); + foos_Expect("err"); + + function_c(); + } + + - :pass: FALSE + :should: 'handle an exception being caught but still catch following errors' + :code: | + test() + { + bars_ExpectAndReturn("This is a\0 silly string"); + foos_ExpectAndThrow("This is a\0 wacky string", 55); + foos_Expect("wrong error"); + + function_c(); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/nonstandard_parsed_stuff_2.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/nonstandard_parsed_stuff_2.yml new file mode 100644 index 000000000..506e7ee8a --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/nonstandard_parsed_stuff_2.yml @@ -0,0 +1,59 @@ +--- +#The purpose of this test is to play with our really rough multidimensional array support, which involves an implicit cast not supported everywhere +:cmock: + :plugins: + - :array + +:systest: + :types: | + + + :mockable: | + void foo(unsigned char** a); + unsigned char** bar(void); + + :source: + :header: | + void function_a(void); + + :code: | + void function_a(void) { + foo(bar()); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle two dimensional array of unsigned characters just like we would handle a single dimensional array in expect (where we really only care about first element)' + :code: | + test() + { + unsigned char a[] = { 1, 2, 3, 4, 5, 6 }; + unsigned char** pa = (unsigned char**)(&a); + + bar_ExpectAndReturn(pa); + foo_Expect(pa); + + function_a(); + } + + - :pass: FALSE + :should: 'handle two dimensional array of unsigned characters just like we would handle a single dimensional array in expect as failures (where we really only care about first element)' + :code: | + test() + { + unsigned char a[] = { 1, 2, 3, 4, 5, 6 }; + unsigned char b[] = { 5, 6, 7, 8, 9, 0 }; + unsigned char** pa = (unsigned char**)(&a); + unsigned char** pb = (unsigned char**)(&b); + + bar_ExpectAndReturn(pa); + foo_Expect(pb); + + function_a(); + } +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/out_of_memory.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/out_of_memory.yml new file mode 100644 index 000000000..ed7bed5c1 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/out_of_memory.yml @@ -0,0 +1,65 @@ +--- +:cmock: + :plugins: [] + :treat_as: + custom_type: INT + +:systest: + :types: | + typedef struct _BIG_FAT_STRUCT_T + { + char bytes[512]; + } BIG_FAT_STRUCT_T; + + :mockable: | + void foo(BIG_FAT_STRUCT_T a); + + :source: + :header: | + void function_a(void); + void function_b(void); + + :code: | + void function_a(void) + { + BIG_FAT_STRUCT_T stuff = { { 8, 0 } }; + foo(stuff); + } + + void function_b(void) + { + BIG_FAT_STRUCT_T stuff1 = { { 9, 1, 0 } }; + BIG_FAT_STRUCT_T stuff2 = { { 9, 2, 0 } }; + foo(stuff1); + foo(stuff2); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully should be able to run function a because it only takes half the memory' + :code: | + test() + { + BIG_FAT_STRUCT_T expected = { { 8, 0 } }; + foo_Expect(expected); + function_a(); + } + + - :pass: FALSE + :should: 'should error out because we do not have eough memory to handle two of these structures' + :code: | + test() + { + BIG_FAT_STRUCT_T expected1 = { { 9, 1, 0 } }; + BIG_FAT_STRUCT_T expected2 = { { 9, 2, 0 } }; + foo_Expect(expected1); + foo_Expect(expected2); + function_b(); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/parsing_challenges.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/parsing_challenges.yml new file mode 100644 index 000000000..77e857d86 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/parsing_challenges.yml @@ -0,0 +1,242 @@ +--- +:cmock: + :plugins: + - # no plugins + :treat_as_void: + - VOID_TYPE_CRAZINESS_CFG + :treat_as: + TypeDefInt: HEX8 + VOID_TYPE_CRAZINESS_CFG*: PTR + +:systest: + :types: | + typedef unsigned short U16; + typedef struct _POINT_T + { + int x; + int y; + } POINT_T; + typedef void VOID_TYPE_CRAZINESS_CFG; + typedef int TypeDefInt; + + :mockable: | + /* Make sure we ignore the following + #include "NonExistantFile.h + */ + //#include "AndIgnoreThisToo.h" + #ifdef __cplusplus + extern "C" { + #endif + #define SHOULD_IGNORE_NEXT_FUNC_DEF_AS_PART_OF_MACRO \ + void IgnoredFunction(NotAValidType ToMakeItFailIfWeActuallyMockedThis); + + // typedef edge case; must be in mockable.h for test to compile + // not ANSI C but it has been done and will break cmock if not handled + typedef void VOID_TYPE_CRAZINESS_LCL; + + VOID_TYPE_CRAZINESS_LCL void_type_craziness1(int * a, int *b, int* c); + void void_type_craziness2(VOID_TYPE_CRAZINESS_CFG); + void void_type_craziness3(VOID_TYPE_CRAZINESS_CFG* a); + + // pointer parsing exercise + U16 *ptr_return1(int a); + U16* ptr_return2(int a); + U16 * ptr_return3(int a); + + unsigned int** ptr_ptr_return1(unsigned int** a); + unsigned int* *ptr_ptr_return2(unsigned int* *a); + unsigned int **ptr_ptr_return3(unsigned int **a); + unsigned int ** ptr_ptr_return4(unsigned int ** a); + + // variable argument lists + void var_args1(int a, ...); + void var_args2(int a, int b, ...); + + // parsing "stress tests" + char + crazy_multiline( + int a, + unsigned int b); + + unsigned long int incredible_descriptors(register const unsigned short a); + + TypeDefInt uses_typedef_like_names(TypeDefInt typedefvar); + + void oh_brackets1(int fudge[5]); + void oh_brackets2(int caramel[]); + void oh_brackets3(int toffee[(32)]); + void oh_brackets4(int taffy[ (64) ]); + #ifdef __cplusplus + } + #endif + + :source: + :header: | + U16* exercise_return_pointers(int a); + void exercise_var_args(int a, int b); + void exercise_arglist_pointers(void); + char exercise_multiline_declarations(int a, unsigned int b); + void exercise_double_pointers(unsigned int** a); + int exercise_many_descriptors(int a); + void exercise_type_craziness3(VOID_TYPE_CRAZINESS_CFG* a); + TypeDefInt exercise_typedef_like_names(TypeDefInt a); + + :code: | + int A, B, C; + unsigned int *pA, *pB, *pC; + + U16* exercise_return_pointers(int a) + { + ptr_return1(a); + ptr_return2(a); + return ptr_return3(a); + } + + void exercise_var_args(int a, int b) + { + var_args1(a, 3); + var_args2(a, b, 'c'); + } + + void exercise_arglist_pointers(void) + { + void_type_craziness1(&A, &B, &C); + void_type_craziness2(); + } + + char exercise_multiline_declarations(int a, unsigned int b) + { + return crazy_multiline(a, b); + } + + void exercise_double_pointers(unsigned int** a) + { + ptr_ptr_return1((unsigned int**)a); + ptr_ptr_return2((unsigned int**)a); + ptr_ptr_return3((unsigned int**)a); + ptr_ptr_return4((unsigned int**)a); + } + + int exercise_many_descriptors(int a) + { + return (int)incredible_descriptors((unsigned short)a); + } + + void exercise_type_craziness3(VOID_TYPE_CRAZINESS_CFG* a) + { + void_type_craziness3(a); + } + + TypeDefInt exercise_typedef_like_names(TypeDefInt a) + { + return uses_typedef_like_names(a); + } + + :tests: + :common: | + extern int A, B, C; + extern unsigned int *pA, *pB, *pC; + + void setUp(void) + { + A = 100; + B = 200; + C = 300; + pA = (unsigned int*)(&A); + pB = (unsigned int*)(&B); + pC = (unsigned int*)(&C); + } + void tearDown(void) {} + :units: + - :pass: TRUE + :should: 'execute simple pointer return value check' + :code: | + test() + { + U16 retval; + ptr_return1_ExpectAndReturn(2, NULL); + ptr_return2_ExpectAndReturn(2, NULL); + ptr_return3_ExpectAndReturn(2, &retval); + TEST_ASSERT_EQUAL_PTR(&retval, exercise_return_pointers(2)); + } + + - :pass: TRUE + :should: 'ignore var args in expect prototype generation' + :code: | + test() + { + var_args1_Expect(2); + var_args2_Expect(2, 3); + exercise_var_args(2, 3); + } + + - :pass: TRUE + :should: "not process a typedef'd void as anything other than void" + :code: | + test() + { + void_type_craziness1_Expect(&A, &B, &C); + void_type_craziness2_Expect(); + exercise_arglist_pointers(); + } + + - :pass: TRUE + :should: 'successfully mock crazy multline function prototypes' + :code: | + test() + { + crazy_multiline_ExpectAndReturn(-10, 11, 'z'); + TEST_ASSERT_EQUAL('z', exercise_multiline_declarations(-10, 11)); + } + + - :pass: TRUE + :should: 'mock double pointers just fine' + :code: | + test() + { + ptr_ptr_return1_ExpectAndReturn(&pA, &pB); + ptr_ptr_return2_ExpectAndReturn(&pA, &pB); + ptr_ptr_return3_ExpectAndReturn(&pA, &pB); + ptr_ptr_return4_ExpectAndReturn(&pA, &pB); + exercise_double_pointers((unsigned int**)(&pA)); + } + + - :pass: TRUE + :should: 'mock prototypes with long lists of return and parameter type descriptors' + :code: | + test() + { + incredible_descriptors_ExpectAndReturn(888, 777); + TEST_ASSERT_EQUAL(777, exercise_many_descriptors(888)); + } + + - :pass: TRUE + :should: 'handle words like typdef as PART of a variable or type' + :code: | + test() + { + uses_typedef_like_names_ExpectAndReturn((TypeDefInt)54, (TypeDefInt)53); + TEST_ASSERT_EQUAL(53, exercise_typedef_like_names((TypeDefInt)54)); + } + + - :pass: FALSE + :should: 'handle words like typdef as PART of a variable or type during failing tests' + :code: | + test() + { + uses_typedef_like_names_ExpectAndReturn((TypeDefInt)52, (TypeDefInt)53); + TEST_ASSERT_EQUAL(53, exercise_typedef_like_names((TypeDefInt)54)); + } + + - :pass: TRUE + :should: 'handle typedef of void used as a void pointer' + :code: | + test() + { + char blah[5] = "blah"; + void_type_craziness3_Expect(blah); + exercise_type_craziness3(blah); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/return_thru_ptr_and_expect_any_args.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/return_thru_ptr_and_expect_any_args.yml new file mode 100644 index 000000000..40e0e7f62 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/return_thru_ptr_and_expect_any_args.yml @@ -0,0 +1,235 @@ +--- +:cmock: + :mock_path: test/mocks + :mock_prefix: mock_ + :treat_as: + abs_struct: PTR + intptr: INT* + :when_ptr: :smart + :plugins: + - :array + - :ignore_arg + - :return_thru_ptr + +:systest: + :types: | + typedef int *intptr; + + struct a_struct + { + int i1; + int i2; + int i3; + }; + + struct _abs_struct + { + int abs_i1; + int abs_i2; + }; + + typedef struct _abs_struct abs_struct; + + :mockable: | + void ptr_ret_int(int *r); + void ptr_ret_ints(int *r, int *s); + void ptr_ret_array(char r[], int len); + void ptr_ret_typedef(intptr r); + void ptr_ret_struct(struct a_struct *r); + void ptr_ret_abstract(abs_struct *r); + void ptr_ret_abstract_array(abs_struct *r, int len); + void ptr_ret_const_int(int *r, const int *s); + void ptr_ret_string(char *s); + + :source: + :header: | + #include <string.h> + #define lengthof(x) (sizeof(x)/sizeof((x)[0])) + + :code: | + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: "handle a single int* argument" + :code: | + test() + { + int r = 1; + int res = 4; + + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(4, r); + } + + - :pass: TRUE + :should: "handle multiple calls" + :code: | + test() + { + int r = 1; + int res1 = 4; + int res2 = 8; + int res3 = 16; + + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res1); + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res2); + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res3); + + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(4, r); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(8, r); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(16, r); + + } + + - :pass: TRUE + :should: "ignore an argument" + :code: | + test() + { + int r = 1, s = 2; + int res = 4; + + ptr_ret_int_Expect(&r); + ptr_ret_int_IgnoreArg_r(); + ptr_ret_int_ReturnThruPtr_r(&res); + ptr_ret_int(&s); + TEST_ASSERT_EQUAL(4, s); + } + + - :pass: TRUE + :should: "ignore a null pointer argument" + :code: | + test() + { + int r = 1; + int res = 4; + + ptr_ret_int_Expect(NULL); + ptr_ret_int_IgnoreArg_r(); + ptr_ret_int_ReturnThruPtr_r(&res); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(4, r); + } + + - :pass: TRUE + :should: "handle multiple int* arguments" + :code: | + test() + { + int r, s = 0x0880AA55; + int r_res = 4; + int s_res = 6; + + ptr_ret_ints_Expect(&r, &s); + ptr_ret_ints_ReturnThruPtr_r(&r_res); + ptr_ret_ints_ReturnThruPtr_s(&s_res); + ptr_ret_ints(&r, &s); + TEST_ASSERT_EQUAL(4, r); + TEST_ASSERT_EQUAL(6, s); + } + + - :pass: TRUE + :should: "only return through pointer when asked to" + :code: | + test() + { + int r = 0x0880AA55; + int s = 0xAA55; + int r_res = 4; + + ptr_ret_ints_Expect(&r, &s); + ptr_ret_ints_ReturnThruPtr_r(&r_res); + ptr_ret_ints(&r, &s); + TEST_ASSERT_EQUAL(4, r); + TEST_ASSERT_EQUAL(0xAA55, s); + } + + - :pass: TRUE + :should: "return an array through a pointer correctly" + :code: | + test() + { + char r_a[] = "booboorooboo"; + char r_a_ret[] = "FEEFI"; + + ptr_ret_array_Expect(r_a, lengthof(r_a)); + ptr_ret_array_ReturnArrayThruPtr_r(r_a_ret, (int)strlen(r_a_ret)); + ptr_ret_array(r_a, lengthof(r_a)); + TEST_ASSERT_EQUAL_STRING("FEEFIorooboo", r_a); + } + + - :pass: TRUE + :should: "handle structs" + :code: | + test() + { + struct a_struct r_s = { .i1 = 2, .i2 = 3, .i3 = 4, }; + struct a_struct r_s_ret = { .i1 = 8, .i2 = 16, .i3 = 32, }; + + ptr_ret_struct_Expect(&r_s); + ptr_ret_struct_ReturnThruPtr_r(&r_s_ret); + ptr_ret_struct(&r_s); + TEST_ASSERT_EQUAL_MEMORY(&r_s_ret, &r_s, sizeof(struct a_struct)); + } + + - :pass: TRUE + :should: "handle typedefs" + :code: | + test() + { + abs_struct r_as = {.abs_i1 = 0x1234, .abs_i2 = 0x4567}; + abs_struct r_as_ret = {.abs_i1 = 0xFFAA55, .abs_i2 = 0xAAFFAA}; + ptr_ret_abstract_Expect(&r_as); + ptr_ret_abstract_ReturnMemThruPtr_r(&r_as_ret, sizeof(abs_struct)); + ptr_ret_abstract(&r_as); + TEST_ASSERT_EQUAL_MEMORY(&r_as_ret, &r_as, sizeof(abs_struct)); + } + + - :pass: TRUE + :should: "only generate ReturnThruPtr definitions for non-const arguments" + :code: | + test() + { + #if !defined(ptr_ret_const_int_ReturnThruPtr_r) + TEST_FAIL_MESSAGE("ReturnThruPtr not defined for a pointer argument."); + #endif + + #if defined(ptr_ret_const_int_ReturnThruPtr_s) + TEST_FAIL_MESSAGE("ReturnThruPtr defined for a const pointer argument."); + #endif + } + + - :pass: TRUE + :should: "generate ReturnThruPtr definitions for string arguments" + :code: | + test() + { + #if !defined(ptr_ret_string_ReturnThruPtr_s) + TEST_FAIL_MESSAGE("ReturnThruPtr not defined for a string argument."); + #endif + } + + - :pass: TRUE + :should: "generate IgnoreArg definitions" + :code: | + test() + { + #if !defined(ptr_ret_array_IgnoreArg_r) \ + || !defined(ptr_ret_array_IgnoreArg_len) \ + || !defined(ptr_ret_const_int_IgnoreArg_s) + TEST_FAIL_MESSAGE("IgnoreArg not defined for an argument."); + #endif + } diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/return_thru_ptr_ignore_arg.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/return_thru_ptr_ignore_arg.yml new file mode 100644 index 000000000..8b07be997 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/return_thru_ptr_ignore_arg.yml @@ -0,0 +1,231 @@ +--- +:cmock: + :mock_path: test/mocks + :mock_prefix: mock_ + :treat_as: + abs_struct: PTR + intptr: INT* + :when_ptr: :smart + :plugins: + - :array + - :expect_any_args + - :return_thru_ptr + +:systest: + :types: | + typedef int *intptr; + + struct a_struct + { + int i1; + int i2; + int i3; + }; + + struct _abs_struct + { + int abs_i1; + int abs_i2; + }; + + typedef struct _abs_struct abs_struct; + + :mockable: | + void ptr_ret_int(int *r); + void ptr_ret_ints(int *r, int *s); + void ptr_ret_array(char r[], int len); + void ptr_ret_typedef(intptr r); + void ptr_ret_struct(struct a_struct *r); + void ptr_ret_abstract(abs_struct *r); + void ptr_ret_abstract_array(abs_struct *r, int len); + void ptr_ret_const_int(int *r, const int *s); + void ptr_ret_string(char *s); + + :source: + :header: | + #include <string.h> + #define lengthof(x) (sizeof(x)/sizeof((x)[0])) + + :code: | + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: "handle a single int* argument" + :code: | + test() + { + int r = 1; + int res = 4; + + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(4, r); + } + + - :pass: TRUE + :should: "handle multiple calls" + :code: | + test() + { + int r = 1; + int res1 = 4; + int res2 = 8; + int res3 = 16; + + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res1); + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res2); + ptr_ret_int_Expect(&r); + ptr_ret_int_ReturnThruPtr_r(&res3); + + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(4, r); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(8, r); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(16, r); + + } + + - :pass: TRUE + :should: "ignore an argument" + :code: | + test() + { + int s = 2; + int res = 4; + + ptr_ret_int_ExpectAnyArgs(); + ptr_ret_int_ReturnThruPtr_r(&res); + ptr_ret_int(&s); + TEST_ASSERT_EQUAL(4, s); + } + + - :pass: TRUE + :should: "ignore a null pointer argument" + :code: | + test() + { + int r = 1; + int res = 4; + + ptr_ret_int_ExpectAnyArgs(); + ptr_ret_int_ReturnThruPtr_r(&res); + ptr_ret_int(&r); + TEST_ASSERT_EQUAL(4, r); + } + + - :pass: TRUE + :should: "handle multiple int* arguments" + :code: | + test() + { + int r, s = 0x0880AA55; + int r_res = 4; + int s_res = 6; + + ptr_ret_ints_Expect(&r, &s); + ptr_ret_ints_ReturnThruPtr_r(&r_res); + ptr_ret_ints_ReturnThruPtr_s(&s_res); + ptr_ret_ints(&r, &s); + TEST_ASSERT_EQUAL(4, r); + TEST_ASSERT_EQUAL(6, s); + } + + - :pass: TRUE + :should: "only return through pointer when asked to" + :code: | + test() + { + int r = 0x0880AA55; + int s = 0xAA55; + int r_res = 4; + + ptr_ret_ints_Expect(&r, &s); + ptr_ret_ints_ReturnThruPtr_r(&r_res); + ptr_ret_ints(&r, &s); + TEST_ASSERT_EQUAL(4, r); + TEST_ASSERT_EQUAL(0xAA55, s); + } + + - :pass: TRUE + :should: "return an array through a pointer correctly" + :code: | + test() + { + char r_a[] = "booboorooboo"; + char r_a_ret[] = "FEEFI"; + + ptr_ret_array_Expect(r_a, lengthof(r_a)); + ptr_ret_array_ReturnArrayThruPtr_r(r_a_ret, (int)strlen(r_a_ret)); + ptr_ret_array(r_a, lengthof(r_a)); + TEST_ASSERT_EQUAL_STRING("FEEFIorooboo", r_a); + } + + - :pass: TRUE + :should: "handle structs" + :code: | + test() + { + struct a_struct r_s = { .i1 = 2, .i2 = 3, .i3 = 4, }; + struct a_struct r_s_ret = { .i1 = 8, .i2 = 16, .i3 = 32, }; + + ptr_ret_struct_Expect(&r_s); + ptr_ret_struct_ReturnThruPtr_r(&r_s_ret); + ptr_ret_struct(&r_s); + TEST_ASSERT_EQUAL_MEMORY(&r_s_ret, &r_s, sizeof(struct a_struct)); + } + + - :pass: TRUE + :should: "handle typedefs" + :code: | + test() + { + abs_struct r_as = {.abs_i1 = 0x1234, .abs_i2 = 0x4567}; + abs_struct r_as_ret = {.abs_i1 = 0xFFAA55, .abs_i2 = 0xAAFFAA}; + ptr_ret_abstract_Expect(&r_as); + ptr_ret_abstract_ReturnMemThruPtr_r(&r_as_ret, sizeof(abs_struct)); + ptr_ret_abstract(&r_as); + TEST_ASSERT_EQUAL_MEMORY(&r_as_ret, &r_as, sizeof(abs_struct)); + } + + - :pass: TRUE + :should: "only generate ReturnThruPtr definitions for non-const arguments" + :code: | + test() + { + #if !defined(ptr_ret_const_int_ReturnThruPtr_r) + TEST_FAIL_MESSAGE("ReturnThruPtr not defined for a pointer argument."); + #endif + + #if defined(ptr_ret_const_int_ReturnThruPtr_s) + TEST_FAIL_MESSAGE("ReturnThruPtr defined for a const pointer argument."); + #endif + } + + - :pass: TRUE + :should: "generate ReturnThruPtr definitions for string arguments" + :code: | + test() + { + #if !defined(ptr_ret_string_ReturnThruPtr_s) + TEST_FAIL_MESSAGE("ReturnThruPtr not defined for a string argument."); + #endif + } + + - :pass: TRUE + :should: "generate ExpectAnyArgs definitions" + :code: | + test() + { + #if !defined(ptr_ret_array_ExpectAnyArgs) + TEST_FAIL_MESSAGE("ExpectAnyArgs not defined for an argument."); + #endif + } diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/skeleton.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/skeleton.yml new file mode 100644 index 000000000..772080022 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/skeleton.yml @@ -0,0 +1,55 @@ +--- +:cmock: + :plugins: + - # none + :skeleton_path: system/generated + +:systest: + :types: | + #define UINT32 unsigned int + + :mockable: | + UINT32 something(int a); + + :skeleton: skeleton.h + + :source: + :header: | + void function_a(void); + int function_b(int a, int b); + const char* function_c(void); + + # we are purposefully not including a :code section because it will be generated with skeleton + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'generate an empty shell for functions with no return values' + :code: | + test() + { + function_a(); + } + + - :pass: TRUE + :should: 'return numerical zero for numerical return values' + :code: | + test() + { + TEST_ASSERT_EQUAL_INT(0, function_b(1, 2)); + } + + - :pass: TRUE + :should: 'return null for pointer return values' + :code: | + test() + { + TEST_ASSERT_NULL(function_c()); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/skeleton_update.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/skeleton_update.yml new file mode 100644 index 000000000..757e8b13d --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/skeleton_update.yml @@ -0,0 +1,76 @@ +--- +:cmock: + :plugins: + - # none + :skeleton_path: system/generated + +:systest: + :types: | + #define UINT32 unsigned int + + :mockable: | + UINT32 something(int a); + + :skeleton: skeleton_update.h + + :source: + :header: | + void function_a(void); + int function_b(int a, int b); + const char* function_c(void); + + # note that this code section exists and will be updated by the skeleton generator + :code: | + const char* donuts = "donuts"; + const char* function_c(void) + { + return donuts; + } + + int function_d(void) + { + return 77; + } + + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + extern int function_d(); + + :units: + - :pass: TRUE + :should: 'generate an empty shell for functions with no return values' + :code: | + test() + { + function_a(); + } + + - :pass: TRUE + :should: 'return numerical zero for numerical return values' + :code: | + test() + { + TEST_ASSERT_EQUAL_INT(0, function_b(1, 2)); + } + + - :pass: TRUE + :should: 'not overwrite functions that already exist' + :code: | + test() + { + TEST_ASSERT_EQUAL_STRING("donuts", function_c()); + } + + - :pass: TRUE + :should: 'leave functions it has never heard of' + :code: | + test() + { + TEST_ASSERT_EQUAL_INT(77, function_d()); + } + + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/struct_union_enum_expect_and_return.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/struct_union_enum_expect_and_return.yml new file mode 100644 index 000000000..d4cf6af19 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/struct_union_enum_expect_and_return.yml @@ -0,0 +1,277 @@ +--- +:cmock: + :plugins: + - # none + +:systest: + :types: | + struct THING { int a; int b; }; + + union STARS_AND_STRIPES { int a; char b; }; + + enum HOKEY_POKEY { IN, OUT, SHAKE_IT_ALL_ABOUT }; + + :mockable: | + void foo_struct(struct THING*, struct THING); + struct THING foobar_struct(void); + + void foo_union(union STARS_AND_STRIPES*, union STARS_AND_STRIPES); + union STARS_AND_STRIPES foobar_union(void); + + void foo_enum(enum HOKEY_POKEY a, enum HOKEY_POKEY * b); + enum HOKEY_POKEY foobar_enum(void); + + :source: + :header: | + void exercise_struct(struct THING* a, struct THING b); + struct THING return_struct(void); + + void exercise_union(union STARS_AND_STRIPES* a, union STARS_AND_STRIPES b); + union STARS_AND_STRIPES return_union(void); + + void exercise_enum(enum HOKEY_POKEY a, enum HOKEY_POKEY * b); + enum HOKEY_POKEY return_enum(void); + + :code: | + void exercise_struct(struct THING* a, struct THING b) + { + foo_struct(a, b); + } + + struct THING return_struct(void) + { + return foobar_struct(); + } + + void exercise_union(union STARS_AND_STRIPES* a, union STARS_AND_STRIPES b) + { + foo_union(a, b); + } + + union STARS_AND_STRIPES return_union(void) + { + return foobar_union(); + } + + void exercise_enum(enum HOKEY_POKEY a, enum HOKEY_POKEY * b) + { + foo_enum(a, b); + } + + enum HOKEY_POKEY return_enum(void) + { + return foobar_enum(); + } + + + :tests: + :common: | + struct THING struct1; + struct THING struct2; + struct THING struct3; + struct THING struct4; + struct THING struct5; + struct THING struct6; + + union STARS_AND_STRIPES union1; + union STARS_AND_STRIPES union2; + union STARS_AND_STRIPES union3; + union STARS_AND_STRIPES union4; + union STARS_AND_STRIPES union5; + union STARS_AND_STRIPES union6; + + enum HOKEY_POKEY enum1; + enum HOKEY_POKEY enum2; + + void setUp(void) + { + struct1.a = 1; + struct1.b = 2; + + struct2.a = 3; + struct2.b = 4; + + struct3.a = 5; + struct3.b = 6; + + struct4.a = 7; + struct4.b = 8; + + struct5.a = 9; + struct5.b = 10; + + struct6.a = 9; + struct6.b = 10; + + union1.a = 1; + union2.a = 2; + union3.a = 3; + union4.a = 4; + union5.a = 5; + union6.a = 5; + + enum1 = OUT; + enum2 = IN; + } + + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully compare structs' + :code: | + test() + { + foo_struct_Expect(&struct1, struct2); + exercise_struct(&struct1, struct2); + } + + - :pass: FALSE + :should: 'blow up on bad struct pointer comparison' + :code: | + test() + { + foo_struct_Expect(&struct1, struct2); + exercise_struct(&struct3, struct2); + } + + - :pass: FALSE + :should: 'blow up on bad structure comparison' + :code: | + test() + { + foo_struct_Expect(&struct1, struct2); + exercise_struct(&struct1, struct4); + } + + - :pass: TRUE + :should: 'compare returned structs as equal' + :code: | + test() + { + foobar_struct_ExpectAndReturn(struct5); + TEST_ASSERT_EQUAL_THING(struct6, return_struct()); + } + + - :pass: FALSE + :should: 'compare returned structs as unequal' + :code: | + test() + { + foobar_struct_ExpectAndReturn(struct4); + TEST_ASSERT_EQUAL_THING(struct5, return_struct()); + } + + - :pass: TRUE + :should: 'successfully compare unions' + :code: | + test() + { + foo_union_Expect(&union1, union2); + exercise_union(&union1, union2); + } + + - :pass: FALSE + :should: 'blow up on bad union pointer comparison' + :code: | + test() + { + foo_union_Expect(&union1, union2); + exercise_union(&union3, union2); + } + + - :pass: FALSE + :should: 'blow up on bad union comparison' + :code: | + test() + { + foo_union_Expect(&union1, union2); + exercise_union(&union1, union4); + } + + - :pass: TRUE + :should: 'compare returned unions as equal' + :code: | + test() + { + foobar_union_ExpectAndReturn(union5); + TEST_ASSERT_EQUAL_STARS_AND_STRIPES(union6, return_union()); + } + + - :pass: FALSE + :should: 'compare returned unions as unequal' + :code: | + test() + { + foobar_union_ExpectAndReturn(union4); + TEST_ASSERT_EQUAL_STARS_AND_STRIPES(union5, return_union()); + } + + - :pass: TRUE + :should: 'successfully pass enum values' + :code: | + test() + { + foo_enum_Expect(OUT, &enum1); + exercise_enum(OUT, &enum1); + } + + - :pass: FALSE + :should: 'blow up on bad enum pointer comparison' + :code: | + test() + { + foo_enum_Expect(IN, &enum1); + exercise_enum(IN, &enum2); + } + + - :pass: FALSE + :should: 'blow up on bad enum comparison' + :code: | + test() + { + foo_enum_Expect(IN, &enum1); + exercise_enum(SHAKE_IT_ALL_ABOUT, &enum1); + } + + - :pass: TRUE + :should: 'compare returned enums as equal' + :code: | + test() + { + foobar_enum_ExpectAndReturn(OUT); + TEST_ASSERT_EQUAL(OUT, return_enum()); + } + + - :pass: FALSE + :should: 'compare returned unions as unequal' + :code: | + test() + { + foobar_enum_ExpectAndReturn(OUT); + TEST_ASSERT_EQUAL(IN, return_enum()); + } + + + :unity_helper: + :header: | + void AssertEqualTHINGStruct(struct THING expected, struct THING actual); + void AssertEqualSTARS_AND_STRIPESUnion(union STARS_AND_STRIPES expected, union STARS_AND_STRIPES actual); + + #define TEST_ASSERT_EQUAL_THING(expected, actual) {AssertEqualTHINGStruct(expected, actual);} + #define TEST_ASSERT_EQUAL_STARS_AND_STRIPES(expected, actual) {AssertEqualSTARS_AND_STRIPESUnion(expected, actual);} + + :code: | + void AssertEqualTHINGStruct(struct THING expected, struct THING actual) + { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected.a, actual.a, "actual struct member \"a\" does not equal expected"); + TEST_ASSERT_EQUAL_INT_MESSAGE(expected.b, actual.b, "actual struct member \"b\" does not equal expected"); + } + + void AssertEqualSTARS_AND_STRIPESUnion(union STARS_AND_STRIPES expected, union STARS_AND_STRIPES actual) + { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected.a, actual.a, "actual union member \"a\" does not equal expected"); + TEST_ASSERT_EQUAL_MESSAGE(expected.b, actual.b, "actual union member \"b\" does not equal expected"); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/struct_union_enum_expect_and_return_with_plugins.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/struct_union_enum_expect_and_return_with_plugins.yml new file mode 100644 index 000000000..a54826ca4 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/struct_union_enum_expect_and_return_with_plugins.yml @@ -0,0 +1,280 @@ +--- +:cmock: + :plugins: + - :array + - :ignore + - :callback + - :return_thru_ptr + +:systest: + :types: | + struct THING { int a; int b; }; + + union STARS_AND_STRIPES { int a; char b; }; + + enum HOKEY_POKEY { IN, OUT, SHAKE_IT_ALL_ABOUT }; + + :mockable: | + void foo_struct(struct THING*, struct THING); + struct THING foobar_struct(void); + + void foo_union(union STARS_AND_STRIPES*, union STARS_AND_STRIPES); + union STARS_AND_STRIPES foobar_union(void); + + void foo_enum(enum HOKEY_POKEY a, enum HOKEY_POKEY * b); + enum HOKEY_POKEY foobar_enum(void); + + :source: + :header: | + void exercise_struct(struct THING* a, struct THING b); + struct THING return_struct(void); + + void exercise_union(union STARS_AND_STRIPES* a, union STARS_AND_STRIPES b); + union STARS_AND_STRIPES return_union(void); + + void exercise_enum(enum HOKEY_POKEY a, enum HOKEY_POKEY * b); + enum HOKEY_POKEY return_enum(void); + + :code: | + void exercise_struct(struct THING* a, struct THING b) + { + foo_struct(a, b); + } + + struct THING return_struct(void) + { + return foobar_struct(); + } + + void exercise_union(union STARS_AND_STRIPES* a, union STARS_AND_STRIPES b) + { + foo_union(a, b); + } + + union STARS_AND_STRIPES return_union(void) + { + return foobar_union(); + } + + void exercise_enum(enum HOKEY_POKEY a, enum HOKEY_POKEY * b) + { + foo_enum(a, b); + } + + enum HOKEY_POKEY return_enum(void) + { + return foobar_enum(); + } + + + :tests: + :common: | + struct THING struct1; + struct THING struct2; + struct THING struct3; + struct THING struct4; + struct THING struct5; + struct THING struct6; + + union STARS_AND_STRIPES union1; + union STARS_AND_STRIPES union2; + union STARS_AND_STRIPES union3; + union STARS_AND_STRIPES union4; + union STARS_AND_STRIPES union5; + union STARS_AND_STRIPES union6; + + enum HOKEY_POKEY enum1; + enum HOKEY_POKEY enum2; + + void setUp(void) + { + struct1.a = 1; + struct1.b = 2; + + struct2.a = 3; + struct2.b = 4; + + struct3.a = 5; + struct3.b = 6; + + struct4.a = 7; + struct4.b = 8; + + struct5.a = 9; + struct5.b = 10; + + struct6.a = 9; + struct6.b = 10; + + union1.a = 1; + union2.a = 2; + union3.a = 3; + union4.a = 4; + union5.a = 5; + union6.a = 5; + + enum1 = OUT; + enum2 = IN; + } + + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'successfully compare structs' + :code: | + test() + { + foo_struct_Expect(&struct1, struct2); + exercise_struct(&struct1, struct2); + } + + - :pass: FALSE + :should: 'blow up on bad struct pointer comparison' + :code: | + test() + { + foo_struct_Expect(&struct1, struct2); + exercise_struct(&struct3, struct2); + } + + - :pass: FALSE + :should: 'blow up on bad structure comparison' + :code: | + test() + { + foo_struct_Expect(&struct1, struct2); + exercise_struct(&struct1, struct4); + } + + - :pass: TRUE + :should: 'compare returned structs as equal' + :code: | + test() + { + foobar_struct_ExpectAndReturn(struct5); + TEST_ASSERT_EQUAL_THING(struct6, return_struct()); + } + + - :pass: FALSE + :should: 'compare returned structs as unequal' + :code: | + test() + { + foobar_struct_ExpectAndReturn(struct4); + TEST_ASSERT_EQUAL_THING(struct5, return_struct()); + } + + - :pass: TRUE + :should: 'successfully compare unions' + :code: | + test() + { + foo_union_Expect(&union1, union2); + exercise_union(&union1, union2); + } + + - :pass: FALSE + :should: 'blow up on bad union pointer comparison' + :code: | + test() + { + foo_union_Expect(&union1, union2); + exercise_union(&union3, union2); + } + + - :pass: FALSE + :should: 'blow up on bad union comparison' + :code: | + test() + { + foo_union_Expect(&union1, union2); + exercise_union(&union1, union4); + } + + - :pass: TRUE + :should: 'compare returned unions as equal' + :code: | + test() + { + foobar_union_ExpectAndReturn(union5); + TEST_ASSERT_EQUAL_STARS_AND_STRIPES(union6, return_union()); + } + + - :pass: FALSE + :should: 'compare returned unions as unequal' + :code: | + test() + { + foobar_union_ExpectAndReturn(union4); + TEST_ASSERT_EQUAL_STARS_AND_STRIPES(union5, return_union()); + } + + - :pass: TRUE + :should: 'successfully pass enum values' + :code: | + test() + { + foo_enum_Expect(OUT, &enum1); + exercise_enum(OUT, &enum1); + } + + - :pass: FALSE + :should: 'blow up on bad enum pointer comparison' + :code: | + test() + { + foo_enum_Expect(IN, &enum1); + exercise_enum(IN, &enum2); + } + + - :pass: FALSE + :should: 'blow up on bad enum comparison' + :code: | + test() + { + foo_enum_Expect(IN, &enum1); + exercise_enum(SHAKE_IT_ALL_ABOUT, &enum1); + } + + - :pass: TRUE + :should: 'compare returned enums as equal' + :code: | + test() + { + foobar_enum_ExpectAndReturn(OUT); + TEST_ASSERT_EQUAL(OUT, return_enum()); + } + + - :pass: FALSE + :should: 'compare returned unions as unequal' + :code: | + test() + { + foobar_enum_ExpectAndReturn(OUT); + TEST_ASSERT_EQUAL(IN, return_enum()); + } + + + :unity_helper: + :header: | + void AssertEqualTHINGStruct(struct THING expected, struct THING actual); + void AssertEqualSTARS_AND_STRIPESUnion(union STARS_AND_STRIPES expected, union STARS_AND_STRIPES actual); + + #define TEST_ASSERT_EQUAL_THING(expected, actual) {AssertEqualTHINGStruct(expected, actual);} + #define TEST_ASSERT_EQUAL_STARS_AND_STRIPES(expected, actual) {AssertEqualSTARS_AND_STRIPESUnion(expected, actual);} + + :code: | + void AssertEqualTHINGStruct(struct THING expected, struct THING actual) + { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected.a, actual.a, "actual struct member \"a\" does not equal expected"); + TEST_ASSERT_EQUAL_INT_MESSAGE(expected.b, actual.b, "actual struct member \"b\" does not equal expected"); + } + + void AssertEqualSTARS_AND_STRIPESUnion(union STARS_AND_STRIPES expected, union STARS_AND_STRIPES actual) + { + TEST_ASSERT_EQUAL_INT_MESSAGE(expected.a, actual.a, "actual union member \"a\" does not equal expected"); + TEST_ASSERT_EQUAL_MESSAGE(expected.b, actual.b, "actual union member \"b\" does not equal expected"); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/stubs_with_callbacks.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/stubs_with_callbacks.yml new file mode 100644 index 000000000..1f2575481 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/stubs_with_callbacks.yml @@ -0,0 +1,221 @@ +--- +:cmock: + :plugins: + - :callback + :treat_as: + custom_type: INT + +:systest: + :types: | + #define UINT32 unsigned int + + typedef signed int custom_type; + + :mockable: | + UINT32 foo(custom_type* a); + UINT32 bar(custom_type* b); + int baz(void); + void fuz(int* args, int num); + + :source: + :header: | + void function_a(int a, int b); + UINT32 function_b(void); + int function_c(void); + + :code: | + void function_a(int a, int b) + { + int args[6] = {0, 1, 2, 3, 5, 5}; + args[0] = a; + fuz(args, b); + } + + UINT32 function_b(void) + { + UINT32 sum = 0; + custom_type a = 0; + custom_type b = 0; + sum = foo(&a) + bar(&b); + return (UINT32)((custom_type)sum + a + b); + } + + int function_c(void) + { + return (baz() + baz() + baz()); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + UINT32 FooAndBarHelper(custom_type* data, int num) + { + num++; + *data = (custom_type)(num * 2); + return (UINT32)(*data * 2); + } + + int BazCallbackPointless(int num) + { + return num; + } + + int BazCallbackComplainsIfCalledMoreThanTwice(int num) + { + TEST_ASSERT_MESSAGE(num < 2, "Do Not Call Baz More Than Twice"); + return num; + } + + void FuzVerifier(int* args, int num_args, int num_calls) + { + int i; + TEST_ASSERT_MESSAGE(num_args < 5, "No More Than 5 Args Allowed"); + for (i = 0; i < num_args; i++) + { + TEST_ASSERT_EQUAL(num_calls + i, args[i]); + } + } + + :units: + - :pass: TRUE + :should: 'successfully exercise two simple ExpectAndReturn mock calls the normal way' + :code: | + test() + { + custom_type exp = 0; + foo_ExpectAndReturn(&exp, 10); + bar_ExpectAndReturn(&exp, 20); + TEST_ASSERT_EQUAL(30, function_b()); + } + + - :pass: FALSE + :should: 'successfully exercise two simple ExpectAndReturn mock calls and catch failure the normal way' + :code: | + test() + { + custom_type exp = 1; + foo_ExpectAndReturn(&exp, 10); + bar_ExpectAndReturn(&exp, 20); + TEST_ASSERT_EQUAL(30, function_b()); + } + + - :pass: TRUE + :should: 'successfully exercise using some basic callbacks' + :code: | + test() + { + foo_StubWithCallback((CMOCK_foo_CALLBACK)FooAndBarHelper); + bar_StubWithCallback((CMOCK_bar_CALLBACK)FooAndBarHelper); + TEST_ASSERT_EQUAL(12, function_b()); + } + + - :pass: TRUE + :should: 'successfully exercise using some basic callbacks even if there were expects' + :code: | + test() + { + custom_type exp = 500; + foo_ExpectAndReturn(&exp, 10); + foo_StubWithCallback((CMOCK_foo_CALLBACK)FooAndBarHelper); + bar_StubWithCallback((CMOCK_bar_CALLBACK)FooAndBarHelper); + TEST_ASSERT_EQUAL(12, function_b()); + } + + - :pass: FALSE + :should: 'successfully exercise using some basic callbacks and notice failures' + :code: | + test() + { + foo_StubWithCallback((CMOCK_foo_CALLBACK)FooAndBarHelper); + bar_StubWithCallback((CMOCK_bar_CALLBACK)FooAndBarHelper); + TEST_ASSERT_EQUAL(10, function_b()); + } + + - :pass: TRUE + :should: 'successfully exercise a callback with no arguments' + :code: | + test() + { + baz_StubWithCallback((CMOCK_baz_CALLBACK)BazCallbackPointless); + TEST_ASSERT_EQUAL(3, function_c()); + } + + - :pass: FALSE + :should: 'successfully throw a failure from within a callback function' + :code: | + test() + { + baz_StubWithCallback((CMOCK_baz_CALLBACK)BazCallbackComplainsIfCalledMoreThanTwice); + function_c(); + } + + - :pass: TRUE + :should: 'be usable for things like dynamically sized memory checking for passing conditions' + :code: | + test() + { + fuz_StubWithCallback((CMOCK_fuz_CALLBACK)FuzVerifier); + function_a(0, 4); + } + + - :pass: FALSE + :should: 'be usable for things like dynamically sized memory checking for failing conditions' + :code: | + test() + { + fuz_StubWithCallback((CMOCK_fuz_CALLBACK)FuzVerifier); + function_a(0, 5); + } + + - :pass: FALSE + :should: 'be usable for things like dynamically sized memory checking for failing conditions 2' + :code: | + test() + { + fuz_StubWithCallback((CMOCK_fuz_CALLBACK)FuzVerifier); + function_a(1, 4); + } + + - :pass: TRUE + :should: 'run them interlaced' + :code: | + test() + { + custom_type exp = 0; + foo_ExpectAndReturn(&exp, 10); + foo_ExpectAndReturn(&exp, 15); + bar_ExpectAndReturn(&exp, 20); + bar_ExpectAndReturn(&exp, 40); + fuz_StubWithCallback((CMOCK_fuz_CALLBACK)FuzVerifier); + baz_StubWithCallback((CMOCK_baz_CALLBACK)BazCallbackPointless); + + TEST_ASSERT_EQUAL(30, function_b()); + TEST_ASSERT_EQUAL(55, function_b()); + function_a(0, 4); + TEST_ASSERT_EQUAL(3, function_c()); + } + + - :pass: TRUE + :should: 'run them back to back' + :code: | + test() + { + custom_type exp = 0; + foo_ExpectAndReturn(&exp, 10); + bar_ExpectAndReturn(&exp, 20); + TEST_ASSERT_EQUAL(30, function_b()); + + foo_ExpectAndReturn(&exp, 15); + bar_ExpectAndReturn(&exp, 40); + TEST_ASSERT_EQUAL(55, function_b()); + + fuz_StubWithCallback((CMOCK_fuz_CALLBACK)FuzVerifier); + function_a(0, 4); + + baz_StubWithCallback((CMOCK_baz_CALLBACK)BazCallbackPointless); + TEST_ASSERT_EQUAL(3, function_c()); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_64bit_support.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_64bit_support.yml new file mode 100644 index 000000000..861b15148 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_64bit_support.yml @@ -0,0 +1,77 @@ +--- +#The purpose of this test is to play with things 64-bit integers, which aren't supported by all compilers +:cmock: + :plugins: + - :array + - :ignore + +:systest: + :types: | + #include "unity_internals.h" + typedef UNITY_UINT64 TEST64; + + :mockable: | + TEST64 foo(TEST64 a); + TEST64* bar(TEST64* b); + + :source: + :header: | + TEST64 function_a(void); + + :code: | + TEST64 function_a(void) { + TEST64 a = 0x1234567890123456; + TEST64 b; + TEST64* c; + + b = foo(a); + c = bar(&b); + return *c; + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle a straightforward 64-bit series of calls' + :code: | + test() + { + TEST64 a = 0x0987654321543210; + TEST64 b = 0x5a5a5a5a5a5a5a5a; + foo_ExpectAndReturn(0x1234567890123456, 0x0987654321543210); + bar_ExpectAndReturn(&a, &b); + + TEST_ASSERT_EQUAL_HEX64(b, function_a()); + } + + - :pass: FALSE + :should: 'handle a straightforward 64-bit series of calls with a failure' + :code: | + test() + { + TEST64 a = 0x0987654321543210; + TEST64 b = 0x5a5a5a5a5a5a5a5a; + foo_ExpectAndReturn(0x1234567890123456, 0x0987654321543211); + bar_ExpectAndReturn(&a, &b); + + TEST_ASSERT_EQUAL_HEX64(b, function_a()); + } + + - :pass: FALSE + :should: 'handle a straightforward 64-bit series of calls returning a failure' + :code: | + test() + { + TEST64 a = 0x0987654321543210; + TEST64 b = 0x5a5a5a5a5a5a5a5a; + foo_ExpectAndReturn(0x1234567890123456, 0x0987654321543210); + bar_ExpectAndReturn(&a, &b); + + TEST_ASSERT_EQUAL_HEX64(b+1, function_a()); + } + +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_ignores.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_ignores.yml new file mode 100644 index 000000000..8595122b2 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_ignores.yml @@ -0,0 +1,139 @@ +--- +:cmock: + :plugins: + - # none + +:systest: + :types: | + #define UINT32 unsigned int + + :mockable: | + UINT32 foo(UINT32 a); + void bar(void); + + :source: + :header: | + UINT32 function_a(int a); + void function_b(void); + + :code: | + UINT32 function_a(int a) + { + bar(); + return foo((UINT32)a); + } + + void function_b(void) + { + bar(); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: :ignore + :should: 'ignore incorrect expects after the TEST_IGNORE call' + :code: | + test() + { + TEST_IGNORE(); + bar_Expect(); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(40, function_a(30)); + } + + - :pass: :ignore + :should: 'ignore missing expects after the TEST_IGNORE call' + :code: | + test() + { + TEST_IGNORE(); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(20, function_a(10)); + } + + - :pass: :ignore + :should: 'ignore extra expects after the TEST_IGNORE call' + :code: | + test() + { + TEST_IGNORE(); + bar_Expect(); + bar_Expect(); + foo_ExpectAndReturn(10, 20); + foo_ExpectAndReturn(10, 20); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(20, function_a(10)); + } + + - :pass: :ignore + :should: 'ignore no expects after the TEST_IGNORE call' + :code: | + test() + { + TEST_IGNORE(); + TEST_ASSERT_EQUAL(20, function_a(10)); + } + + - :pass: :ignore + :should: 'ignore extra expects after the TEST_IGNORE call even if it happens later' + :code: | + test() + { + bar_Expect(); + foo_ExpectAndReturn(10, 20); + function_a(10); + + TEST_IGNORE(); + bar_Expect(); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(40, function_a(30)); + } + + - :pass: false + :should: 'still fail if there are expect problems before the TEST_IGNORE' + :code: | + test() + { + bar_Expect(); + foo_ExpectAndReturn(10, 20); + function_a(30); + + TEST_IGNORE(); + bar_Expect(); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(40, function_a(30)); + } + + - :pass: false + :should: 'still fail if there are missing expect problems before the TEST_IGNORE' + :code: | + test() + { + bar_Expect(); + function_a(10); + + TEST_IGNORE(); + bar_Expect(); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(40, function_a(30)); + } + + - :pass: :ignore + :should: 'ignore if extra expects before the TEST_IGNORE because it ignored the rest of the test that might have made calls to it' + :code: | + test() + { + bar_Expect(); + bar_Expect(); + foo_ExpectAndReturn(10, 20); + function_a(10); + + TEST_IGNORE(); + foo_ExpectAndReturn(10, 20); + TEST_ASSERT_EQUAL(40, function_a(30)); + } +... diff --git a/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_void_pointer_compare.yml b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_void_pointer_compare.yml new file mode 100644 index 000000000..1a49b0cd3 --- /dev/null +++ b/FreeRTOS-Plus/Test/CMock/test/system/test_interactions/unity_void_pointer_compare.yml @@ -0,0 +1,91 @@ +--- +#The purpose of this test is to verify we handle void pointers as memory compares +:cmock: + :plugins: + - :array + :treat_as_array: + VOID_PTR: unsigned char + +:systest: + :types: | + #include "unity_internals.h" + typedef void* VOID_PTR; + + :mockable: | + void* ret_v_ptr(void); + void get_v_ptr(void* ptr); + void get_v_ptr_typedefed(VOID_PTR ptr); + + :source: + :header: | + void function_a(void); + + :code: | + void function_a(void) { + void* stuff = ret_v_ptr(); + get_v_ptr(stuff); + get_v_ptr_typedefed((VOID_PTR)stuff); + } + + :tests: + :common: | + void setUp(void) {} + void tearDown(void) {} + + :units: + - :pass: TRUE + :should: 'handle passing working expects' + :code: | + test() + { + char* a = "Hello"; + char* b = "Hello"; + ret_v_ptr_ExpectAndReturn(a); + get_v_ptr_Expect(b); + get_v_ptr_typedefed_Expect((VOID_PTR)b); + + function_a(); + } + + - :pass: TRUE + :should: 'handle passing array expects' + :code: | + test() + { + char* a = "Hello"; + char* b = "Hello"; + ret_v_ptr_ExpectAndReturn(a); + get_v_ptr_ExpectWithArray(b,5); + get_v_ptr_typedefed_ExpectWithArray((VOID_PTR)b,5); + + function_a(); + } + + - :pass: FALSE + :should: 'handle failing expects' + :code: | + test() + { + char* a = "Hello"; + char* b = "Jello"; + ret_v_ptr_ExpectAndReturn(a); + get_v_ptr_Expect(b); + get_v_ptr_typedefed_Expect((VOID_PTR)b); + + function_a(); + } + + - :pass: FALSE + :should: 'handle failing array expects' + :code: | + test() + { + char* a = "Hello"; + char* b = "Hella"; + ret_v_ptr_ExpectAndReturn(a); + get_v_ptr_ExpectWithArray(b,5); + get_v_ptr_typedefed_ExpectWithArray((VOID_PTR)b,5); + + function_a(); + } +... |