Laurence Lundblade | f156fb8 | 2018-10-01 09:47:03 -0700 | [diff] [blame] | 1 | |
| 2 | /*============================================================================== |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 3 | run_tests.h -- test aggregator and results reporting |
Laurence Lundblade | 3aee3a3 | 2018-12-17 16:17:45 -0800 | [diff] [blame] | 4 | |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 5 | Created 9/30/18. |
| 6 | |
Laurence Lundblade | 2da5d08 | 2019-01-10 09:56:50 -0800 | [diff] [blame] | 7 | Copyright (c) 2018-2019, Laurence Lundblade. |
Laurence Lundblade | d92a616 | 2018-11-01 11:38:35 +0700 | [diff] [blame] | 8 | All rights reserved. |
Laurence Lundblade | 3aee3a3 | 2018-12-17 16:17:45 -0800 | [diff] [blame] | 9 | |
Laurence Lundblade | 0dbc917 | 2018-11-01 14:17:21 +0700 | [diff] [blame] | 10 | Redistribution and use in source and binary forms, with or without |
| 11 | modification, are permitted provided that the following conditions are |
| 12 | met: |
| 13 | * Redistributions of source code must retain the above copyright |
| 14 | notice, this list of conditions and the following disclaimer. |
| 15 | * Redistributions in binary form must reproduce the above |
| 16 | copyright notice, this list of conditions and the following |
| 17 | disclaimer in the documentation and/or other materials provided |
| 18 | with the distribution. |
| 19 | * The name "Laurence Lundblade" may not be used to |
| 20 | endorse or promote products derived from this software without |
| 21 | specific prior written permission. |
Laurence Lundblade | 3aee3a3 | 2018-12-17 16:17:45 -0800 | [diff] [blame] | 22 | |
Laurence Lundblade | 0dbc917 | 2018-11-01 14:17:21 +0700 | [diff] [blame] | 23 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 24 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 26 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 27 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 28 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 29 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 30 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 31 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 32 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 33 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Laurence Lundblade | f156fb8 | 2018-10-01 09:47:03 -0700 | [diff] [blame] | 34 | ==============================================================================*/ |
Laurence Lundblade | 8ca1369 | 2018-12-04 14:35:53 +0900 | [diff] [blame] | 35 | |
Laurence Lundblade | df1c1cf | 2019-01-17 11:55:05 -0800 | [diff] [blame] | 36 | /** |
| 37 | @file run_tests.h |
| 38 | */ |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 39 | |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 40 | /** |
| 41 | @brief Type for function to output a text string |
Laurence Lundblade | 8ca1369 | 2018-12-04 14:35:53 +0900 | [diff] [blame] | 42 | |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 43 | @param[in] szString The string to output |
| 44 | @param[in] pOutCtx A context pointer; NULL if not needed |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 45 | @param[in] bNewline If non-zero, output a newline after the string |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 46 | |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 47 | This is a prototype of a function to be passed to RunTests() to |
Laurence Lundblade | 9dddd9c | 2019-01-19 15:28:07 -0800 | [diff] [blame] | 48 | output text strings. |
Laurence Lundblade | df1c1cf | 2019-01-17 11:55:05 -0800 | [diff] [blame] | 49 | |
| 50 | This can be implemented with stdio (if available) using a straight |
| 51 | call to fputs() where the FILE * is passed as the pOutCtx as shown in |
| 52 | the example code below. This code is for Linux where the newline is |
| 53 | a \\n. Windows usually prefers \\r\\n. |
Laurence Lundblade | 9dddd9c | 2019-01-19 15:28:07 -0800 | [diff] [blame] | 54 | |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 55 | @code |
| 56 | static void fputs_wrapper(const char *szString, void *pOutCtx, int bNewLine) |
| 57 | { |
| 58 | fputs(szString, (FILE *)pOutCtx); |
| 59 | if(bNewLine) { |
| 60 | fputs("\n", pOutCtx); |
| 61 | } |
| 62 | } |
| 63 | @endcode |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 64 | */ |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 65 | typedef void (*OutputStringCB)(const char *szString, void *pOutCtx, int bNewline); |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 66 | |
| 67 | |
| 68 | /** |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 69 | @brief Runs the QCBOR tests. |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 70 | |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 71 | @param[in] szTestNames An argv-style list of test names to run. If |
| 72 | empty, all are run. |
| 73 | @param[in] pfOutput Function that is called to output text strings. |
| 74 | @param[in] pOutCtx Context pointer passed to output function. |
| 75 | @param[out] pNumTestsRun Returns the number of tests run. May be NULL. |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 76 | |
| 77 | @return The number of tests that failed. Zero means overall success. |
| 78 | */ |
| 79 | int RunTests(const char *szTestNames[], OutputStringCB pfOutput, void *pOutCtx, int *pNumTestsRun); |
| 80 | |
| 81 | |
| 82 | /** |
| 83 | @brief Print sizes of encoder / decoder contexts. |
| 84 | |
Laurence Lundblade | d396f62 | 2019-01-12 17:12:29 -0800 | [diff] [blame] | 85 | @param[in] pfOutput Function that is called to output text strings. |
| 86 | @param[in] pOutCtx Context pointer passed to output function. |
Laurence Lundblade | 1f8b5b0 | 2019-01-01 22:27:38 -0800 | [diff] [blame] | 87 | */ |
| 88 | void PrintSizes(OutputStringCB pfOutput, void *pOutCtx); |
Laurence Lundblade | 8ca1369 | 2018-12-04 14:35:53 +0900 | [diff] [blame] | 89 | |