blob: 850c4e2bdc978c058263e5826cc4ab31d6e4281d [file] [log] [blame]
Laurence Lundbladef156fb82018-10-01 09:47:03 -07001
2/*==============================================================================
Laurence Lundbladed396f622019-01-12 17:12:29 -08003 run_tests.h -- test aggregator and results reporting
Laurence Lundblade3aee3a32018-12-17 16:17:45 -08004
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -08005 Created 9/30/18.
6
Laurence Lundblade2da5d082019-01-10 09:56:50 -08007 Copyright (c) 2018-2019, Laurence Lundblade.
Laurence Lundbladed92a6162018-11-01 11:38:35 +07008 All rights reserved.
Laurence Lundblade3aee3a32018-12-17 16:17:45 -08009
Laurence Lundblade0dbc9172018-11-01 14:17:21 +070010Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are
12met:
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 Lundblade3aee3a32018-12-17 16:17:45 -080022
Laurence Lundblade0dbc9172018-11-01 14:17:21 +070023THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
24WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
27BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Laurence Lundbladef156fb82018-10-01 09:47:03 -070034 ==============================================================================*/
Laurence Lundblade8ca13692018-12-04 14:35:53 +090035
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080036/**
37 @file run_tests.h
38*/
Laurence Lundbladed396f622019-01-12 17:12:29 -080039
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080040/**
41 @brief Type for function to output a text string
Laurence Lundblade8ca13692018-12-04 14:35:53 +090042
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080043 @param[in] szString The string to output
44 @param[in] pOutCtx A context pointer; NULL if not needed
Laurence Lundbladed396f622019-01-12 17:12:29 -080045 @param[in] bNewline If non-zero, output a newline after the string
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080046
Laurence Lundbladed396f622019-01-12 17:12:29 -080047 This is a prototype of a function to be passed to RunTests() to
Laurence Lundblade9dddd9c2019-01-19 15:28:07 -080048 output text strings.
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080049
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 Lundblade9dddd9c2019-01-19 15:28:07 -080054
Laurence Lundbladed396f622019-01-12 17:12:29 -080055 @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 Lundblade1f8b5b02019-01-01 22:27:38 -080064*/
Laurence Lundbladed396f622019-01-12 17:12:29 -080065typedef void (*OutputStringCB)(const char *szString, void *pOutCtx, int bNewline);
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080066
67
68/**
Laurence Lundbladed396f622019-01-12 17:12:29 -080069 @brief Runs the QCBOR tests.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080070
Laurence Lundbladed396f622019-01-12 17:12:29 -080071 @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 Lundblade1f8b5b02019-01-01 22:27:38 -080076
77 @return The number of tests that failed. Zero means overall success.
78 */
79int RunTests(const char *szTestNames[], OutputStringCB pfOutput, void *pOutCtx, int *pNumTestsRun);
80
81
82/**
83 @brief Print sizes of encoder / decoder contexts.
84
Laurence Lundbladed396f622019-01-12 17:12:29 -080085 @param[in] pfOutput Function that is called to output text strings.
86 @param[in] pOutCtx Context pointer passed to output function.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080087 */
88void PrintSizes(OutputStringCB pfOutput, void *pOutCtx);
Laurence Lundblade8ca13692018-12-04 14:35:53 +090089