blob: 438d55ef01f707c2c1c29ac04d5f6e9cf61a46ba [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
36
Laurence Lundbladed396f622019-01-12 17:12:29 -080037
38
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080039/**
40 @brief Type for function to output a text string
Laurence Lundblade8ca13692018-12-04 14:35:53 +090041
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080042 @param[in] szString The string to output
43 @param[in] pOutCtx A context pointer; NULL if not needed
Laurence Lundbladed396f622019-01-12 17:12:29 -080044 @param[in] bNewline If non-zero, output a newline after the string
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080045
Laurence Lundbladed396f622019-01-12 17:12:29 -080046 This is a prototype of a function to be passed to RunTests() to
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080047 output text strings. This can be implemented with stdio (if
48 available) using a straight call to fputs() where the FILE *
49 is passed as the ctx.
Laurence Lundbladed396f622019-01-12 17:12:29 -080050
51 @code
52 static void fputs_wrapper(const char *szString, void *pOutCtx, int bNewLine)
53 {
54 fputs(szString, (FILE *)pOutCtx);
55 if(bNewLine) {
56 fputs("\n", pOutCtx);
57 }
58 }
59 @endcode
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080060*/
Laurence Lundbladed396f622019-01-12 17:12:29 -080061typedef void (*OutputStringCB)(const char *szString, void *pOutCtx, int bNewline);
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080062
63
64/**
Laurence Lundbladed396f622019-01-12 17:12:29 -080065 @brief Runs the QCBOR tests.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080066
Laurence Lundbladed396f622019-01-12 17:12:29 -080067 @param[in] szTestNames An argv-style list of test names to run. If
68 empty, all are run.
69 @param[in] pfOutput Function that is called to output text strings.
70 @param[in] pOutCtx Context pointer passed to output function.
71 @param[out] pNumTestsRun Returns the number of tests run. May be NULL.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080072
73 @return The number of tests that failed. Zero means overall success.
74 */
75int RunTests(const char *szTestNames[], OutputStringCB pfOutput, void *pOutCtx, int *pNumTestsRun);
76
77
78/**
79 @brief Print sizes of encoder / decoder contexts.
80
Laurence Lundbladed396f622019-01-12 17:12:29 -080081 @param[in] pfOutput Function that is called to output text strings.
82 @param[in] pOutCtx Context pointer passed to output function.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080083 */
84void PrintSizes(OutputStringCB pfOutput, void *pOutCtx);
Laurence Lundblade8ca13692018-12-04 14:35:53 +090085