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
97f8d464
Commit
97f8d464
authored
Jun 03, 2014
by
Michael Meyling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[trackrdrd] test_config: refactoring and some more testing
parent
adbbc80d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
35 deletions
+101
-35
Makefile.am
trackrdrd/src/test/Makefile.am
+4
-5
test_config.c
trackrdrd/src/test/test_config.c
+48
-24
test_utils.c
trackrdrd/src/test/test_utils.c
+2
-2
test_utils.h
trackrdrd/src/test/test_utils.h
+5
-4
trackrdrd_001.conf
trackrdrd/src/test/trackrdrd_001.conf
+0
-0
trackrdrd_002.conf
trackrdrd/src/test/trackrdrd_002.conf
+21
-0
trackrdrd_003.conf
trackrdrd/src/test/trackrdrd_003.conf
+21
-0
No files found.
trackrdrd/src/test/Makefile.am
View file @
97f8d464
...
...
@@ -9,9 +9,7 @@ check_PROGRAMS = test_parse test_data test_hash test_mq test_spmcq test_config \
test_parse_SOURCES
=
\
minunit.h
\
test_parse.c
\
../trackrdrd.h
\
testing.h
\
testing.c
../trackrdrd.h
test_parse_LDADD
=
\
-lm
\
...
...
@@ -74,11 +72,12 @@ test_config_SOURCES = \
../config_common.c
\
../log.c
\
test_config.c
\
test_utils.c
\
test_utils.h
\
../trackrdrd.h
test_config_LDADD
=
\
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
\
testing.
$(OBJEXT)
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
test_worker_SOURCES
=
\
...
...
trackrdrd/src/test/test_config.c
View file @
97f8d464
...
...
@@ -29,29 +29,37 @@
*
*/
/***** includes ***************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "minunit.h"
#include "test
ing
.h"
#include "test
_utils
.h"
#include "../trackrdrd.h"
#include "config_common.h"
int
tests_run
=
0
;
/***** defines ****************************************************************/
#define DEFAULT_USER "nobody"
#define DEFAULT_PID_FILE "/var/run/trackrdrd.pid"
#define confdump(str,val) \
i += sprintf(verbose_buffer + i, str"\n", (val))
/***** variables **************************************************************/
int
tests_run
=
0
;
char
verbose_buffer
[
9000
];
char
*
getConfigContent
(
void
);
int
saveConfig
(
const
char
*
fname
);
#define confdump(str,val) \
i += sprintf(verbose_buffer + i, str"\n", (val))
/***** functions **************************************************************/
char
*
static
char
*
getConfigContent
(
void
)
{
int
i
=
0
;
...
...
@@ -81,7 +89,8 @@ getConfigContent(void)
return
verbose_buffer
;
}
int
saveConfig
(
const
char
*
fname
)
static
int
saveConfig
(
const
char
*
fname
)
{
FILE
*
fp
;
char
*
content
;
...
...
@@ -105,8 +114,8 @@ int saveConfig(const char * fname)
return
0
;
}
static
char
*
test_CONF_Init
(
void
)
static
char
*
test_CONF_Init
(
void
)
{
printf
(
"... testing CONF_Init
\n
"
);
...
...
@@ -120,8 +129,30 @@ static char
}
static
char
*
test_CONF_ReadDefault
(
void
)
static
char
*
readAndCompare
(
const
char
*
confName
)
{
int
err
;
char
confNameNew
[
512
];
err
=
CONF_ReadDefault
();
VMASSERT
(
err
==
0
,
"Error code during reading default config: %i"
,
err
);
err
=
CONF_ReadFile
(
confName
,
CONF_Add
);
VMASSERT
(
err
==
0
,
"Error code during reading config
\"
%s
\"
: %i"
,
confName
,
err
);
// verbose("Config is:\n%s", getConfigContent());
strcpy
(
confNameNew
,
confName
);
strcat
(
confNameNew
,
".new"
);
saveConfig
(
confNameNew
);
VMASSERT
(
TEST_compareFiles
(
confName
,
confNameNew
),
"Files are not equal:
\"
%s
\"
and
\"
%s
\"
"
,
confName
,
confNameNew
);
// CONF_Dump();
return
NULL
;
}
static
const
char
*
test_CONF_ReadDefault
(
void
)
{
printf
(
"... testing CONF_ReadDefault
\n
"
);
...
...
@@ -129,23 +160,16 @@ static char
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
(
TEST_compareFiles
(
"trackrdrd.conf"
,
"trackrdrd.conf.new"
),
"Files are not equal: %s %s"
,
"trackrdrd.conf"
,
"trackrdrd.conf.new"
);
// CONF_Dump();
returnIfNotNull
(
readAndCompare
(
"trackrdrd_001.conf"
));
returnIfNotNull
(
readAndCompare
(
"trackrdrd_002.conf"
));
returnIfNotNull
(
readAndCompare
(
"trackrdrd_003.conf"
));
return
NULL
;
}
static
const
char
*
all_tests
(
void
)
static
const
char
*
all_tests
(
void
)
{
mu_run_test
(
test_CONF_Init
);
mu_run_test
(
test_CONF_ReadDefault
);
...
...
trackrdrd/src/test/test
ing
.c
→
trackrdrd/src/test/test
_utils
.c
View file @
97f8d464
...
...
@@ -30,13 +30,13 @@
*/
/**
* Module: test
ing
.c
* Module: test
_utils
.c
* Description: Contains utilities for testing.
*/
/***** includes ***************************************************************/
#include "test
ing
.h"
#include "test
_utils
.h"
/***** functions **************************************************************/
...
...
trackrdrd/src/test/test
ing
.h
→
trackrdrd/src/test/test
_utils
.h
View file @
97f8d464
...
...
@@ -30,12 +30,12 @@
*/
/**
* Module: test
ing
.h
* Module: test
_utils
.h
* Description: Contains utilities for testing.
*/
#ifndef _TEST
ING
_H
#define _TEST
ING
_H
#ifndef _TEST
_UTILS
_H
#define _TEST
_UTILS
_H
/***** includes ***************************************************************/
...
...
@@ -54,6 +54,7 @@
#define verbose(fmt, ...) do{ } while ( 0 )
#endif
#define returnIfNotNull(test) do { const char *msg = test; if (msg) return msg; } while (0)
/***** variables **************************************************************/
...
...
@@ -68,4 +69,4 @@ extern long global_line_pos; /* actual position in input line */
extern
int
TEST_compareFiles
(
const
char
*
fname1
,
const
char
*
fname2
);
#endif
/* _TEST
ING
_H */
#endif
/* _TEST
_UTILS
_H */
trackrdrd/src/test/trackrdrd.conf
→
trackrdrd/src/test/trackrdrd
_001
.conf
View file @
97f8d464
File moved
trackrdrd/src/test/trackrdrd_002.conf
0 → 100644
View file @
97f8d464
pid
.
file
= /
var
/
opt
/
run
/
my
/
very
/
deeply
/
hidden
/
run
/
directory
/
SOME_OTHER_trackrdrd
.
pid
varnish
.
name
= /
var
/
opt
/
varnish
/
var
/
varnish_pa_proxy
/
log
.
file
=
testing
.
log
varnish
.
bindump
=
syslog
.
facility
=
LOCAL5
monitor
.
interval
=
300
monitor
.
workers
=
false
maxopen
.
scale
=
12
maxdone
=
10001
maxdata
=
1024
maxkeylen
=
124
qlen
.
goal
=
4991
hash
.
max_probes
=
9
hash
.
ttl
=
59
hash
.
mlt
=
12
mq
.
module
= /
var
/
opt
/
varnish_tracking
/
lib
/
trackrdrd
/
libtrackrdr
-
activemq
.
so
mq
.
config_file
= /
etc
/
trackrdr
-
activemq
.
conf
nworkers
=
2
restarts
=
3
thread
.
restarts
=
4
user
=
nobody
trackrdrd/src/test/trackrdrd_003.conf
0 → 100644
View file @
97f8d464
pid
.
file
=
trackrdrd
.
pid
varnish
.
name
= /
var
/
opt
/
varnish
/
var
/
varnish_pa_proxy
/
log
.
file
=
testing
.
log
varnish
.
bindump
=
syslog
.
facility
=
LOCAL5
monitor
.
interval
=
10000000
monitor
.
workers
=
true
maxopen
.
scale
=
12
maxdone
=
10001
maxdata
=
1024
maxkeylen
=
124
qlen
.
goal
=
4991
hash
.
max_probes
=
100
hash
.
ttl
=
59
hash
.
mlt
=
112
mq
.
module
= /
var
/
opt
/
varnish_tracking
/
lib
/
trackrdrd
/
libtrackrdr
-
activemq
.
so
mq
.
config_file
= /
etc
/
trackrdr
-
activemq
.
conf
nworkers
=
1
restarts
=
1
thread
.
restarts
=
1
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