aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-10 22:27:18 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-11-10 22:27:18 +0000
commit902a2e4bb5aa53241898ae34dcf7aafb29df7b7e (patch)
tree8ccc38229f02ecf7ae264712e829ba5ae64e5912 /tests
parent3556dd6310425a2c175e66a9ba6f7d5f61304302 (diff)
downloadgdbm-902a2e4bb5aa53241898ae34dcf7aafb29df7b7e.tar.gz
gdbm-902a2e4bb5aa53241898ae34dcf7aafb29df7b7e.tar.bz2
Fix handling of NDBM databases in read-only mode.
* compat/dbmopen.c (ndbm_open_dir_file0): Open dir file in read-only mode if the database is being opened as GDBM_READER. * tests/dbmcvt.at: New file. * tests/dbmfetch02.at: New file. * tests/dbmfetch03.at: New file. * tests/Makefile.am (TESTSUITE_AT): Add new files. * tests/testsuite.at: Include new testcases.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/dbmcvt.at34
-rw-r--r--tests/dbmfetch02.at32
-rw-r--r--tests/dbmfetch03.at36
-rw-r--r--tests/testsuite.at4
5 files changed, 109 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6075c38..bfbcd9e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,8 +52,11 @@ TESTSUITE_AT = \
dbmdel00.at\
dbmdel01.at\
dbmdel02.at\
+ dbmcvt.at\
dbmfetch00.at\
dbmfetch01.at\
+ dbmfetch02.at\
+ dbmfetch03.at\
create00.at\
delete00.at\
delete01.at\
diff --git a/tests/dbmcvt.at b/tests/dbmcvt.at
new file mode 100644
index 0000000..c314c8e
--- /dev/null
+++ b/tests/dbmcvt.at
@@ -0,0 +1,34 @@
+# 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 <http://www.gnu.org/licenses/>. */
+
+AT_SETUP([converting a 1.8-style database])
+AT_KEYWORDS([dbm fetch cvt])
+
+AT_CHECK([
+AT_COMPAT_PREREQ
+num2word 1:10 | dtload test
+rm test.dir
+ln test.pag test.dir
+dtfetch test 6
+cmp test.pag test.dir >/dev/null 2>&1 && exit 1
+exit 0
+],
+[0],
+[six
+])
+
+AT_CLEANUP
+
diff --git a/tests/dbmfetch02.at b/tests/dbmfetch02.at
new file mode 100644
index 0000000..c581a22
--- /dev/null
+++ b/tests/dbmfetch02.at
@@ -0,0 +1,32 @@
+# 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 <http://www.gnu.org/licenses/>. */
+
+AT_SETUP([fetch from a read-only database])
+AT_KEYWORDS([dbm fetch fetch02 dbmfetch02])
+
+AT_CHECK([
+AT_COMPAT_PREREQ
+num2word 1:10 | dtload test
+chmod -w test.dir test.pag
+dtfetch test 6 10
+],
+[0],
+[six
+ten
+])
+
+AT_CLEANUP
+
diff --git a/tests/dbmfetch03.at b/tests/dbmfetch03.at
new file mode 100644
index 0000000..b1e149b
--- /dev/null
+++ b/tests/dbmfetch03.at
@@ -0,0 +1,36 @@
+# 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 <http://www.gnu.org/licenses/>. */
+
+AT_SETUP([fetch from a read-only 1.8-style database])
+AT_KEYWORDS([dbm fetch fetch03 dbmfetch03])
+
+AT_CHECK([
+AT_COMPAT_PREREQ
+mkdir dir
+cd dir
+num2word 1:10 | dtload test
+rm test.dir
+ln test.pag test.dir
+chmod -w test.dir test.pag .
+dtfetch test 6 10
+],
+[0],
+[six
+ten
+])
+
+AT_CLEANUP
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index a7827c2..a13b3fb 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -47,8 +47,12 @@ AT_BANNER([Compatibility library (dbm/ndbm)])
m4_include([dbmcreate00.at])
+m4_include([dbmcvt.at])
+
m4_include([dbmfetch00.at])
m4_include([dbmfetch01.at])
+m4_include([dbmfetch02.at])
+m4_include([dbmfetch03.at])
m4_include([dbmdel00.at])
m4_include([dbmdel01.at])

Return to:

Send suggestions and report system problems to the System administrator.