aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-11 18:39:42 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-11-11 18:39:42 +0000
commitbc12482932a6771566c7dcabc53f34e6297510f2 (patch)
treeb6f3f100201a5475fecdd1df66a45b1178831457 /tests
parent894b78d5bcb7b609a3b52ce804306a63c4761282 (diff)
downloadgdbm-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/.cvsignore4
-rw-r--r--tests/Makefile.am13
-rw-r--r--tests/cloexec00.at25
-rw-r--r--tests/cloexec01.at25
-rw-r--r--tests/cloexec02.at27
-rw-r--r--tests/cloexec03.at26
-rw-r--r--tests/d_creat_ce.c90
-rw-r--r--tests/fdop.c36
-rw-r--r--tests/g_open_ce.c66
-rw-r--r--tests/g_reorg_ce.c72
-rw-r--r--tests/testsuite.at7
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
5Makefile.in 5Makefile.in
6atconfig 6atconfig
7atlocal 7atlocal
8d_creat_ce
8dtdel 9dtdel
9dtdump 10dtdump
10dtfetch 11dtfetch
11dtload 12dtload
13fdop
14g_open_ce
15g_reorg_ce
12gtdel 16gtdel
13gtdump 17gtdump
14gtfetch 18gtfetch
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
49TESTSUITE_AT = \ 49TESTSUITE_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
95if COMPAT_OPT 99if 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
98endif 102endif
99 103
100check_PROGRAMS = \ 104check_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
116gtver_LDADD = ../src/libgdbm.la 123gtver_LDADD = ../src/libgdbm.la
117gtopt_LDADD = ../src/libgdbm.la 124gtopt_LDADD = ../src/libgdbm.la
118 125
126g_open_ce_LDADD = ../src/libgdbm.la
127g_reorg_ce_LDADD = ../src/libgdbm.la
128
119dtload_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la 129dtload_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la
120dtdump_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la 130dtdump_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la
121dtfetch_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la 131dtfetch_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la
122dtdel_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la 132dtdel_LDADD = ../src/libgdbm.la ../compat/libgdbm_compat.la
133d_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
17AT_SETUP([cloexec: gdbm_open])
18AT_KEYWORDS([gdbm gdbm_open cloexec cloexec00])
19
20AT_CHECK([
21g_open_ce "$abs_builddir/fdop"
22],
230)
24
25AT_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
17AT_SETUP([cloexec: gdbm_reorganize])
18AT_KEYWORDS([gdbm gdbm_reorganize cloexec cloexec01])
19
20AT_CHECK([
21g_reorg_ce "$abs_builddir/fdop"
22],
230)
24
25AT_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
17AT_SETUP([cloexec: dbm_open])
18AT_KEYWORDS([ndbm dbm_open cloexec cloexec02])
19
20AT_CHECK([
21AT_COMPAT_PREREQ
22num2word 1:10 | dtload file
23d_creat_ce "$abs_builddir/fdop"
24],
250)
26
27AT_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
17AT_SETUP([cloexec: dbm_open -creat])
18AT_KEYWORDS([ndbm dbm_open cloexec cloexec03])
19
20AT_CHECK([
21AT_COMPAT_PREREQ
22d_creat_ce "$abs_builddir/fdop" -creat
23],
240)
25
26AT_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
26char *
27ntos (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