mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-17 09:20:41 +01:00
fixing init and adding tests
This commit is contained in:
parent
006ba9c5b1
commit
79b339c02b
@ -31,6 +31,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <typedefs.h>
|
||||
@ -40,8 +41,6 @@
|
||||
# include <xxhash.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "rsyslog.h"
|
||||
#include "parserif.h"
|
||||
#include "module-template.h"
|
||||
@ -55,8 +54,10 @@ DEF_FMOD_STATIC_DATA
|
||||
|
||||
typedef struct hash_context_s hash_context_t;
|
||||
typedef rsRetVal (*hash_impl)(const void*, size_t, uint32_t, hash_context_t*);
|
||||
typedef rsRetVal (*hash_wrapper_2)(struct svar *, struct svar *, hash_context_t*);
|
||||
typedef rsRetVal (*hash_wrapper_3)(struct svar *, struct svar *, struct svar *, hash_context_t*);
|
||||
typedef rsRetVal (*hash_wrapper_2)(struct svar *__restrict__ const
|
||||
, struct svar *__restrict__ const, hash_context_t*);
|
||||
typedef rsRetVal (*hash_wrapper_3)(struct svar *__restrict__ const, struct svar *__restrict__ const
|
||||
, struct svar *__restrict__ const, hash_context_t*);
|
||||
|
||||
struct hash_context_s {
|
||||
hash_impl hashXX;
|
||||
@ -187,8 +188,8 @@ finalize_it:
|
||||
}
|
||||
|
||||
static rsRetVal
|
||||
hash_wrapper3(struct svar *__restrict__ const sourceVal, struct svar *__restrict__ const modVal,
|
||||
struct svar *__restrict__ const seedVal, hash_context_t* hcontext) {
|
||||
hash_wrapper3(struct svar *__restrict__ const sourceVal, struct svar *__restrict__ const modVal
|
||||
, struct svar *__restrict__ const seedVal, hash_context_t* hcontext) {
|
||||
|
||||
DEFiRet;
|
||||
int success = 0;
|
||||
@ -297,7 +298,7 @@ init_fmHash64(struct cnffunc *const func)
|
||||
func->destructable_funcdata = 1;
|
||||
CHKmalloc(hash_context = calloc(1, sizeof(hash_context_t)));
|
||||
init_hash64_context(hash_context);
|
||||
func->funcdata = (void*)&hash_context;
|
||||
func->funcdata = (void*)hash_context;
|
||||
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
@ -318,7 +319,7 @@ init_fmHash64mod(struct cnffunc *const func)
|
||||
func->destructable_funcdata = 1;
|
||||
CHKmalloc(hash_context = calloc(1, sizeof(hash_context_t)));
|
||||
init_hash64_context(hash_context);
|
||||
func->funcdata = (void*)&hash_context;
|
||||
func->funcdata = (void*)hash_context;
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
@ -338,7 +339,7 @@ init_fmHash32(struct cnffunc *const func)
|
||||
func->destructable_funcdata = 1;
|
||||
CHKmalloc(hash_context = calloc(1, sizeof(hash_context_t)));
|
||||
init_hash32_context(hash_context);
|
||||
func->funcdata = (void*)&hash_context;
|
||||
func->funcdata = (void*)hash_context;
|
||||
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
@ -359,7 +360,7 @@ init_fmHash32mod(struct cnffunc *const func)
|
||||
func->destructable_funcdata = 1;
|
||||
CHKmalloc(hash_context = calloc(1, sizeof(hash_context_t)));
|
||||
init_hash32_context(hash_context);
|
||||
func->funcdata = (void*)&hash_context;
|
||||
func->funcdata = (void*)hash_context;
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
@ -371,7 +372,6 @@ destruct_fmhash(struct cnffunc *const func)
|
||||
if(((hash_context_t*)func->funcdata)->xhash != NULL) {
|
||||
free((void*)((hash_context_t*)func->funcdata)->xhash);
|
||||
}
|
||||
free((void*) ((hash_context_t*)func->funcdata));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -543,6 +543,7 @@ TESTS += \
|
||||
imptcp-NUL.sh \
|
||||
imptcp-NUL-rawmsg.sh \
|
||||
rscript_random.sh \
|
||||
rscript_hash32.sh \
|
||||
rscript_hash64.sh \
|
||||
rscript_replace.sh
|
||||
if HAVE_VALGRIND
|
||||
@ -1681,6 +1682,8 @@ EXTRA_DIST= \
|
||||
testsuites/tokenized_input \
|
||||
rscript_random.sh \
|
||||
testsuites/rscript_random.conf \
|
||||
rscript_hash32.sh \
|
||||
testsuites/rscript_hash32.conf \
|
||||
rscript_hash64.sh \
|
||||
testsuites/rscript_hash64.conf \
|
||||
rscript_replace.sh \
|
||||
|
||||
14
tests/rscript_hash32.sh
Executable file
14
tests/rscript_hash32.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
# added 2018-02-07 by Harshvardhan Shrivastava
|
||||
# This file is part of the rsyslog project, released under ASL 2.0
|
||||
echo ===============================================================================
|
||||
echo \rscript_hash32.sh\]: test for hash32 and hash64mod script-function
|
||||
. $srcdir/diag.sh init
|
||||
. $srcdir/diag.sh startup rscript_hash32.conf
|
||||
. $srcdir/diag.sh tcpflood -m 20
|
||||
echo doing shutdown
|
||||
. $srcdir/diag.sh shutdown-when-empty
|
||||
echo wait on shutdown
|
||||
. $srcdir/diag.sh wait-shutdown
|
||||
. $srcdir/diag.sh content-pattern-check "^\(746581550 - 50\|3889673532 - 32\)$"
|
||||
. $srcdir/diag.sh exit
|
||||
@ -10,5 +10,5 @@ echo doing shutdown
|
||||
. $srcdir/diag.sh shutdown-when-empty
|
||||
echo wait on shutdown
|
||||
. $srcdir/diag.sh wait-shutdown
|
||||
. $srcdir/diag.sh content-pattern-check "^-2574714428477944902 - 14\|-50452361579464591 - 25$"
|
||||
. $srcdir/diag.sh content-pattern-check "^\(-2574714428477944902 - 14\|-50452361579464591 - 25\)$"
|
||||
. $srcdir/diag.sh exit
|
||||
|
||||
11
tests/testsuites/rscript_hash32.conf
Normal file
11
tests/testsuites/rscript_hash32.conf
Normal file
@ -0,0 +1,11 @@
|
||||
$IncludeConfig diag-common.conf
|
||||
template(name="outfmt" type="string" string="%$.hash_no_1% - %$.hash_no_2%\n")
|
||||
|
||||
module(load="../plugins/imtcp/.libs/imtcp")
|
||||
module(load="../plugins/fmhash/.libs/fmhash")
|
||||
input(type="imtcp" port="13514")
|
||||
|
||||
set $.hash_no_1 = hash32("0f9a1d07-a8c9-43a7-a6f7-198dca3d932e");
|
||||
set $.hash_no_2 = hash32mod("0f9a1d07-a8c9-43a7-a6f7-198dca3d932e", 100);
|
||||
|
||||
action(type="omfile" file="./rsyslog.out.log" template="outfmt")
|
||||
Loading…
x
Reference in New Issue
Block a user