blob: 370558aae086747f005e1c4174393ce08a9b9d29 [file] [log] [blame]
Laurence Lundbladef156fb82018-10-01 09:47:03 -07001/*==============================================================================
Laurence Lundbladed396f622019-01-12 17:12:29 -08002 run_tests.h -- test aggregator and results reporting
Laurence Lundblade3aee3a32018-12-17 16:17:45 -08003
Laurence Lundbladeee851742020-01-08 08:37:05 -08004 Copyright (c) 2018-2020, Laurence Lundblade. All rights reserved.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -08005
Laurence Lundbladea3fd49f2019-01-21 10:16:22 -08006 SPDX-License-Identifier: BSD-3-Clause
Laurence Lundblade035bd782019-01-21 17:01:31 -08007
Laurence Lundblade4903e552024-08-21 11:13:48 -07008 See BSD-3-Clause license in file named "LICENSE"
Laurence Lundblade035bd782019-01-21 17:01:31 -08009
Laurence Lundbladea3fd49f2019-01-21 10:16:22 -080010 Created 9/30/18
Laurence Lundbladeee851742020-01-08 08:37:05 -080011 =============================================================================*/
Laurence Lundblade8ca13692018-12-04 14:35:53 +090012
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080013/**
14 @file run_tests.h
15*/
Laurence Lundbladed396f622019-01-12 17:12:29 -080016
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080017/**
18 @brief Type for function to output a text string
Laurence Lundblade8ca13692018-12-04 14:35:53 +090019
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080020 @param[in] szString The string to output
21 @param[in] pOutCtx A context pointer; NULL if not needed
Laurence Lundbladed396f622019-01-12 17:12:29 -080022 @param[in] bNewline If non-zero, output a newline after the string
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080023
Laurence Lundbladed396f622019-01-12 17:12:29 -080024 This is a prototype of a function to be passed to RunTests() to
Laurence Lundblade9dddd9c2019-01-19 15:28:07 -080025 output text strings.
Laurence Lundbladedf1c1cf2019-01-17 11:55:05 -080026
27 This can be implemented with stdio (if available) using a straight
28 call to fputs() where the FILE * is passed as the pOutCtx as shown in
29 the example code below. This code is for Linux where the newline is
30 a \\n. Windows usually prefers \\r\\n.
Laurence Lundblade9dddd9c2019-01-19 15:28:07 -080031
Laurence Lundbladed396f622019-01-12 17:12:29 -080032 @code
33 static void fputs_wrapper(const char *szString, void *pOutCtx, int bNewLine)
34 {
35 fputs(szString, (FILE *)pOutCtx);
36 if(bNewLine) {
37 fputs("\n", pOutCtx);
38 }
39 }
40 @endcode
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080041*/
Laurence Lundbladed396f622019-01-12 17:12:29 -080042typedef void (*OutputStringCB)(const char *szString, void *pOutCtx, int bNewline);
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080043
44
45/**
Laurence Lundbladed396f622019-01-12 17:12:29 -080046 @brief Runs the QCBOR tests.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080047
Laurence Lundbladed396f622019-01-12 17:12:29 -080048 @param[in] szTestNames An argv-style list of test names to run. If
49 empty, all are run.
50 @param[in] pfOutput Function that is called to output text strings.
51 @param[in] pOutCtx Context pointer passed to output function.
52 @param[out] pNumTestsRun Returns the number of tests run. May be NULL.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080053
54 @return The number of tests that failed. Zero means overall success.
55 */
Laurence Lundblade29501b72020-01-16 15:05:18 -080056int RunTestsQCBOR(const char *szTestNames[],
57 OutputStringCB pfOutput,
58 void *pOutCtx,
59 int *pNumTestsRun);
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080060
61
62/**
Laurence Lundblade475c2722024-05-08 11:17:47 -070063 @brief Print sizes of encoder-decoder contexts.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080064
Laurence Lundbladed396f622019-01-12 17:12:29 -080065 @param[in] pfOutput Function that is called to output text strings.
66 @param[in] pOutCtx Context pointer passed to output function.
Laurence Lundblade1f8b5b02019-01-01 22:27:38 -080067 */
Laurence Lundblade29501b72020-01-16 15:05:18 -080068void PrintSizesQCBOR(OutputStringCB pfOutput, void *pOutCtx);
Laurence Lundblade8ca13692018-12-04 14:35:53 +090069