mirror of https://github.com/yasm/yasm.git
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=1900.3
parent
cd3528249d
commit
9397744af8
18 changed files with 307 additions and 19 deletions
@ -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 |
@ -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; |
||||
} |
@ -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; |
@ -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…
Reference in new issue