@ -24,6 +24,14 @@
* Unit test framework
* Unit test framework
*/
*/
/**
* \ defgroup Testing Testing
*
* \ brief Unit testing support functions .
*
* @ {
*/
# include "suricata-common.h"
# include "suricata-common.h"
# include "runmodes.h"
# include "runmodes.h"
# include "util-unittest.h"
# include "util-unittest.h"
@ -38,6 +46,8 @@ static pcre_extra *parse_regex_study;
static UtTest * ut_list ;
static UtTest * ut_list ;
int unittests_fatal = 0 ;
/**
/**
* \ brief Allocate UtTest list member
* \ brief Allocate UtTest list member
*
*
@ -181,12 +191,6 @@ uint32_t UtRunTests(char *regex_arg)
uint32_t good = 0 , bad = 0 , matchcnt = 0 ;
uint32_t good = 0 , bad = 0 , matchcnt = 0 ;
int ret = 0 , rcomp = 0 ;
int ret = 0 , rcomp = 0 ;
int ov [ MAX_SUBSTRINGS ] ;
int ov [ MAX_SUBSTRINGS ] ;
int failure_fatal ;
if ( ConfGetBool ( " unittests.failure-fatal " , & failure_fatal ) ! = 1 ) {
SCLogDebug ( " ConfGetBool could not load the value. " ) ;
failure_fatal = 0 ;
}
rcomp = UtRegex ( regex_arg ) ;
rcomp = UtRegex ( regex_arg ) ;
@ -205,7 +209,7 @@ uint32_t UtRunTests(char *regex_arg)
ret = ut - > TestFn ( ) ;
ret = ut - > TestFn ( ) ;
printf ( " %s \n " , ret ? " pass " : " FAILED " ) ;
printf ( " %s \n " , ret ? " pass " : " FAILED " ) ;
if ( ! ret ) {
if ( ! ret ) {
if ( failure _fatal = = 1 ) {
if ( unittests _fatal = = 1 ) {
fprintf ( stderr , " ERROR: unittest failed. \n " ) ;
fprintf ( stderr , " ERROR: unittest failed. \n " ) ;
exit ( EXIT_FAILURE ) ;
exit ( EXIT_FAILURE ) ;
}
}
@ -292,6 +296,7 @@ int UtSelftestFalse(void)
if ( 0 ) return 0 ;
if ( 0 ) return 0 ;
else return 1 ;
else return 1 ;
}
}
# endif /* UNITTESTS */
# endif /* UNITTESTS */
/** \brief Run self tests
/** \brief Run self tests
@ -321,3 +326,7 @@ int UtRunSelftest (char *regex_arg)
# endif /* UNITTESTS */
# endif /* UNITTESTS */
return 0 ;
return 0 ;
}
}
/**
* @ }
*/