From: Victor Julien Date: Wed, 27 Apr 2022 14:54:49 +0000 (+0200) Subject: unittests: wrap unittest registration in guards X-Git-Tag: suricata-7.0.0-beta1~615 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b55c8909c3d6aaf598d6070db9171488c8780340;p=thirdparty%2Fsuricata.git unittests: wrap unittest registration in guards --- diff --git a/src/util-action.c b/src/util-action.c index 96991b5c2c..cf052e5270 100644 --- a/src/util-action.c +++ b/src/util-action.c @@ -1590,12 +1590,9 @@ done: return res; } -#endif - /* Register unittests */ void UtilActionRegisterTests(void) { -#ifdef UNITTESTS /* Generic tests */ UtRegisterTest("UtilActionTest01", UtilActionTest01); UtRegisterTest("UtilActionTest02", UtilActionTest02); @@ -1622,5 +1619,5 @@ void UtilActionRegisterTests(void) UtRegisterTest("UtilActionTest22", UtilActionTest22); UtRegisterTest("UtilActionTest23", UtilActionTest23); UtRegisterTest("UtilActionTest24", UtilActionTest24); -#endif } +#endif diff --git a/src/util-action.h b/src/util-action.h index 0413067609..6c96ba08b6 100644 --- a/src/util-action.h +++ b/src/util-action.h @@ -28,6 +28,7 @@ int ActionInitConfig(void); uint8_t ActionOrderVal(uint8_t); +#ifdef UNITTESTS void UtilActionRegisterTests(void); - +#endif #endif /* __ACTION_ORDER_H__ */ diff --git a/src/util-misc.c b/src/util-misc.c index e5feb1be02..32816f8e33 100644 --- a/src/util-misc.c +++ b/src/util-misc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -1166,14 +1166,9 @@ static int UtilMiscParseSizeStringTest01(void) return 0; } -#endif /* UNITTESTS */ - void UtilMiscRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("UtilMiscParseSizeStringTest01", UtilMiscParseSizeStringTest01); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ diff --git a/src/util-misc.h b/src/util-misc.h index e39e487952..8ae730931a 100644 --- a/src/util-misc.h +++ b/src/util-misc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -47,7 +47,10 @@ int ParseSizeStringU8(const char *, uint8_t *); int ParseSizeStringU16(const char *, uint16_t *); int ParseSizeStringU32(const char *, uint32_t *); int ParseSizeStringU64(const char *, uint64_t *); + +#ifdef UNITTESTS void UtilMiscRegisterTests(void); +#endif /* UNITTESTS */ void ParseSizeInit(void); void ParseSizeDeinit(void); diff --git a/src/util-spm.c b/src/util-spm.c index 0652758e70..b3b14d7f71 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2014 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -2671,12 +2671,9 @@ static int SpmSearchTest02(void) { return ret; } -#endif - /* Register unittests */ void UtilSpmSearchRegistertests(void) { -#ifdef UNITTESTS /* Generic tests */ UtRegisterTest("UtilSpmBasicSearchTest01", UtilSpmBasicSearchTest01); UtRegisterTest("UtilSpmBasicSearchNocaseTest01", @@ -2743,6 +2740,6 @@ void UtilSpmSearchRegistertests(void) UtRegisterTest("UtilSpmNocaseSearchStatsTest07", UtilSpmNocaseSearchStatsTest07); -#endif #endif } +#endif diff --git a/src/util-spm.h b/src/util-spm.h index dbffb2bf30..6e4372f40a 100644 --- a/src/util-spm.h +++ b/src/util-spm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -120,5 +120,7 @@ uint8_t *BoyerMooreNocaseSearch(const uint8_t *text, uint32_t textlen, uint8_t * mfound; \ }) +#ifdef UNITTESTS void UtilSpmSearchRegistertests(void); +#endif #endif /* __UTIL_SPM_H__ */