From c17f57c42898b887949c61d9b384fa5a6aa2518a Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 2 Aug 2011 11:24:07 +0000 Subject: Add tests. --- tests/Makefile.am | 90 +++++++++++++++++++ tests/atlocal.in | 24 +++++ tests/create00.at | 28 ++++++ tests/fetch00.at | 31 +++++++ tests/fetch01.at | 30 +++++++ tests/gtdump.c | 128 +++++++++++++++++++++++++++ tests/gtfetch.c | 141 +++++++++++++++++++++++++++++ tests/gtload.c | 150 +++++++++++++++++++++++++++++++ tests/num2word.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 33 +++++++ tests/version.at | 33 +++++++ 11 files changed, 943 insertions(+) create mode 100644 tests/Makefile.am create mode 100644 tests/atlocal.in create mode 100644 tests/create00.at create mode 100644 tests/fetch00.at create mode 100644 tests/fetch01.at create mode 100644 tests/gtdump.c create mode 100644 tests/gtfetch.c create mode 100644 tests/gtload.c create mode 100644 tests/num2word.c create mode 100644 tests/testsuite.at create mode 100644 tests/version.at (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..7b6c9ee --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,90 @@ +# This file is part of GDBM. -*- autoconf -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +EXTRA_DIST = \ + $(TESTSUITE_AT)\ + testsuite\ + package.m4 + +DISTCLEANFILES = atconfig +MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) + + +## ------------ ## +## package.m4. ## +## ------------ ## + +$(srcdir)/package.m4: $(top_srcdir)/configure.ac $(srcdir)/Makefile + $(AM_V_GEN){ \ + echo '# Signature of the current package.'; \ + echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ + echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ + echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ + echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ + } >$(srcdir)/package.m4 + +# + +## ------------ ## +## Test suite. ## +## ------------ ## + +TESTSUITE_AT = \ + create00.at\ + fetch00.at\ + fetch01.at\ + version.at + +TESTSUITE = $(srcdir)/testsuite +M4=m4 + +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): package.m4 $(TESTSUITE_AT) + $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp + mv $@.tmp $@ + +atconfig: $(top_builddir)/config.status + cd $(top_builddir) && ./config.status tests/$@ + +clean-local: + test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean + +check-local: atconfig atlocal $(TESTSUITE) + $(SHELL) $(TESTSUITE) + +# Run the test suite on the *installed* tree. +#installcheck-local: +# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin + +## ------------ ## +## num2word ## +## ------------ ## + +check_PROGRAMS = \ + gtdump\ + gtfetch\ + gtload\ + num2word + +INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src +gtload_LDADD = ../src/libgdbm.la +gtdump_LDADD = ../src/libgdbm.la +gtfetch_LDADD = ../src/libgdbm.la + + + + diff --git a/tests/atlocal.in b/tests/atlocal.in new file mode 100644 index 0000000..411a76d --- /dev/null +++ b/tests/atlocal.in @@ -0,0 +1,24 @@ +# @configure_input@ -*- shell-script -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +PATH=@abs_top_builddir@/src:$PATH + +XFAILFILE=$abs_builddir/.badversion + +trap "cleanup; test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15 + + + diff --git a/tests/create00.at b/tests/create00.at new file mode 100644 index 0000000..7ebe744 --- /dev/null +++ b/tests/create00.at @@ -0,0 +1,28 @@ +# This file is part of GDBM. -*- autoconf -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +AT_SETUP([create database]) + +AT_CHECK([ +AT_SORT_PREREQ +num2word 1:1000 > input +gtload test.db < input +gtdump test.db | sort -k1,2 -n > output +diff -u input output +]) + +AT_CLEANUP + diff --git a/tests/fetch00.at b/tests/fetch00.at new file mode 100644 index 0000000..b3a3cec --- /dev/null +++ b/tests/fetch00.at @@ -0,0 +1,31 @@ +# This file is part of GDBM. -*- autoconf -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +AT_SETUP([fetch a record]) +AT_KEYWORDS([fetch fetch00.at]) + +AT_CHECK([ +num2word 1:10000 | gtload test.db +gtfetch test.db 1 2745 9999 +], +[0], +[one +two thousand seven hundred and fourty-five +nine thousand nine hundred and ninety-nine +]) + +AT_CLEANUP + diff --git a/tests/fetch01.at b/tests/fetch01.at new file mode 100644 index 0000000..6efd004 --- /dev/null +++ b/tests/fetch01.at @@ -0,0 +1,30 @@ +# This file is part of GDBM. -*- autoconf -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +AT_SETUP([fetch: nonexisting record]) +AT_KEYWORDS([fetch fetch01.at]) + +AT_CHECK([ +num2word 1:10000 | gtload test.db +gtfetch test.db 0 +], +[2], +[], +[gtfetch: 0: not found +]) + +AT_CLEANUP + diff --git a/tests/gtdump.c b/tests/gtdump.c new file mode 100644 index 0000000..2d3049a --- /dev/null +++ b/tests/gtdump.c @@ -0,0 +1,128 @@ +/* This file is part of GDBM test suite. + Copyright (C) 2011 Free Software Foundation, Inc. + + GDBM 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, or (at your option) + any later version. + + GDBM 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 GDBM. If not, see . +*/ +#include "autoconf.h" +#include +#include +#include +#include "gdbm.h" + +const char * +canonical_progname (const char *str) +{ + const char *p; + + p = strrchr (str, '/'); + if (p) + p++; + else + p = str; + if (strncmp (p, "lt-", 3) == 0) + p += 3; + return p; +} + +int +main (int argc, char **argv) +{ + const char *progname = canonical_progname (argv[0]); + const char *dbname; + datum key; + datum data; + int flags = 0; + GDBM_FILE dbf; + int delim = '\t'; + int data_z = 0; + + while (--argc) + { + char *arg = *++argv; + + if (strcmp (arg, "-h") == 0) + { + printf ("usage: %s [-nolock] [-nommap] [-delim=CHR] DBFILE\n", + progname); + exit (0); + } + else if (strcmp (arg, "-nolock") == 0) + flags |= GDBM_NOLOCK; + else if (strcmp (arg, "-nommap") == 0) + flags |= GDBM_NOMMAP; + else if (strcmp (arg, "-sync") == 0) + flags |= GDBM_SYNC; + else if (strncmp (arg, "-delim=", 7) == 0) + delim = arg[7]; + else if (strcmp (arg, "--") == 0) + { + --argc; + ++argv; + break; + } + else if (arg[0] == '-') + { + fprintf (stderr, "%s: unknown option %s\n", progname, arg); + exit (1); + } + else + break; + } + + if (argc != 1) + { + fprintf (stderr, "%s: wrong arguments\n", progname); + exit (1); + } + dbname = *argv; + + dbf = gdbm_open (dbname, 0, GDBM_READER|flags, 00664, NULL); + if (!dbf) + { + fprintf (stderr, "gdbm_open failed: %s", gdbm_strerror (gdbm_errno)); + exit (1); + } + + key = gdbm_firstkey (dbf); + while (key.dptr) + { + size_t i; + datum nextkey = gdbm_nextkey (dbf, key); + + for (i = 0; i < key.dsize && key.dptr[i]; i++) + { + if (key.dptr[i] == delim || key.dptr[i] == '\\') + fputc ('\\', stdout); + fputc (key.dptr[i], stdout); + } + + fputc (delim, stdout); + + data = gdbm_fetch (dbf, key); + i = data.dsize; + if (data.dptr[i-1] == 0) + i--; + + fwrite (data.dptr, i, 1, stdout); + free (data.dptr); + + fputc ('\n', stdout); + + free (key.dptr); + key = nextkey; + } + + gdbm_close (dbf); + exit (0); +} diff --git a/tests/gtfetch.c b/tests/gtfetch.c new file mode 100644 index 0000000..a50b83e --- /dev/null +++ b/tests/gtfetch.c @@ -0,0 +1,141 @@ +/* This file is part of GDBM test suite. + Copyright (C) 2011 Free Software Foundation, Inc. + + GDBM 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, or (at your option) + any later version. + + GDBM 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 GDBM. If not, see . +*/ +#include "autoconf.h" +#include +#include +#include +#include "gdbm.h" + +void +print_key (FILE *fp, datum key, int delim) +{ + size_t i; + + for (i = 0; i < key.dsize && key.dptr[i]; i++) + { + if (key.dptr[i] == delim || key.dptr[i] == '\\') + fputc ('\\', fp); + fputc (key.dptr[i], fp); + } +} + +const char * +canonical_progname (const char *str) +{ + const char *p; + + p = strrchr (str, '/'); + if (p) + p++; + else + p = str; + if (strncmp (p, "lt-", 3) == 0) + p += 3; + return p; +} + +int +main (int argc, char **argv) +{ + const char *progname = canonical_progname (argv[0]); + const char *dbname; + datum key; + datum data; + int flags = 0; + GDBM_FILE dbf; + int data_z = 0; + int delim = 0; + int rc = 0; + + while (--argc) + { + char *arg = *++argv; + + if (strcmp (arg, "-h") == 0) + { + printf ("usage: %s [-nolock] [-nommap] [-null] [-delim=CHR] DBFILE KEY [KEY...]\n", + progname); + exit (0); + } + else if (strcmp (arg, "-nolock") == 0) + flags |= GDBM_NOLOCK; + else if (strcmp (arg, "-nommap") == 0) + flags |= GDBM_NOMMAP; + else if (strcmp (arg, "-null") == 0) + data_z = 1; + else if (strncmp (arg, "-delim=", 7) == 0) + delim = arg[7]; + else if (strcmp (arg, "--") == 0) + { + --argc; + ++argv; + break; + } + else if (arg[0] == '-') + { + fprintf (stderr, "%s: unknown option %s\n", progname, arg); + exit (1); + } + else + break; + } + + if (argc < 2) + { + fprintf (stderr, "%s: wrong arguments\n", progname); + exit (1); + } + dbname = *argv; + + dbf = gdbm_open (dbname, 0, GDBM_READER|flags, 00664, NULL); + if (!dbf) + { + fprintf (stderr, "gdbm_open failed: %s", gdbm_strerror (gdbm_errno)); + exit (1); + } + + while (--argc) + { + char *arg = *++argv; + + key.dptr = arg; + key.dsize = strlen (arg) + !!data_z; + + data = gdbm_fetch (dbf, key); + if (data.dptr == NULL) + { + rc = 2; + fprintf (stderr, "%s: ", progname); + print_key (stderr, key, delim); + fprintf (stderr, ": not found\n"); + continue; + } + if (delim) + { + print_key (stdout, key, delim); + fputc (delim, stdout); + } + + fwrite (data.dptr, data.dsize - !!data_z, 1, stdout); + free (data.dptr); + + fputc ('\n', stdout); + } + + gdbm_close (dbf); + exit (rc); +} diff --git a/tests/gtload.c b/tests/gtload.c new file mode 100644 index 0000000..f75f671 --- /dev/null +++ b/tests/gtload.c @@ -0,0 +1,150 @@ +/* This file is part of GDBM test suite. + Copyright (C) 2011 Free Software Foundation, Inc. + + GDBM 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, or (at your option) + any later version. + + GDBM 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 GDBM. If not, see . +*/ +#include "autoconf.h" +#include +#include +#include +#include "gdbm.h" + +const char * +canonical_progname (const char *str) +{ + const char *p; + + p = strrchr (str, '/'); + if (p) + p++; + else + p = str; + if (strncmp (p, "lt-", 3) == 0) + p += 3; + return p; +} + +int +main (int argc, char **argv) +{ + const char *progname = canonical_progname (argv[0]); + const char *dbname; + int line = 0; + char buf[1024]; + datum key; + datum data; + int replace = 0; + int flags = 0; + int mode = GDBM_WRCREAT; + int block_size = 0; + GDBM_FILE dbf; + int delim = '\t'; + int data_z = 0; + + while (--argc) + { + char *arg = *++argv; + + if (strcmp (arg, "-h") == 0) + { + printf ("usage: %s [-replace] [-clear] [-blocksize=N] [-null] [-nolock] [-nommap] [-sync] [-delim=CHR] DBFILE\n", progname); + exit (0); + } + else if (strcmp (arg, "-replace") == 0) + replace |= GDBM_REPLACE; + else if (strcmp (arg, "-clear") == 0) + mode = GDBM_NEWDB; + else if (strcmp (arg, "-null") == 0) + data_z = 1; + else if (strcmp (arg, "-nolock") == 0) + flags |= GDBM_NOLOCK; + else if (strcmp (arg, "-nommap") == 0) + flags |= GDBM_NOMMAP; + else if (strcmp (arg, "-sync") == 0) + flags |= GDBM_SYNC; + else if (strncmp (arg, "-blocksize=", 11) == 0) + block_size = atoi (arg + 11); + else if (strncmp (arg, "-delim=", 7) == 0) + delim = arg[7]; + else if (strcmp (arg, "--") == 0) + { + --argc; + ++argv; + break; + } + else if (arg[0] == '-') + { + fprintf (stderr, "%s: unknown option %s\n", progname, arg); + exit (1); + } + else + break; + } + + if (argc != 1) + { + fprintf (stderr, "%s: wrong arguments\n", progname); + exit (1); + } + dbname = *argv; + + dbf = gdbm_open (dbname, block_size, mode|flags, 00664, NULL); + + while (fgets (buf, sizeof buf, stdin)) + { + size_t i, j; + size_t len = strlen (buf); + + if (buf[len - 1] != '\n') + { + fprintf (stderr, "%s: %d: line too long\n", + progname, line); + continue; + } + + buf[--len] = 0; + + line++; + + for (i = j = 0; i < len; i++) + { + if (buf[i] == '\\') + i++; + else if (buf[i] == delim) + break; + else + buf[j++] = buf[i]; + } + + if (buf[i] != delim) + { + fprintf (stderr, "%s: %d: malformed line\n", + progname, line); + continue; + } + + key.dptr = buf; + key.dsize = j + data_z; + data.dptr = buf + j + 1; + data.dsize = strlen (buf + j + 1) + data_z; + if (gdbm_store (dbf, key, data, replace) != 0) + { + fprintf (stderr, "%s: %d: item not inserted\n", + progname, line); + exit (1); + } + } + gdbm_close (dbf); + exit (0); +} diff --git a/tests/num2word.c b/tests/num2word.c new file mode 100644 index 0000000..4b55a35 --- /dev/null +++ b/tests/num2word.c @@ -0,0 +1,255 @@ +/* This file is part of GDBM test suite. + Copyright (C) 2011 Free Software Foundation, Inc. + + GDBM 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, or (at your option) + any later version. + + GDBM 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 GDBM. If not, see . +*/ +#include "autoconf.h" +#include +#include +#include +#include +#include + +const char *progname; + +const char *nstr[][10] = { + { "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine" + }, + { "ten", + "eleven", + "twelve", + "thirteen", + "fourteen", + "fifteen", + "sixteen", + "seventeen", + "eighteen", + "nineteen" + }, + { NULL, + NULL, + "twenty", + "thirty", + "fourty", + "fifty", + "sixty", + "seventy", + "eighty", + "ninety" + } +}; + +const char *short_scale[] = { + "one", + "thousand", + "million", + "billion" + /* End of range for 32-bit unsigned long */ +}; +size_t short_scale_max = sizeof (short_scale) / sizeof (short_scale[0]); + +char buffer[1024]; +size_t bufsize = sizeof(buffer); +size_t bufoff; +int delim = 0; + +void +copy (const char *str, int dch) +{ + size_t len = strlen (str); + if (len + !!dch > bufoff) + abort (); + if (dch) + buffer[--bufoff] = dch; + bufoff -= len; + memcpy (buffer + bufoff, str, len); + delim = ' '; +} + +void +format_100 (unsigned long num) +{ + if (num == 0) + ; + else if (num < 10) + copy (nstr[0][num], delim); + else if (num < 20) + copy (nstr[1][num-10], delim); + else + { + unsigned long tens = num / 10; + num %= 10; + if (num) + { + copy (nstr[0][num], delim); + copy ("-", 0); + copy (nstr[2][tens], 0); + } + else + copy (nstr[2][tens], delim); + } +} + +void +format_1000 (unsigned long num, int more) +{ + size_t n = num % 100; + num /= 100; + format_100 (n); + more |= num != 0; + if (n && more) + copy ("and", delim); + if (num) + { + copy ("hundred", delim); + copy (nstr[0][num], delim); + } +} + + +void +format_number (unsigned long num) +{ + int s = 0; + size_t off; + + bufoff = bufsize; + buffer[--bufoff] = 0; + off = bufoff; + delim = 0; + + do + { + unsigned long n = num % 1000; + + num /= 1000; + + if (s > 0 && ((n && off > bufoff) || num == 0)) + copy (short_scale[s], delim); + s++; + + if (s > short_scale_max) + abort (); + + format_1000 (n, num != 0); + } + while (num); + + if (bufoff + 1 == bufsize) + copy (nstr[0][0], 0); +} + + +void +print_number (unsigned long num) +{ + format_number (num); + printf ("%lu\t%s\n", num, buffer + bufoff); +} + +void +print_range (unsigned long num, unsigned long to) +{ + for (; num <= to; num++) + print_number (num); +} + +unsigned long +xstrtoul (char *arg, char **endp) +{ + unsigned long num; + char *p; + + errno = 0; + num = strtoul (arg, &p, 10); + if (errno) + { + fprintf (stderr, "%s: invalid number: ", progname); + perror (arg); + exit (2); + } + if (endp) + *endp = p; + else if (*p) + { + fprintf (stderr, "%s: invalid number (near %s)\n", + progname, p); + exit (2); + } + + return num; +} + +int +main (int argc, char **argv) +{ + progname = argv[0]; + + if (argc == 1 || strcmp (argv[1], "-h") == 0) + { + printf ("usage: %s NUM [NUM...]\n", progname); + printf ("where NUM is a decimal number, NUM:COUNT or NUM-NUM\n"); + exit (0); + } + + while (--argc) + { + char *arg = *++argv; + unsigned long num, num2; + char *p; + + num = xstrtoul (arg, &p); + if (*p == 0) + print_number (num); + else if (*p == ':') + { + *p++ = 0; + num2 = xstrtoul (p, NULL); + if (num2 == 0) + { + fprintf (stderr, "%s: invalid count\n", progname); + exit (2); + } + print_range (num, num + num2 - 1); + } + else if (*p == '-') + { + *p++ = 0; + num2 = xstrtoul (p, NULL); + if (num2 < num) + { + fprintf (stderr, "%s: invalid range: %lu-%lu\n", + progname, num, num2); + exit (2); + } + + print_range (num, num2); + } + else + { + fprintf (stderr, "%s: invalid argument\n", progname); + exit (2); + } + } + exit (0); +} diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..5dae7f6 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,33 @@ +# This file is part of GDBM. -*- autoconf -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +m4_version_prereq([2.52g]) + +m4_define([AT_SKIP_TEST],[exit 77]) + +dnl AT_SORT_PREREQ - Skip test if sort utility outputs unwanted data on stderr +m4_define([AT_SORT_PREREQ],[ +test -z "`sort < /dev/null 2>&1`" || AT_SKIP_TEST +]) + +dnl # Begin tests + +AT_INIT +m4_include([version.at]) +m4_include([create00.at]) +m4_include([fetch00.at]) +m4_include([fetch01.at]) +# End of testsuite.at diff --git a/tests/version.at b/tests/version.at new file mode 100644 index 0000000..6b73953 --- /dev/null +++ b/tests/version.at @@ -0,0 +1,33 @@ +# This file is part of GDBM. -*- autoconf -*- +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# GDBM 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, or (at your option) +# any later version. +# +# GDBM 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 GDBM. If not, see . */ + +AT_SETUP([gdbm version]) + +AT_CHECK([testgdbm --version | sed 1q], + [0], + [testgdbm (AT_PACKAGE_NAME) AT_PACKAGE_VERSION +], +[], +[cat >$[]XFAILFILE <<'_EOT' + +============================================================== +WARNING: Not using the proper version, *all* checks dubious... +============================================================== +_EOT +], +[rm -f $[]XFAILFILE]) + +AT_CLEANUP -- cgit v1.2.1