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
191ccd56
Commit
191ccd56
authored
Jun 02, 2014
by
Michael Meyling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[trackrdrd] a little bit of test refactoring for test_config
parent
78fccf0a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
163 additions
and
56 deletions
+163
-56
Makefile.am
trackrdrd/src/test/Makefile.am
+6
-2
minunit.h
trackrdrd/src/test/minunit.h
+0
-9
test_config.c
trackrdrd/src/test/test_config.c
+3
-45
testing.c
trackrdrd/src/test/testing.c
+83
-0
testing.h
trackrdrd/src/test/testing.h
+71
-0
No files found.
trackrdrd/src/test/Makefile.am
View file @
191ccd56
...
...
@@ -9,7 +9,9 @@ check_PROGRAMS = test_parse test_data test_hash test_mq test_spmcq test_config \
test_parse_SOURCES
=
\
minunit.h
\
test_parse.c
\
../trackrdrd.h
../trackrdrd.h
\
testing.h
\
testing.c
test_parse_LDADD
=
\
-lm
\
...
...
@@ -75,7 +77,9 @@ test_config_SOURCES = \
../trackrdrd.h
test_config_LDADD
=
\
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
\
testing.
$(OBJEXT)
test_worker_SOURCES
=
\
minunit.h
\
...
...
trackrdrd/src/test/minunit.h
View file @
191ccd56
...
...
@@ -105,12 +105,3 @@ 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
View file @
191ccd56
...
...
@@ -34,6 +34,7 @@
#include <string.h>
#include "minunit.h"
#include "testing.h"
#include "../trackrdrd.h"
#include "config_common.h"
...
...
@@ -42,53 +43,11 @@ 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))
...
...
@@ -166,7 +125,6 @@ static char
{
printf
(
"... testing CONF_ReadDefault
\n
"
);
// CONF_Init();
strcpy
(
config
.
log_file
,
"testing.log"
);
LOG_Open
(
"trackrdrd"
);
LOG_SetLevel
(
7
);
...
...
@@ -176,9 +134,9 @@ static char
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
());
//
verbose("Config is:\n%s", getConfigContent());
saveConfig
(
"trackrdrd.conf.new"
);
VMASSERT
(
compareFiles
(
"trackrdrd.conf"
,
"trackrdrd.conf.new"
),
VMASSERT
(
TEST_
compareFiles
(
"trackrdrd.conf"
,
"trackrdrd.conf.new"
),
"Files are not equal: %s %s"
,
"trackrdrd.conf"
,
"trackrdrd.conf.new"
);
// CONF_Dump();
...
...
trackrdrd/src/test/testing.c
0 → 100644
View file @
191ccd56
/*-
* 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.
*
*/
/**
* Module: testing.c
* Description: Contains utilities for testing.
*/
/***** includes ***************************************************************/
#include "testing.h"
/***** functions **************************************************************/
int
TEST_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
;
}
trackrdrd/src/test/testing.h
0 → 100644
View file @
191ccd56
/*-
* 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.
*
*/
/**
* Module: testing.h
* Description: Contains utilities for testing.
*/
#ifndef _TESTING_H
#define _TESTING_H
/***** includes ***************************************************************/
#include <stdio.h>
/***** defines ****************************************************************/
/** debugging output */
#define VERBOSE 1
#ifdef VERBOSE
#define verbose(fmt, ...) \
do { printf("%8s:%4d:%20s:>>> "fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while (0)
#else
#define verbose(fmt, ...) do{ } while ( 0 )
#endif
/***** variables **************************************************************/
extern
long
global_line_pos
;
/* actual position in input line */
/***** structures *************************************************************/
/***** functions **************************************************************/
extern
int
TEST_compareFiles
(
const
char
*
fname1
,
const
char
*
fname2
);
#endif
/* _TESTING_H */
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