From 604b3f102a0869eac79c91ccc82e172c2e6d36a0 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 17 Aug 2003 06:32:45 +0000 Subject: [PATCH] Makefile.am: add check_sizeof and testischar --- test/.cvsignore | 1 + test/Makefile.am | 7 +++-- test/check_sizeof.c | 72 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 test/check_sizeof.c diff --git a/test/.cvsignore b/test/.cvsignore index 90f9ab80..4c2e4f9f 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -5,6 +5,7 @@ Makefile.in check_cue.sh check_common_fn check_nrg.sh +check_sizeof testassert testischar *.dump diff --git a/test/Makefile.am b/test/Makefile.am index 3f3d2e5e..11e1baf7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.4 2003/08/17 05:31:19 rocky Exp $ +# $Id: Makefile.am,v 1.5 2003/08/17 06:32:45 rocky Exp $ # # Copyright (C) 2003 Rocky Bernstein # @@ -20,12 +20,13 @@ # Things to regression testing #################################################### # -noinst_PROGRAMS = testassert testischar +noinst_PROGRAMS = testassert testischar check_sizeof INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) testassert_LDADD = $(LIBCDIO_LIBS) testischar_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) +check_sizeof_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) check_SCRIPTS = check_nrg.sh check_cue.sh check_opts.sh @@ -43,6 +44,6 @@ EXTRA_DIST = $(check_SCRIPTS) $(check_DATA) \ check_common_fn check_cue.sh.in check_nrg.sh.in TESTS_ENVIRONMENT=$(SHELL) -TESTS = $(check_SCRIPTS) +TESTS = testischar check_sizeof $(check_SCRIPTS) MOSTLYCLEANFILES = core.* *.dump diff --git a/test/check_sizeof.c b/test/check_sizeof.c new file mode 100644 index 00000000..bccf0969 --- /dev/null +++ b/test/check_sizeof.c @@ -0,0 +1,72 @@ +/* + $Id: check_sizeof.c,v 1.1 2003/08/17 06:32:45 rocky Exp $ + + Copyright (C) 2001 Herbert Valerio Riedel + + This program 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. + + This program 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 +#include +#include +#include +#include + +#include +#include + +/* Private headers */ +#include "iso9660_private.h" + +#define CHECK_SIZEOF(typnam) { \ + printf ("checking sizeof (%s) ...", #typnam); \ + if (sizeof (typnam) != (typnam##_SIZEOF)) { \ + printf ("failed!\n==> sizeof (%s) == %d (but should be %d)\n", \ + #typnam, (int)sizeof(typnam), (int)(typnam##_SIZEOF)); \ + fail++; \ + } else { pass++; printf ("ok!\n"); } \ +} + +#define CHECK_SIZEOF_STRUCT(typnam) { \ + printf ("checking sizeof (struct %s) ...", #typnam); \ + if (sizeof (struct typnam) != (struct_##typnam##_SIZEOF)) { \ + printf ("failed!\n==> sizeof (struct %s) == %d (but should be %d)\n", \ + #typnam, (int)sizeof(struct typnam), (int)(struct_##typnam##_SIZEOF)); \ + fail++; \ + } else { pass++; printf ("ok!\n"); } \ +} + +int main (int argc, const char *argv[]) +{ + unsigned fail = 0, pass = 0; + + /* */ + CHECK_SIZEOF(msf_t); + + /* "iso9660_private.h" */ + CHECK_SIZEOF_STRUCT(iso_volume_descriptor); + CHECK_SIZEOF_STRUCT(iso_primary_descriptor); + CHECK_SIZEOF_STRUCT(iso_path_table); + CHECK_SIZEOF_STRUCT(iso_directory_record); + + if (fail) + return 1; + + return 0; +}