libsir 2.2.5
Standard Incident Reporter
Loading...
Searching...
No Matches
tests.h
1/*
2 * tests.h
3 *
4 * Version: 2.2.5
5 *
6 * ----------------------------------------------------------------------------
7 *
8 * SPDX-License-Identifier: MIT
9 *
10 * Copyright (c) 2018-2024 Ryan M. Lederman <lederman@gmail.com>
11 * Copyright (c) 2018-2024 Jeffrey H. Johnson <trnsz@pobox.com>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy of
14 * this software and associated documentation files (the "Software"), to deal in
15 * the Software without restriction, including without limitation the rights to
16 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17 * the Software, and to permit persons to whom the Software is furnished to do so,
18 * subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in all
21 * copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
26 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
27 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 *
30 * ----------------------------------------------------------------------------
31 */
32
33#ifndef _SIR_TESTS_H_INCLUDED
34# define _SIR_TESTS_H_INCLUDED
35
36# include "tests_shared.h"
37# include "sir/filecache.h"
38# include "sir/textstyle.h"
39# include "sir/mutex.h"
40# include "sir/threadpool.h"
41# include "sir/queue.h"
42
57bool sirtest_threadrace(void);
58
64bool sirtest_exceedmaxsize(void);
65
71bool sirtest_logwritesanity(void);
72
79
85bool sirtest_failnulls(void);
86
93
100
107
114
120bool sirtest_faildupefile(void);
121
128
135
141bool sirtest_failwithoutinit(void);
142
147bool sirtest_isinitialized(void);
148
154bool sirtest_failinittwice(void);
155
162
168bool sirtest_initcleanupinit(void);
169
175bool sirtest_initmakeinit(void);
176
182bool sirtest_failaftercleanup(void);
183
189bool sirtest_errorsanity(void);
190
196bool sirtest_textstylesanity(void);
197
203bool sirtest_optionssanity(void);
204
210bool sirtest_levelssanity(void);
211
217bool sirtest_mutexsanity(void);
218
224bool sirtest_perf(void);
225
231bool sirtest_updatesanity(void);
232
238bool sirtest_threadidsanity(void);
239
246bool sirtest_syslog(void);
247
254bool sirtest_os_log(void);
255
262bool sirtest_win_eventlog(void);
263
269bool sirtest_filesystem(void);
270
277bool sirtest_squelchspam(void);
278
285bool sirtest_pluginloader(void);
286
292bool sirtest_stringutils(void);
293
299bool sirtest_getcpucount(void);
300
306bool sirtest_getversioninfo(void);
307
314bool sirtest_threadpool(void);
315
323# if defined(SIR_OS_LOG_ENABLED)
324void os_log_parent_activity(void* ctx);
325void os_log_child_activity(void* ctx);
326# endif
327
328/*
329 * Utility functions, macros, and types
330 */
331
332# define INIT_BASE(var, l_stdout, o_stdout, l_stderr, o_stderr, p_name, init) \
333 sirinit var = {0}; \
334 var.d_stdout.opts = (o_stdout) > 0 ? (o_stdout) : SIRO_DEFAULT; \
335 var.d_stdout.levels = (l_stdout); \
336 var.d_stderr.opts = (o_stderr) > 0 ? (o_stderr) : SIRO_DEFAULT; \
337 var.d_stderr.levels = (l_stderr); \
338 if (_sir_validstrnofail(p_name)) \
339 (void)_sir_strncpy(var.name, SIR_MAXNAME, (p_name), SIR_MAXNAME); \
340 bool var##_init = false; \
341 if (init) \
342 var##_init = sir_init(&var); \
343 else \
344 (void)var##_init
345
346# define INIT_N(var, l_stdout, o_stdout, l_stderr, o_stderr, name) \
347 INIT_BASE(var, l_stdout, o_stdout, l_stderr, o_stderr, name, true)
348
349# define INIT_SL(var, l_stdout, o_stdout, l_stderr, o_stderr, name) \
350 INIT_BASE(var, l_stdout, o_stdout, l_stderr, o_stderr, name, false)
351
352# define INIT(var, l_stdout, o_stdout, l_stderr, o_stderr) \
353 INIT_N(var, l_stdout, o_stdout, l_stderr, o_stderr, "")
354
360bool filter_error(bool pass, uint16_t err);
361
365char* get_wineversion(void);
366
370bool roll_and_archive(const char* filename, const char* extension);
371
372#endif /* !_SIR_TESTS_H_INCLUDED */
bool sirtest_textstylesanity(void)
Properly style stdio output for each level, and handle style overrides.
Definition tests.c:773
bool sirtest_rollandarchivefile(void)
Properly roll/archive a file when it hits max size.
Definition tests.c:587
bool sirtest_pluginloader(void)
Ensure that well-formed, valid plugins are successfully loaded, and that ill-formed/incorrectly behav...
Definition tests.c:1893
bool sirtest_errorsanity(void)
Properly return valid codes and messages for all possible errors.
Definition tests.c:697
bool sirtest_failinvalidinitdata(void)
Properly handle initialization with junk memory.
Definition tests.c:640
bool sirtest_win_eventlog(void)
Properly open, configure, and send messages to the Windows event log.
Definition tests.c:1535
bool sirtest_faildupefile(void)
Properly refuse to add a duplicate file.
Definition tests.c:504
bool sirtest_squelchspam(void)
Ensure that spam messages are squelched, normal messages are not, and proper return values result fro...
Definition tests.c:1815
bool sirtest_getversioninfo(void)
Ensure that version retrieval exports are functioning properly.
Definition tests.c:2117
bool sirtest_levelssanity(void)
Properly reject invalid level bitmasks.
Definition tests.c:1002
bool sirtest_filecachesanity(void)
Properly handle adding and removing log files.
Definition tests.c:389
bool sirtest_failwithoutinit(void)
Properly handle calls without initialization.
Definition tests.c:596
bool sirtest_os_log(void)
Properly open, configure, and send messages to os_log().
Definition tests.c:1520
bool sirtest_getcpucount(void)
Ensure the processor counting routines are functioning properly.
Definition tests.c:2102
bool sirtest_perf(void)
Performance evaluation.
Definition tests.c:1158
bool sirtest_failremovebadfile(void)
Properly refuse to remove a file that isn't added.
Definition tests.c:573
bool sirtest_stringutils(void)
Ensure the string utility routines are functioning properly.
Definition tests.c:2023
bool sirtest_mutexsanity(void)
Ensure that the mutex implementation is functioning properly.
Definition tests.c:1096
bool sirtest_isinitialized(void)
Definition tests.c:605
bool sirtest_failinvalidfilename(void)
Properly handle invalid log file name.
Definition tests.c:463
bool sirtest_syslog(void)
Properly open, configure, and send messages to syslog().
Definition tests.c:1505
bool sirtest_failfilebadpermission(void)
Properly handle log file without appropriate permissions.
Definition tests.c:476
bool sirtest_exceedmaxsize(void)
Properly handle messages that exceed internal buffer sizes.
Definition tests.c:161
bool sirtest_failnooutputdest(void)
Properly handle the lack of any output destinations.
Definition tests.c:320
bool sirtest_threadpool(void)
Ensure the proper functioning of the thread pool and job queue mech- anisms.
Definition tests.c:2157
bool sirtest_initcleanupinit(void)
Properly handle initialization, cleanup, re-initialization.
Definition tests.c:656
bool sirtest_filesystem(void)
Ensure the proper functionality of portable filesystem implementation.
Definition tests.c:1550
bool sirtest_initmakeinit(void)
Properly initialize using sir_makeinit.
Definition tests.c:672
bool sirtest_failaftercleanup(void)
Properly handle calls after cleanup.
Definition tests.c:684
bool sirtest_optionssanity(void)
Properly reject invalid option bitmasks.
Definition tests.c:893
bool sirtest_threadrace(void)
Properly handle multiple threads competing for locked sections.
Definition tests.c:2200
bool sirtest_logwritesanity(void)
Ensure the correct (and complete) message is written to a log file.
Definition tests.c:175
bool sirtest_failnulls(void)
Properly handle null/empty input.
Definition tests.c:350
bool sirtest_updatesanity(void)
Properly update levels/options at runtime.
Definition tests.c:1260
bool sirtest_failinittwice(void)
Properly handle two initialization calls without corresponding cleanup.
Definition tests.c:626
bool sirtest_failemptymessage(void)
Ensure an empty message is properly handled.
Definition tests.c:379
bool sirtest_threadidsanity(void)
Properly format thread ID/names in output.
Definition tests.c:235