mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Added basic support for unit testing
This commit is contained in:
parent
4950b4f441
commit
74415a7585
@ -1,3 +1,7 @@
|
|||||||
|
2005-10-27 Mauro Tortonesi <mauro@ferrara.linux.it>
|
||||||
|
|
||||||
|
* Makefile.in: Added basic support for unit testing.
|
||||||
|
|
||||||
2005-08-26 Stepan Kasal <kasal@ucw.cz>
|
2005-08-26 Stepan Kasal <kasal@ucw.cz>
|
||||||
|
|
||||||
* configure.in: Abort configure if --with-ssl given but SSL
|
* configure.in: Abort configure if --with-ssl given but SSL
|
||||||
|
@ -80,12 +80,20 @@ CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' LIBS='$(LIBS)' \
|
|||||||
prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \
|
prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \
|
||||||
infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)'
|
infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)'
|
||||||
|
|
||||||
|
TESTDEFS = CC='$(CC)' CPPFLAGS='$(CPPFLAGS) -DTESTING' DEFS='$(DEFS)' \
|
||||||
|
CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' LIBS='$(LIBS)' \
|
||||||
|
prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \
|
||||||
|
infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)'
|
||||||
|
|
||||||
# subdirectories in the distribution
|
# subdirectories in the distribution
|
||||||
SUBDIRS = src doc po util windows
|
SUBDIRS = src doc po util windows
|
||||||
|
|
||||||
# default target
|
# default target
|
||||||
all: src/config.h Makefile $(SUBDIRS)
|
all: src/config.h Makefile $(SUBDIRS)
|
||||||
|
|
||||||
|
test: src/config.h Makefile
|
||||||
|
cd src && $(MAKE) $(TESTDEFS) clean && $(MAKE) $(TESTDEFS) test$(exeext)
|
||||||
|
|
||||||
check: all
|
check: all
|
||||||
|
|
||||||
$(SUBDIRS): FORCE
|
$(SUBDIRS): FORCE
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2005-10-27 Mauro Tortonesi <mauro@ferrara.linux.it>
|
||||||
|
|
||||||
|
* Makefile.in: Added basic support for unit testing.
|
||||||
|
|
||||||
|
* test.c: Ditto.
|
||||||
|
|
||||||
|
* test.h: Ditto.
|
||||||
|
|
||||||
2005-10-13 Daniel Stenberg <daniel@haxx.se>
|
2005-10-13 Daniel Stenberg <daniel@haxx.se>
|
||||||
|
|
||||||
* http-ntlm.c (ntlm_output): Fixed buffer overflow vulnerability.
|
* http-ntlm.c (ntlm_output): Fixed buffer overflow vulnerability.
|
||||||
|
@ -102,6 +102,26 @@ $(OBJ): config-post.h config.h connect.h convert.h cookies.h ftp.h \
|
|||||||
progress.h ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h \
|
progress.h ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h \
|
||||||
sysdep.h url.h utils.h wget.h xmalloc.h
|
sysdep.h url.h utils.h wget.h xmalloc.h
|
||||||
|
|
||||||
|
#
|
||||||
|
# Dependencies for test binary
|
||||||
|
#
|
||||||
|
|
||||||
|
TESTOBJ = $(ALLOCA) cmpt.o connect.o convert.o cookies.o \
|
||||||
|
ftp.o ftp-basic.o ftp-ls.o $(OPIE_OBJ) $(GETOPT_OBJ) hash.o \
|
||||||
|
host.o html-parse.o html-url.o http.o $(NTLM_OBJ) init.o \
|
||||||
|
log.o main.o $(MD5_OBJ) netrc.o progress.o ptimer.o recur.o \
|
||||||
|
res.o retr.o safe-ctype.o snprintf.o $(SSL_OBJ) test.o \
|
||||||
|
url.o utils.o version.o xmalloc.o
|
||||||
|
|
||||||
|
$(TESTOBJ): config-post.h config.h connect.h convert.h cookies.h ftp.h \
|
||||||
|
gen-md5.h getopt.h gnu-md5.h hash.h host.h html-parse.h \
|
||||||
|
http-ntlm.h init.h log.h mswindows.h netrc.h options.h \
|
||||||
|
progress.h ptimer.h recur.h res.h retr.h safe-ctype.h ssl.h \
|
||||||
|
sysdep.h test.h url.h utils.h wget.h xmalloc.h
|
||||||
|
|
||||||
|
test$(exeext): $(TESTOBJ)
|
||||||
|
$(LINK) $(TESTOBJ) $(LIBS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Dependencies for installing
|
# Dependencies for installing
|
||||||
#
|
#
|
||||||
|
@ -670,6 +670,7 @@ GNU General Public License for more details.\n"), stdout);
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TESTING
|
||||||
int
|
int
|
||||||
main (int argc, char *const *argv)
|
main (int argc, char *const *argv)
|
||||||
{
|
{
|
||||||
@ -1007,6 +1008,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
|||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* TESTING */
|
||||||
|
|
||||||
#if defined(SIGHUP) || defined(SIGUSR1)
|
#if defined(SIGHUP) || defined(SIGUSR1)
|
||||||
|
|
||||||
|
73
src/test.c
Normal file
73
src/test.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* Unit testing.
|
||||||
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Wget.
|
||||||
|
|
||||||
|
GNU Wget is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GNU Wget is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Wget; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
In addition, as a special exception, the Free Software Foundation
|
||||||
|
gives permission to link the code of its release of Wget with the
|
||||||
|
OpenSSL project's "OpenSSL" library (or with modified versions of it
|
||||||
|
that use the same license as the "OpenSSL" library), and distribute
|
||||||
|
the linked executables. You must obey the GNU General Public License
|
||||||
|
in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
modify this file, you may extend this exception to your version of the
|
||||||
|
file, but you are not obligated to do so. If you do not wish to do
|
||||||
|
so, delete this exception statement from your version. */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
#ifndef TESTING
|
||||||
|
#error "TESTING not set!!!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int tests_run;
|
||||||
|
|
||||||
|
// char *test_ccache();
|
||||||
|
|
||||||
|
static char *
|
||||||
|
all_tests()
|
||||||
|
{
|
||||||
|
// mu_run_test (test_ccache);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
char *result = all_tests();
|
||||||
|
|
||||||
|
if (result != NULL)
|
||||||
|
{
|
||||||
|
puts (result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("ALL TESTS PASSED\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("Tests run: %d\n", tests_run);
|
||||||
|
|
||||||
|
return result != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: et ts=2 sw=2
|
||||||
|
*/
|
||||||
|
|
45
src/test.h
Normal file
45
src/test.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* Unit testing declarations.
|
||||||
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Wget.
|
||||||
|
|
||||||
|
GNU Wget is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GNU Wget is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Wget; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
In addition, as a special exception, the Free Software Foundation
|
||||||
|
gives permission to link the code of its release of Wget with the
|
||||||
|
OpenSSL project's "OpenSSL" library (or with modified versions of it
|
||||||
|
that use the same license as the "OpenSSL" library), and distribute
|
||||||
|
the linked executables. You must obey the GNU General Public License
|
||||||
|
in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
modify this file, you may extend this exception to your version of the
|
||||||
|
file, but you are not obligated to do so. If you do not wish to do
|
||||||
|
so, delete this exception statement from your version. */
|
||||||
|
|
||||||
|
#ifndef TEST_H
|
||||||
|
#define TEST_H
|
||||||
|
|
||||||
|
/* from MinUnit */
|
||||||
|
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
|
||||||
|
#define mu_run_test(test) do { char *message = test(); tests_run++; \
|
||||||
|
if (message) return message; } while (0)
|
||||||
|
|
||||||
|
extern int tests_run;
|
||||||
|
|
||||||
|
#endif /* TEST_H */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: et ts=2 sw=2
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user