diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-10 22:27:18 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-10 22:27:18 +0000 |
commit | 902a2e4bb5aa53241898ae34dcf7aafb29df7b7e (patch) | |
tree | 8ccc38229f02ecf7ae264712e829ba5ae64e5912 /tests | |
parent | 3556dd6310425a2c175e66a9ba6f7d5f61304302 (diff) | |
download | gdbm-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.am | 3 | ||||
-rw-r--r-- | tests/dbmcvt.at | 34 | ||||
-rw-r--r-- | tests/dbmfetch02.at | 32 | ||||
-rw-r--r-- | tests/dbmfetch03.at | 36 | ||||
-rw-r--r-- | tests/testsuite.at | 4 |
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 = \ | |||
52 | dbmdel00.at\ | 52 | dbmdel00.at\ |
53 | dbmdel01.at\ | 53 | dbmdel01.at\ |
54 | dbmdel02.at\ | 54 | dbmdel02.at\ |
55 | dbmcvt.at\ | ||
55 | dbmfetch00.at\ | 56 | dbmfetch00.at\ |
56 | dbmfetch01.at\ | 57 | dbmfetch01.at\ |
58 | dbmfetch02.at\ | ||
59 | dbmfetch03.at\ | ||
57 | create00.at\ | 60 | create00.at\ |
58 | delete00.at\ | 61 | delete00.at\ |
59 | delete01.at\ | 62 | 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 @@ | |||
1 | # This file is part of GDBM. -*- autoconf -*- | ||
2 | # Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GDBM is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 2, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GDBM is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | AT_SETUP([converting a 1.8-style database]) | ||
18 | AT_KEYWORDS([dbm fetch cvt]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | num2word 1:10 | dtload test | ||
23 | rm test.dir | ||
24 | ln test.pag test.dir | ||
25 | dtfetch test 6 | ||
26 | cmp test.pag test.dir >/dev/null 2>&1 && exit 1 | ||
27 | exit 0 | ||
28 | ], | ||
29 | [0], | ||
30 | [six | ||
31 | ]) | ||
32 | |||
33 | AT_CLEANUP | ||
34 | |||
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 @@ | |||
1 | # This file is part of GDBM. -*- autoconf -*- | ||
2 | # Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GDBM is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 2, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GDBM is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | AT_SETUP([fetch from a read-only database]) | ||
18 | AT_KEYWORDS([dbm fetch fetch02 dbmfetch02]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | num2word 1:10 | dtload test | ||
23 | chmod -w test.dir test.pag | ||
24 | dtfetch test 6 10 | ||
25 | ], | ||
26 | [0], | ||
27 | [six | ||
28 | ten | ||
29 | ]) | ||
30 | |||
31 | AT_CLEANUP | ||
32 | |||
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 @@ | |||
1 | # This file is part of GDBM. -*- autoconf -*- | ||
2 | # Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GDBM is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 2, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # GDBM is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | AT_SETUP([fetch from a read-only 1.8-style database]) | ||
18 | AT_KEYWORDS([dbm fetch fetch03 dbmfetch03]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | mkdir dir | ||
23 | cd dir | ||
24 | num2word 1:10 | dtload test | ||
25 | rm test.dir | ||
26 | ln test.pag test.dir | ||
27 | chmod -w test.dir test.pag . | ||
28 | dtfetch test 6 10 | ||
29 | ], | ||
30 | [0], | ||
31 | [six | ||
32 | ten | ||
33 | ]) | ||
34 | |||
35 | AT_CLEANUP | ||
36 | |||
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)]) | |||
47 | 47 | ||
48 | m4_include([dbmcreate00.at]) | 48 | m4_include([dbmcreate00.at]) |
49 | 49 | ||
50 | m4_include([dbmcvt.at]) | ||
51 | |||
50 | m4_include([dbmfetch00.at]) | 52 | m4_include([dbmfetch00.at]) |
51 | m4_include([dbmfetch01.at]) | 53 | m4_include([dbmfetch01.at]) |
54 | m4_include([dbmfetch02.at]) | ||
55 | m4_include([dbmfetch03.at]) | ||
52 | 56 | ||
53 | m4_include([dbmdel00.at]) | 57 | m4_include([dbmdel00.at]) |
54 | m4_include([dbmdel01.at]) | 58 | m4_include([dbmdel01.at]) |