diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-11 18:39:42 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-11 18:39:42 +0000 |
commit | bc12482932a6771566c7dcabc53f34e6297510f2 (patch) | |
tree | b6f3f100201a5475fecdd1df66a45b1178831457 /tests | |
parent | 894b78d5bcb7b609a3b52ce804306a63c4761282 (diff) | |
download | gdbm-bc12482932a6771566c7dcabc53f34e6297510f2.tar.gz gdbm-bc12482932a6771566c7dcabc53f34e6297510f2.tar.bz2 |
Implement cloexec in gdbm_reorganize. Add test cases.
* compat/dbmopen.c: Apply O_CLOEXEC for newly created dir
file, if requested.
* src/gdbmdefs.h (gdbm_file_info) <cloexec>: New member.
* src/gdbmopen.c (gdbm_open): Initialize cloexec member.
* src/gdbmreorg.c (gdbm_reorganize): Propagate cloexec bit
to the new database.
* tests/.cvsignore: Update.
* tests/cloexec00.at: New test case.
* tests/cloexec01.at: Likewise.
* tests/cloexec02.at: Likewise.
* tests/cloexec03.at: Likewise.
* fdop.c: New auxiliary program.
* g_open_ce: New test program.
* g_reorg_ce: New test program.
* d_creat_ce: New test program.
* tests/Makefile.am: Add new test cases and test programs.
* tests/testsuite.at: Include new test cases.
* doc/gdbm.texinfo: Minor change.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.cvsignore | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 13 | ||||
-rw-r--r-- | tests/cloexec00.at | 25 | ||||
-rw-r--r-- | tests/cloexec01.at | 25 | ||||
-rw-r--r-- | tests/cloexec02.at | 27 | ||||
-rw-r--r-- | tests/cloexec03.at | 26 | ||||
-rw-r--r-- | tests/d_creat_ce.c | 90 | ||||
-rw-r--r-- | tests/fdop.c | 36 | ||||
-rw-r--r-- | tests/g_open_ce.c | 66 | ||||
-rw-r--r-- | tests/g_reorg_ce.c | 72 | ||||
-rw-r--r-- | tests/testsuite.at | 7 |
11 files changed, 390 insertions, 1 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore index 3275961..0883563 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore | |||
@@ -5,10 +5,14 @@ Makefile | |||
5 | Makefile.in | 5 | Makefile.in |
6 | atconfig | 6 | atconfig |
7 | atlocal | 7 | atlocal |
8 | d_creat_ce | ||
8 | dtdel | 9 | dtdel |
9 | dtdump | 10 | dtdump |
10 | dtfetch | 11 | dtfetch |
11 | dtload | 12 | dtload |
13 | fdop | ||
14 | g_open_ce | ||
15 | g_reorg_ce | ||
12 | gtdel | 16 | gtdel |
13 | gtdump | 17 | gtdump |
14 | gtfetch | 18 | gtfetch |
diff --git a/tests/Makefile.am b/tests/Makefile.am index bfbcd9e..95d7fff 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am | |||
@@ -48,6 +48,10 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac $(srcdir)/Makefile.am | |||
48 | 48 | ||
49 | TESTSUITE_AT = \ | 49 | TESTSUITE_AT = \ |
50 | testsuite.at\ | 50 | testsuite.at\ |
51 | cloexec00.at\ | ||
52 | cloexec01.at\ | ||
53 | cloexec02.at\ | ||
54 | cloexec03.at\ | ||
51 | dbmcreate00.at\ | 55 | dbmcreate00.at\ |
52 | dbmdel00.at\ | 56 | dbmdel00.at\ |
53 | dbmdel01.at\ | 57 | dbmdel01.at\ |
@@ -94,10 +98,13 @@ check-local: atconfig atlocal $(TESTSUITE) | |||
94 | 98 | ||
95 | if COMPAT_OPT | 99 | if COMPAT_OPT |
96 | DBMINCLUDES = -I$(top_srcdir)/compat | 100 | DBMINCLUDES = -I$(top_srcdir)/compat |
97 | DBMPROGS = dtload dtdump dtfetch dtdel | 101 | DBMPROGS = dtload dtdump dtfetch dtdel d_creat_ce |
98 | endif | 102 | endif |
99 | 103 | ||
100 | check_PROGRAMS = \ | 104 | check_PROGRAMS = \ |
105 | fdop\ | ||
106 | g_open_ce\ | ||
107 | g_reorg_ce\ | ||
101 | gtdel\ | 108 | gtdel\ |
102 | gtdump\ | 109 | gtdump\ |
103 | gtfetch\ | 110 | gtfetch\ |
@@ -116,9 +123,13 @@ gtfetch_LDADD = ../src/libgdbm.la | |||
116 | gtver_LDADD = ../src/libgdbm.la | 123 | gtver_LDADD = ../src/libgdbm.la |
117 | gtopt_LDADD = ../src/libgdbm.la | 124 | gtopt_LDADD = ../src/libgdbm.la |
118 | 125 | ||
126 | g_open_ce_LDADD = ../src/libgdbm.la | ||
127 | g_reorg_ce_LDADD = ../src/libgdbm.la | ||
128 | |||
119 | dtload_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la | 129 | dtload_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la |
120 | dtdump_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la | 130 | dtdump_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la |
121 | dtfetch_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la | 131 | dtfetch_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la |
122 | dtdel_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la | 132 | dtdel_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la |
133 | d_creat_ce_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la | ||
123 | 134 | ||
124 | 135 | ||
diff --git a/tests/cloexec00.at b/tests/cloexec00.at new file mode 100644 index 0000000..022b12f --- /dev/null +++ b/tests/cloexec00.at | |||
@@ -0,0 +1,25 @@ | |||
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([cloexec: gdbm_open]) | ||
18 | AT_KEYWORDS([gdbm gdbm_open cloexec cloexec00]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | g_open_ce "$abs_builddir/fdop" | ||
22 | ], | ||
23 | 0) | ||
24 | |||
25 | AT_CLEANUP | ||
diff --git a/tests/cloexec01.at b/tests/cloexec01.at new file mode 100644 index 0000000..21baac6 --- /dev/null +++ b/tests/cloexec01.at | |||
@@ -0,0 +1,25 @@ | |||
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([cloexec: gdbm_reorganize]) | ||
18 | AT_KEYWORDS([gdbm gdbm_reorganize cloexec cloexec01]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | g_reorg_ce "$abs_builddir/fdop" | ||
22 | ], | ||
23 | 0) | ||
24 | |||
25 | AT_CLEANUP | ||
diff --git a/tests/cloexec02.at b/tests/cloexec02.at new file mode 100644 index 0000000..9d1b7e3 --- /dev/null +++ b/tests/cloexec02.at | |||
@@ -0,0 +1,27 @@ | |||
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([cloexec: dbm_open]) | ||
18 | AT_KEYWORDS([ndbm dbm_open cloexec cloexec02]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | num2word 1:10 | dtload file | ||
23 | d_creat_ce "$abs_builddir/fdop" | ||
24 | ], | ||
25 | 0) | ||
26 | |||
27 | AT_CLEANUP | ||
diff --git a/tests/cloexec03.at b/tests/cloexec03.at new file mode 100644 index 0000000..5fa1c0f --- /dev/null +++ b/tests/cloexec03.at | |||
@@ -0,0 +1,26 @@ | |||
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([cloexec: dbm_open -creat]) | ||
18 | AT_KEYWORDS([ndbm dbm_open cloexec cloexec03]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | d_creat_ce "$abs_builddir/fdop" -creat | ||
23 | ], | ||
24 | 0) | ||
25 | |||
26 | AT_CLEANUP | ||
diff --git a/tests/d_creat_ce.c b/tests/d_creat_ce.c new file mode 100644 index 0000000..6a6cff2 --- /dev/null +++ b/tests/d_creat_ce.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* This file is part of GDBM test suite. | ||
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 | #include "autoconf.h" | ||
18 | #include <stdlib.h> | ||
19 | #include <stdio.h> | ||
20 | #include <string.h> | ||
21 | #include <unistd.h> | ||
22 | #include <sys/stat.h> | ||
23 | #include <fcntl.h> | ||
24 | #include <ndbm.h> | ||
25 | |||
26 | char * | ||
27 | ntos (int n, char *buf, size_t size) | ||
28 | { | ||
29 | char *p = buf + size; | ||
30 | *--p = 0; | ||
31 | do | ||
32 | { | ||
33 | int x = n % 10; | ||
34 | *--p = '0' + x; | ||
35 | n /= 10; | ||
36 | } | ||
37 | while (n); | ||
38 | return p; | ||
39 | } | ||
40 | |||