mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 02:10:42 +01:00
Merge pull request #2968 from rgerhards/tb10
testbench: short test id and make more reliable
This commit is contained in:
commit
8ff395ccd6
@ -8,13 +8,12 @@ CLEANFILES=\
|
||||
rsyslog*.pid.save xlate*.lkp_tbl \
|
||||
log log* \
|
||||
work \
|
||||
rsyslog_*.out.* \
|
||||
rsyslog2_*.out.* \
|
||||
test-spool test-logdir stat-file1 \
|
||||
rsyslog.pipe rsyslog.input.* \
|
||||
rsyslog.input rsyslog.input.* imfile-state* omkafka-failed.data \
|
||||
rsyslog.input-symlink.log rsyslog-link.*.log targets \
|
||||
HOSTNAME \
|
||||
rstb_* \
|
||||
tmp.qi nocert
|
||||
|
||||
CLEANFILES+= \
|
||||
|
||||
@ -115,11 +115,10 @@ function generate_conf() {
|
||||
new_port="$(get_free_port)"
|
||||
if [ "$1" == "" ]; then
|
||||
export IMDIAG_PORT=$new_port
|
||||
export RSYSLOG_DYNNAME="rsyslog_$(basename $0)_${new_port}"
|
||||
export TESTCONF_NM="${RSYSLOG_DYNNAME}_" # this basename is also used by instance 2!
|
||||
export RSYSLOG_OUT_LOG="${RSYSLOG_DYNNAME}.out.log"
|
||||
export RSYSLOG2_OUT_LOG="${RSYSLOG_DYNNAME}_2.out.log"
|
||||
export RSYSLOG_PIDBASE="${RSYSLOG_DYNNAME}_" # also used by instance 2!
|
||||
export RSYSLOG_PIDBASE="${RSYSLOG_DYNNAME}:" # also used by instance 2!
|
||||
mkdir $RSYSLOG_DYNNAME.spool
|
||||
else
|
||||
export IMDIAG_PORT2=$new_port
|
||||
@ -564,14 +563,18 @@ case $1 in
|
||||
# some default names (later to be set in other parts, once we support fully
|
||||
# parallel tests)
|
||||
export RSYSLOG_DFLT_LOG_INTERNAL=1 # testbench needs internal messages logged internally!
|
||||
export RSYSLOG2_OUT_LOG=rsyslog2.out.log
|
||||
export RSYSLOG_OUT_LOG=rsyslog.out.log
|
||||
export RSYSLOG2_OUT_LOG=rsyslog2.out.log # TODO: remove
|
||||
export RSYSLOG_OUT_LOG=rsyslog.out.log # TODO: remove
|
||||
export RSYSLOG_PIDBASE="rsyslog" # TODO: remove
|
||||
export RSYSLOG_DYNNAME="rsyslog" # TODO: remove
|
||||
export RSYSLOG_DYNNAME="rstb_$(./test_id $(basename $0))"
|
||||
export IMDIAG_PORT=13500
|
||||
export IMDIAG_PORT2=13501
|
||||
export TCPFLOOD_PORT=13514
|
||||
|
||||
# we create one file with the test name, so that we know what was
|
||||
# left over if "make distcheck" complains
|
||||
touch $RSYSLOG_DYNNAME-$(basename $0).test_id
|
||||
|
||||
if [ -z $RS_SORTCMD ]; then
|
||||
RS_SORTCMD=sort
|
||||
fi
|
||||
|
||||
@ -25,7 +25,6 @@ if $msg contains "msgnum:" then
|
||||
action(type="omfile" file=`echo $RSYSLOG_OUT_LOG`)
|
||||
'
|
||||
|
||||
# . $srcdir/diag.sh es-init
|
||||
startup
|
||||
injectmsg 0 1
|
||||
shutdown_when_empty
|
||||
@ -38,7 +37,6 @@ else
|
||||
error_exit 1
|
||||
fi
|
||||
|
||||
. $srcdir/diag.sh init
|
||||
generate_conf
|
||||
add_conf '
|
||||
template(name="tpl" type="string"
|
||||
@ -57,7 +55,6 @@ if $msg contains "msgnum:" then
|
||||
action(type="omfile" file=`echo $RSYSLOG_OUT_LOG`)
|
||||
'
|
||||
|
||||
# . $srcdir/diag.sh es-init
|
||||
startup
|
||||
injectmsg 0 1
|
||||
shutdown_when_empty
|
||||
@ -70,7 +67,6 @@ else
|
||||
error_exit 1
|
||||
fi
|
||||
|
||||
. $srcdir/diag.sh init
|
||||
generate_conf
|
||||
add_conf '
|
||||
template(name="tpl" type="string"
|
||||
|
||||
@ -109,6 +109,4 @@ if [[ "$start_fd_count" != "$end_fd_count" ]]; then
|
||||
error_exit 1
|
||||
fi
|
||||
|
||||
cat -n $RSYSLOG_OUT_LOG # 2018-08-29 debug, remove when no longer needed
|
||||
|
||||
exit_test
|
||||
|
||||
@ -48,3 +48,4 @@ wait_shutdown
|
||||
# may be needed by TLS (once we do it): sleep 60
|
||||
# do the final check
|
||||
seq_check 1 50000 $3
|
||||
exit_test
|
||||
|
||||
@ -3,14 +3,37 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int main()
|
||||
/* one provided by Aaaron Wiebe based on perl's hashing algorithm
|
||||
* (so probably pretty generic). Not for excessively large strings!
|
||||
*/
|
||||
#if defined(__clang__)
|
||||
#pragma GCC diagnostic ignored "-Wunknown-attributes"
|
||||
#endif
|
||||
static unsigned __attribute__((nonnull(1))) int
|
||||
#if defined(__clang__)
|
||||
__attribute__((no_sanitize("unsigned-integer-overflow")))
|
||||
#endif
|
||||
hash_from_string(void *k)
|
||||
{
|
||||
char *rkey = (char*) k;
|
||||
unsigned hashval = 1;
|
||||
|
||||
while (*rkey)
|
||||
hashval = hashval * 33 + *rkey++;
|
||||
|
||||
return hashval;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
struct tm *tm;
|
||||
gettimeofday(&tv, &tz);
|
||||
tm = localtime(&tv.tv_sec);
|
||||
printf("%02d:%02d:%02d:%06ld", tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec);
|
||||
if(argc != 2) {
|
||||
fprintf(stderr, "usage: test_id test-file-name\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("%06ld_%04.4x", tv.tv_usec, hash_from_string(argv[1]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user