Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
trackrdrd
Commits
8327d34b
Commit
8327d34b
authored
Jun 02, 2014
by
Michael Meyling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[trackrdrd] new config test added
parent
3970a4fa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
241 additions
and
2 deletions
+241
-2
Makefile.am
trackrdrd/src/test/Makefile.am
+13
-2
minunit.h
trackrdrd/src/test/minunit.h
+10
-0
test_config.c
trackrdrd/src/test/test_config.c
+197
-0
trackrdrd.conf
trackrdrd/src/test/trackrdrd.conf
+21
-0
No files found.
trackrdrd/src/test/Makefile.am
View file @
8327d34b
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
-I
$(top_srcdir)
/include
TESTS
=
test_parse test_data test_hash test_mq test_spmcq
\
TESTS
=
test_parse test_data test_hash test_mq test_spmcq
test_config
\
test_spmcq_loop.sh test_worker regress.sh
check_PROGRAMS
=
test_parse test_data test_hash test_mq test_spmcq
\
check_PROGRAMS
=
test_parse test_data test_hash test_mq test_spmcq
test_config
\
test_worker
test_parse_SOURCES
=
\
...
...
@@ -66,6 +66,17 @@ test_spmcq_LDADD = \
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
\
../spmcq.
$(OBJEXT)
test_config_SOURCES
=
\
minunit.h
\
../config.c
\
../config_common.c
\
../log.c
\
test_config.c
\
../trackrdrd.h
test_config_LDADD
=
\
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
test_worker_SOURCES
=
\
minunit.h
\
test_worker.c
\
...
...
trackrdrd/src/test/minunit.h
View file @
8327d34b
...
...
@@ -104,3 +104,13 @@ main(int argc, char **argv) \
}
#endif
/** debugging output */
#define VERBOSE 1
#ifdef VERBOSE
#define verbose(fmt, ...) \
do { printf("%s:%d:%s: \n>>> "fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while (0)
#else
#define verbose(fmt, ...) do{ } while ( 0 )
#endif
trackrdrd/src/test/test_config.c
0 → 100644
View file @
8327d34b
/*-
* Copyright (c) 2012-2014 UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2012-2014 Otto Gmbh & Co KG
* All rights reserved
* Use only with permission
*
* Author: Michael Meyling <michael@meyling.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "minunit.h"
#include "../trackrdrd.h"
#include "config_common.h"
int
tests_run
=
0
;
#define DEFAULT_USER "nobody"
#define DEFAULT_PID_FILE "/var/run/trackrdrd.pid"
int
compareFiles
(
const
char
*
fname1
,
const
char
*
fname2
);
char
verbose_buffer
[
9000
];
char
*
getConfigContent
(
void
);
int
saveConfig
(
const
char
*
fname
);
int
compareFiles
(
const
char
*
fname1
,
const
char
*
fname2
)
{
FILE
*
fp1
,
*
fp2
;
int
ch1
,
ch2
;
int
line
=
1
;
int
col
=
1
;
fp1
=
fopen
(
fname1
,
"r"
);
if
(
fp1
==
NULL
)
{
printf
(
"Cannot open %s for reading "
,
fname1
);
return
-
2
;
}
fp2
=
fopen
(
fname2
,
"r"
)
;
if
(
fp2
==
NULL
)
{
printf
(
"Cannot open %s for reading "
,
fname2
);
fclose
(
fp1
);
return
-
3
;
}
do
{
col
++
;
ch1
=
getc
(
fp1
);
ch2
=
getc
(
fp2
);
if
(
ch1
==
'\n'
)
{
line
++
;
col
=
0
;
}
}
while
((
ch1
!=
EOF
)
&&
(
ch2
!=
EOF
)
&&
(
ch1
==
ch2
));
fclose
(
fp1
);
fclose
(
fp2
);
if
(
ch1
!=
ch2
)
{
printf
(
" files differ at line: %i col: %i
\n
"
,
line
,
col
);
}
return
ch1
==
ch2
;
}
#define confdump(str,val) \
i += sprintf(verbose_buffer + i, str"\n", (val))
char
*
getConfigContent
(
void
)
{
int
i
=
0
;
confdump
(
"pid.file = %s"
,
config
.
pid_file
);
confdump
(
"varnish.name = %s"
,
config
.
varnish_name
);
confdump
(
"log.file = %s"
,
strcmp
(
config
.
log_file
,
"-"
)
==
0
?
"stdout"
:
config
.
log_file
);
confdump
(
"varnish.bindump = %s"
,
config
.
varnish_bindump
);
confdump
(
"syslog.facility = %s"
,
config
.
syslog_facility_name
);
confdump
(
"monitor.interval = %u"
,
config
.
monitor_interval
);
confdump
(
"monitor.workers = %s"
,
config
.
monitor_workers
?
"true"
:
"false"
);
confdump
(
"maxopen.scale = %u"
,
config
.
maxopen_scale
);
confdump
(
"maxdone = %u"
,
config
.
maxdone
);
confdump
(
"maxdata = %u"
,
config
.
maxdata
);
confdump
(
"maxkeylen = %u"
,
config
.
maxkeylen
);
confdump
(
"qlen.goal = %u"
,
config
.
qlen_goal
);
confdump
(
"hash.max_probes = %u"
,
config
.
hash_max_probes
);
confdump
(
"hash.ttl = %u"
,
config
.
hash_ttl
);
confdump
(
"hash.mlt = %u"
,
config
.
hash_mlt
);
confdump
(
"mq.module = %s"
,
config
.
mq_module
);
confdump
(
"mq.config_file = %s"
,
config
.
mq_config_file
);
confdump
(
"nworkers = %u"
,
config
.
nworkers
);
confdump
(
"restarts = %u"
,
config
.
restarts
);
confdump
(
"thread.restarts = %u"
,
config
.
thread_restarts
);
confdump
(
"user = %s"
,
config
.
user_name
);
return
verbose_buffer
;
}
int
saveConfig
(
const
char
*
fname
)
{
FILE
*
fp
;
char
*
content
;
fp
=
fopen
(
fname
,
"w"
);
if
(
fp
==
NULL
)
{
printf
(
"Cannot open %s for writing "
,
fname
);
return
4
;
}
content
=
getConfigContent
();
for
(
int
i
=
0
;
*
(
content
+
i
)
!=
0
;
i
++
)
{
if
(
EOF
==
putc
(
*
(
content
+
i
),
fp
))
{
fclose
(
fp
);
return
8
;
}
}
fclose
(
fp
);
return
0
;
}
static
char
*
test_CONF_Init
(
void
)
{
printf
(
"... testing CONF_Init
\n
"
);
CONF_Init
();
VMASSERT
(
!
strcmp
(
DEFAULT_USER
,
config
.
user_name
),
"Default user name expected:
\"
%s
\"
, but found:
\"
%s
\"
"
,
DEFAULT_USER
,
config
.
user_name
);
VMASSERT
(
!
strcmp
(
DEFAULT_PID_FILE
,
config
.
pid_file
),
"Default pid file name expected:
\"
%s
\"
, but found:
\"
%s
\"
"
,
DEFAULT_PID_FILE
,
config
.
user_name
);
return
NULL
;
}
static
char
*
test_CONF_ReadDefault
(
void
)
{
printf
(
"... testing CONF_ReadDefault
\n
"
);
// CONF_Init();
strcpy
(
config
.
log_file
,
"testing.log"
);
LOG_Open
(
"trackrdrd"
);
LOG_SetLevel
(
7
);
int
err
;
err
=
CONF_ReadDefault
();
VMASSERT
(
err
==
0
,
"Error code during reading default config: %i"
,
err
);
err
=
CONF_ReadFile
(
"trackrdrd.conf"
,
CONF_Add
);
VMASSERT
(
err
==
0
,
"Error code during reading config: %i"
,
err
);
verbose
(
"Config is:
\n
%s"
,
getConfigContent
());
saveConfig
(
"trackrdrd.conf.new"
);
VMASSERT
(
compareFiles
(
"trackrdrd.conf"
,
"trackrdrd.conf.new"
),
"Files are not equal: %s %s"
,
"trackrdrd.conf"
,
"trackrdrd.conf.new"
);
// CONF_Dump();
return
NULL
;
}
static
const
char
*
all_tests
(
void
)
{
mu_run_test
(
test_CONF_Init
);
mu_run_test
(
test_CONF_ReadDefault
);
return
NULL
;
}
TEST_RUNNER
trackrdrd/src/test/trackrdrd.conf
0 → 100644
View file @
8327d34b
pid
.
file
= /
var
/
run
/
trackrdrd
.
pid
varnish
.
name
= /
var
/
opt
/
varnish
/
var
/
varnish_pa_proxy
/
log
.
file
=
testing
.
log
varnish
.
bindump
=
syslog
.
facility
=
LOCAL5
monitor
.
interval
=
30
monitor
.
workers
=
true
maxopen
.
scale
=
13
maxdone
=
10000
maxdata
=
8192
maxkeylen
=
126
qlen
.
goal
=
4990
hash
.
max_probes
=
8
hash
.
ttl
=
61
hash
.
mlt
=
11
mq
.
module
= /
var
/
opt
/
varnish_tracking
/
lib
/
trackrdrd
/
libtrackrdr
-
activemq
.
so
mq
.
config_file
= /
etc
/
trackrdr
-
activemq
.
conf
nworkers
=
20
restarts
=
100
thread
.
restarts
=
100
user
=
root
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment