Add unit test framework using Check (http://check.sourceforge.net/).

Only test included right now is a tiny one for one bytecode function, but
will grow as time goes on.
TODO: check for non ANSI C things required by Check.

svn path=/trunk/yasm/; revision=190
0.3
Peter Johnson 24 years ago
parent cd3528249d
commit 9397744af8
  1. 2
      Makefile.am
  2. 23
      check/Makefile.am
  3. 3
      configure.ac
  4. 3
      configure.in
  5. 6
      frontends/yasm/yasm.c
  6. 34
      libyasm/linemgr.c
  7. 5
      libyasm/tests/.cvsignore
  8. 21
      libyasm/tests/Makefile.am
  9. 42
      libyasm/tests/bytecode_test.c
  10. 25
      src/Makefile.am
  11. 34
      src/globals.c
  12. 34
      src/linemgr.c
  13. 6
      src/main.c
  14. 5
      src/tests/.cvsignore
  15. 21
      src/tests/Makefile.am
  16. 42
      src/tests/bytecode_test.c
  17. 4
      tests/.cvsignore
  18. 16
      tests/Makefile.am

@ -1,5 +1,5 @@
# $IdPath$
SUBDIRS = intl src po doc
SUBDIRS = check intl src po doc tests
EXTRA_DIST = config/install-sh config/missing config/mkinstalldirs \
config/config.guess config/config.sub

@ -0,0 +1,23 @@
# $IdPath$
noinst_LIBRARIES=libcheck.a
libcheck_a_SOURCES = \
check.c \
check_run.c \
check.h \
check_impl.h \
check_msg.c \
check_msg.h \
check_log.c \
check_log.h \
check_print.c \
check_print.h \
error.c \
error.h \
list.c \
list.h
if DEV
CFLAGS = -ansi -pedantic -Wall -g
endif

@ -86,6 +86,7 @@ case "$host" in
esac
AC_OUTPUT(Makefile
check/Makefile
intl/Makefile
po/Makefile.in
src/Makefile
@ -97,8 +98,10 @@ AC_OUTPUT(Makefile
src/optimizers/dbg/Makefile
src/objfmts/Makefile
src/objfmts/dbg/Makefile
src/tests/Makefile
doc/Makefile
doc/user/Makefile
doc/programmer/Makefile
doc/programmer/queue/Makefile
tests/Makefile
)

@ -86,6 +86,7 @@ case "$host" in
esac
AC_OUTPUT(Makefile
check/Makefile
intl/Makefile
po/Makefile.in
src/Makefile
@ -97,8 +98,10 @@ AC_OUTPUT(Makefile
src/optimizers/dbg/Makefile
src/objfmts/Makefile
src/objfmts/dbg/Makefile
src/tests/Makefile
doc/Makefile
doc/user/Makefile
doc/programmer/Makefile
doc/programmer/queue/Makefile
tests/Makefile
)

@ -32,6 +32,8 @@
# include <string.h>
#endif
#include "globals.h"
#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
@ -40,10 +42,6 @@
RCSID("$IdPath$");
char *filename = (char *)NULL;
unsigned int line_number = 1;
unsigned int mode_bits = 32;
int
main(int argc, char *argv[])
{

@ -0,0 +1,34 @@
/* $IdPath$
* Global variables
*
* Copyright (C) 2001 Peter Johnson
*
* This file is part of YASM.
*
* YASM 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.
*
* YASM 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "util.h"
#include <stdio.h>
RCSID("$IdPath$");
char *filename = (char *)NULL;
unsigned int line_number = 1;
unsigned int mode_bits = 32;

@ -0,0 +1,5 @@
.*.sw?
Makefile.in
Makefile
.deps
bytecode_test

@ -0,0 +1,21 @@
# $IdPath$
TESTS = \
bytecode_test
noinst_PROGRAMS = \
bytecode_test
bytecode_test_SOURCES = \
bytecode_test.c
INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/check
LDADD = \
$(top_builddir)/check/libcheck.a \
$(top_builddir)/src/parsers/nasm/libparser.a \
$(top_builddir)/src/preprocs/raw/libpreproc.a \
$(top_builddir)/src/optimizers/dbg/liboptimizer.a \
$(top_builddir)/src/objfmts/dbg/libobjfmt.a \
$(top_builddir)/src/libyasm.a \
$(INTLLIBS)

@ -0,0 +1,42 @@
/* $IdPath$
*
*/
#include <stdlib.h>
#include "check.h"
#include "util.h"
#include "bytecode.h"
START_TEST(test_ConvertRegToEA)
{
effaddr static_val, *allocp, *retp;
/* Test with static passing */
fail_unless(ConvertRegToEA(&static_val, 1) == &static_val,
"No allocation should be performed if non-NULL passed in ptr");
}
END_TEST
Suite *bytecode_suite(void)
{
Suite *s = suite_create("bytecode");
TCase *tc_conversion = tcase_create("Conversion");
suite_add_tcase(s, tc_conversion);
tcase_add_test(tc_conversion, test_ConvertRegToEA);
return s;
}
int main(void)
{
int nf;
Suite *s = bytecode_suite();
SRunner *sr = srunner_create(s);
srunner_run_all(sr, CRNORMAL);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
suite_free(s);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

@ -1,21 +1,33 @@
# $IdPath$
SUBDIRS = parsers preprocs optimizers objfmts
SUBDIRS = parsers preprocs optimizers objfmts . tests
INCLUDES = -I$(top_builddir)/intl
bin_PROGRAMS = yasm
yasm_SOURCES = \
yasm_SOURCES = main.c
yasm_LDADD = \
parsers/nasm/libparser.a \
preprocs/raw/libpreproc.a \
optimizers/dbg/liboptimizer.a \
objfmts/dbg/libobjfmt.a \
libyasm.a \
$(INTLLIBS)
noinst_LIBRARIES = libyasm.a
libyasm_a_SOURCES = \
bytecode.c \
bytecode.h \
errwarn.c \
errwarn.h \
expr.c \
expr.h \
main.c \
symrec.c \
symrec.h \
globals.c \
globals.h \
util.h \
section.h \
@ -26,13 +38,6 @@ yasm_SOURCES = \
optimizer.h \
strcasecmp.c
yasm_LDADD = \
parsers/nasm/libparser.a \
preprocs/raw/libpreproc.a \
optimizers/dbg/liboptimizer.a \
objfmts/dbg/libobjfmt.a \
$(INTLLIBS)
if DEV
CFLAGS = -ansi -pedantic -Wall -g
endif

@ -0,0 +1,34 @@
/* $IdPath$
* Global variables
*
* Copyright (C) 2001 Peter Johnson
*
* This file is part of YASM.
*
* YASM 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.
*
* YASM 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "util.h"
#include <stdio.h>
RCSID("$IdPath$");
char *filename = (char *)NULL;
unsigned int line_number = 1;
unsigned int mode_bits = 32;

@ -0,0 +1,34 @@
/* $IdPath$
* Global variables
*
* Copyright (C) 2001 Peter Johnson
*
* This file is part of YASM.
*
* YASM 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.
*
* YASM 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "util.h"
#include <stdio.h>
RCSID("$IdPath$");
char *filename = (char *)NULL;
unsigned int line_number = 1;
unsigned int mode_bits = 32;

@ -32,6 +32,8 @@
# include <string.h>
#endif
#include "globals.h"
#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
@ -40,10 +42,6 @@
RCSID("$IdPath$");
char *filename = (char *)NULL;
unsigned int line_number = 1;
unsigned int mode_bits = 32;
int
main(int argc, char *argv[])
{

@ -0,0 +1,5 @@
.*.sw?
Makefile.in
Makefile
.deps
bytecode_test

@ -0,0 +1,21 @@
# $IdPath$
TESTS = \
bytecode_test
noinst_PROGRAMS = \
bytecode_test
bytecode_test_SOURCES = \
bytecode_test.c
INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/check
LDADD = \
$(top_builddir)/check/libcheck.a \
$(top_builddir)/src/parsers/nasm/libparser.a \
$(top_builddir)/src/preprocs/raw/libpreproc.a \
$(top_builddir)/src/optimizers/dbg/liboptimizer.a \
$(top_builddir)/src/objfmts/dbg/libobjfmt.a \
$(top_builddir)/src/libyasm.a \
$(INTLLIBS)

@ -0,0 +1,42 @@
/* $IdPath$
*
*/
#include <stdlib.h>
#include "check.h"
#include "util.h"
#include "bytecode.h"
START_TEST(test_ConvertRegToEA)
{
effaddr static_val, *allocp, *retp;
/* Test with static passing */
fail_unless(ConvertRegToEA(&static_val, 1) == &static_val,
"No allocation should be performed if non-NULL passed in ptr");
}
END_TEST
Suite *bytecode_suite(void)
{
Suite *s = suite_create("bytecode");
TCase *tc_conversion = tcase_create("Conversion");
suite_add_tcase(s, tc_conversion);
tcase_add_test(tc_conversion, test_ConvertRegToEA);
return s;
}
int main(void)
{
int nf;
Suite *s = bytecode_suite();
SRunner *sr = srunner_create(s);
srunner_run_all(sr, CRNORMAL);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
suite_free(s);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

@ -0,0 +1,4 @@
.*.sw?
Makefile.in
Makefile
.deps

@ -0,0 +1,16 @@
# $IdPath$
#TESTS = \
#noinst_PROGRAMS = \
INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/check
LDADD = \
$(top_builddir)/check/libcheck.a \
$(top_builddir)/src/parsers/nasm/libparser.a \
$(top_builddir)/src/preprocs/raw/libpreproc.a \
$(top_builddir)/src/optimizers/dbg/liboptimizer.a \
$(top_builddir)/src/objfmts/dbg/libobjfmt.a \
$(top_builddir)/src/libyasm.a \
$(INTLLIBS)
Loading…
Cancel
Save