summaryrefslogtreecommitdiffabout
path: root/tests
authorSergey Poznyakoff <gray@gnu.org>2018-07-01 07:08:55 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-07-01 07:19:36 (GMT)
commit030e685eb9df82f63d73a1bf206da84b7aa52374 (patch) (side-by-side diff)
treedcfc6693121e332d2cdb7c579e65ed0f397dc78e /tests
parentd6fe3b45bc669a6bc3f21e4bda69c6a052d78482 (diff)
downloadgdbm-030e685eb9df82f63d73a1bf206da84b7aa52374.tar.gz
gdbm-030e685eb9df82f63d73a1bf206da84b7aa52374.tar.bz2
Change return value of gdbm_close and gdbm_sync
* src/gdbm.h.in (gdbm_close, gdbm_sync): Return int (GDBM_FILE_CLOSE_ERROR, GDBM_FILE_SYNC_ERROR): New error codes. * src/gdbmclose.c (gdbm_close): Return 0 on success, -1 on failure. Set gdbm_errno and errno. * src/gdbmsync.c (gdbm_sync): Likewise. * src/gdbmerrno.c: Handle new error codes. * src/mmap.c (_gdbm_mapped_sync): Set gdbm_errno. * src/proto.h (gdbm_file_sync): Set gdbm_errno. * doc/gdbm.3: Document changes. * doc/gdbm.texi: Document changes. * NEWS: Document changes. * configure.ac: Set patchlevel. * tests/Makefile.am: Add new test. * tests/testsuite.at: Add new test. * tests/closerr.at: New test case. * tests/closerr.c: New test program. * tests/gtdel.c: Check gdbm_close return. * tests/gtdump.c: Likewise. * tests/gtfetch.c: Likewise. * tests/gtload.c: Likewise. * tests/gtopt.c: Likewise. * tests/gtrecover.c: Likewise.
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/closerr.at5
-rw-r--r--tests/closerr.c56
-rw-r--r--tests/gtdel.c8
-rw-r--r--tests/gtdump.c8
-rw-r--r--tests/gtfetch.c8
-rw-r--r--tests/gtload.c7
-rw-r--r--tests/gtopt.c8
-rw-r--r--tests/gtrecover.c8
-rw-r--r--tests/testsuite.at2
10 files changed, 106 insertions, 6 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 827af58..dbe17dd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -54,6 +54,7 @@ TESTSUITE_AT = \
cloexec01.at\
cloexec02.at\
cloexec03.at\
+ closerr.at\
dbmcreate00.at\
dbmdel00.at\
dbmdel01.at\
@@ -108,6 +109,7 @@ if COMPAT_OPT
endif
check_PROGRAMS = \
+ closerr\
fdop\
g_open_ce\
g_reorg_ce\
diff --git a/tests/closerr.at b/tests/closerr.at
new file mode 100644
index 0000000..5f5e208
--- a/dev/null
+++ b/tests/closerr.at
@@ -0,0 +1,5 @@
+# This file is part of GDBM testsuite. -*- autoconf -*-
+AT_SETUP([gdbm_close error])
+AT_KEYWORDS([close])
+AT_CHECK(closerr,1,[],[ignore])
+AT_CLEANUP
diff --git a/tests/closerr.c b/tests/closerr.c
new file mode 100644
index 0000000..5bc8fdc
--- a/dev/null
+++ b/tests/closerr.c
@@ -0,0 +1,56 @@
+/* This file is part of GDBM test suite.
+ Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
+*/
+#include "autoconf.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include "gdbm.h"
+
+int
+main (int argc, char **argv)
+{
+ GDBM_FILE dbf;
+ char dbname[] = "junk.gdbm";
+ int rc;
+
+ assert (argc == 1);
+
+ dbf = gdbm_open (dbname, 0, GDBM_NEWDB, 0600, NULL);
+ if (!dbf)
+ {
+ fprintf (stderr, "gdbm_open: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ return 1;
+ }
+ if (close (gdbm_fdesc (dbf)))
+ {
+ perror ("close");
+ return 77;
+ }
+
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/gtdel.c b/tests/gtdel.c
index 729086c..d0c711d 100644
--- a/tests/gtdel.c
+++ b/tests/gtdel.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "gdbm.h"
#include "progname.h"
@@ -93,6 +94,11 @@ main (int argc, char **argv)
rc = 2;
}
}
- gdbm_close (dbf);
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ rc = 3;
+ }
exit (rc);
}
diff --git a/tests/gtdump.c b/tests/gtdump.c
index dcc27ac..fb27997 100644
--- a/tests/gtdump.c
+++ b/tests/gtdump.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "gdbm.h"
#include "progname.h"
@@ -115,6 +116,11 @@ main (int argc, char **argv)
exit (1);
}
- gdbm_close (dbf);
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ exit (3);
+ }
exit (0);
}
diff --git a/tests/gtfetch.c b/tests/gtfetch.c
index c1ea45e..5070fcc 100644
--- a/tests/gtfetch.c
+++ b/tests/gtfetch.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "gdbm.h"
#include "progname.h"
@@ -130,6 +131,11 @@ main (int argc, char **argv)
fputc ('\n', stdout);
}
- gdbm_close (dbf);
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ rc = 3;
+ }
exit (rc);
}
diff --git a/tests/gtload.c b/tests/gtload.c
index 21c89b2..1493236 100644
--- a/tests/gtload.c
+++ b/tests/gtload.c
@@ -287,6 +287,11 @@ main (int argc, char **argv)
}
}
}
- gdbm_close (dbf);
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ exit (3);
+ }
exit (0);
}
diff --git a/tests/gtopt.c b/tests/gtopt.c
index b461d56..236ae92 100644
--- a/tests/gtopt.c
+++ b/tests/gtopt.c
@@ -406,7 +406,13 @@ main (int argc, char **argv)
}
}
- gdbm_close (dbf);
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ exit (3);
+ }
+
exit (0);
}
diff --git a/tests/gtrecover.c b/tests/gtrecover.c
index 0527c53..f5e6f97 100644
--- a/tests/gtrecover.c
+++ b/tests/gtrecover.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <errno.h>
#include "gdbm.h"
#include "progname.h"
#include <assert.h>
@@ -119,6 +120,11 @@ main (int argc, char **argv)
rc = gdbm_recover (dbf, &rcvr, rcvr_flags);
- gdbm_close (dbf);
+ if (gdbm_close (dbf))
+ {
+ fprintf (stderr, "gdbm_close: %s; %s\n", gdbm_strerror (gdbm_errno),
+ strerror (errno));
+ rc = 3;
+ }
exit (rc);
}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index b7b1e4e..efc2705 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -43,6 +43,8 @@ m4_include([delete00.at])
m4_include([delete01.at])
m4_include([delete02.at])
+m4_include([closerr.at])
+
AT_BANNER([Block size selection])
m4_include([blocksize00.at])
m4_include([blocksize01.at])

Return to:

Send suggestions and report system problems to the System administrator.