diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-05 11:32:27 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-05 11:32:27 +0000 |
commit | 02f5d1c3e066af4ef00085a433f37d9a6d1a636f (patch) | |
tree | 9f88e92606662ce08f6fb78320358b41618198ea | |
parent | 92a4099a3c02a200c4ee8d776808fa9dc0f9978c (diff) | |
download | gdbm-02f5d1c3e066af4ef00085a433f37d9a6d1a636f.tar.gz gdbm-02f5d1c3e066af4ef00085a433f37d9a6d1a636f.tar.bz2 |
New files.
-rw-r--r-- | tests/.cvsignore | 4 | ||||
-rw-r--r-- | tests/dbmcreate00.at | 30 | ||||
-rw-r--r-- | tests/dbmdel00.at | 40 | ||||
-rw-r--r-- | tests/dbmdel01.at | 32 | ||||
-rw-r--r-- | tests/dbmdel02.at | 29 | ||||
-rw-r--r-- | tests/dtdel.c | 96 | ||||
-rw-r--r-- | tests/dtdump.c | 97 | ||||
-rw-r--r-- | tests/dtload.c | 151 | ||||
-rw-r--r-- | tests/progname.h | 32 |
9 files changed, 511 insertions, 0 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore index de9d411..8950eb4 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore | |||
@@ -5,6 +5,10 @@ Makefile | |||
5 | Makefile.in | 5 | Makefile.in |
6 | atconfig | 6 | atconfig |
7 | atlocal | 7 | atlocal |
8 | dtdel | ||
9 | dtdump | ||
10 | dtfetch | ||
11 | dtload | ||
8 | gtdel | 12 | gtdel |
9 | gtdump | 13 | gtdump |
10 | gtfetch | 14 | gtfetch |
diff --git a/tests/dbmcreate00.at b/tests/dbmcreate00.at new file mode 100644 index 0000000..157bd35 --- /dev/null +++ b/tests/dbmcreate00.at | |||
@@ -0,0 +1,30 @@ | |||
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([create database: dbm interface]) | ||
18 | AT_KEYWORDS([dbm create create00 dbmcreate00]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | AT_SORT_PREREQ | ||
23 | num2word 1:1000 > input | ||
24 | dtload test < input | ||
25 | dtdump test | sort -k1,2 -n > output | ||
26 | diff -u input output | ||
27 | ]) | ||
28 | |||
29 | AT_CLEANUP | ||
30 | |||
diff --git a/tests/dbmdel00.at b/tests/dbmdel00.at new file mode 100644 index 0000000..8ff08dc --- /dev/null +++ b/tests/dbmdel00.at | |||
@@ -0,0 +1,40 @@ | |||
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([delete a record (dbm)]) | ||
18 | AT_KEYWORDS([dbm delete delete00 dbmdel00]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | AT_SORT_PREREQ | ||
23 | num2word 1:10 | dtload test | ||
24 | dtdel test 8 | ||
25 | dtdump test | sort -k1,2 -n | ||
26 | ], | ||
27 | [0], | ||
28 | [1 one | ||
29 | 2 two | ||
30 | 3 three | ||
31 | 4 four | ||
32 | 5 five | ||
33 | 6 six | ||
34 | 7 seven | ||
35 | 9 nine | ||
36 | 10 ten | ||
37 | ]) | ||
38 | |||
39 | AT_CLEANUP | ||
40 | |||
diff --git a/tests/dbmdel01.at b/tests/dbmdel01.at new file mode 100644 index 0000000..1b537a1 --- /dev/null +++ b/tests/dbmdel01.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([delete (dbm): non existing record]) | ||
18 | AT_KEYWORDS([dbm delete delete01 dbmdel01]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | AT_SORT_PREREQ | ||
23 | num2word 1:10 | dtload test | ||
24 | dtdel test 11 | ||
25 | ], | ||
26 | [2], | ||
27 | [], | ||
28 | [dtdel: cannot delete 11: Item not found | ||
29 | ]) | ||
30 | |||
31 | AT_CLEANUP | ||
32 | |||
diff --git a/tests/dbmdel02.at b/tests/dbmdel02.at new file mode 100644 index 0000000..9b08974 --- /dev/null +++ b/tests/dbmdel02.at | |||
@@ -0,0 +1,29 @@ | |||
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([delete (dbm): all records]) | ||
18 | AT_KEYWORDS([dbm delete delete02 dbmdel02]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_COMPAT_PREREQ | ||
22 | num2word 1:10 | dtload test | ||
23 | dtdel test 1 2 3 4 5 6 7 8 9 10 | ||
24 | dtdump test | ||
25 | ], | ||
26 | [0]) | ||
27 | |||
28 | AT_CLEANUP | ||
29 | |||
diff --git a/tests/dtdel.c b/tests/dtdel.c new file mode 100644 index 0000000..b7d0112 --- /dev/null +++ b/tests/dtdel.c | |||
@@ -0,0 +1,96 @@ | |||
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 <stdio.h> | ||
19 | #include <stdlib.h> | ||
20 | #include <string.h> | ||
21 | #include "dbm.h" | ||
22 | #include "progname.h" | ||
23 | |||
24 | int | ||
25 | main (int argc, char **argv) | ||
26 | { | ||
27 | const char *progname = canonical_progname (argv[0]); | ||
28 | char *dbname; | ||
29 | datum key; | ||
30 | int flags = 0; | ||
31 | int data_z = 0; | ||
32 | int rc = 0; | ||
33 | |||
34 | while (--argc) | ||
35 | { | ||
36 | char *arg = *++argv; | ||
37 | |||
38 | if (strcmp (arg, "-h") == 0) | ||
39 | { | ||
40 | printf ("usage: %s [-null] [-nolock] [-nommap] [-sync] DBFILE KEY [KEY...]\n", | ||
41 | progname); | ||
42 | exit (0); | ||
43 | } | ||
44 | else if (strcmp (arg, "-null") == 0) | ||
45 | data_z = 1; | ||
46 | else if (strcmp (arg, "-nolock") == 0) | ||
47 | flags |= GDBM_NOLOCK; | ||
48 | else if (strcmp (arg, "-nommap") == 0) | ||
49 | flags |= GDBM_NOMMAP; | ||
50 | else if (strcmp (arg, "-sync") == 0) | ||
51 | flags |= GDBM_SYNC; | ||
52 | else if (strcmp (arg, "--") == 0) | ||
53 | { | ||
54 | --argc; | ||
55 | ++argv; | ||
56 | break; | ||
57 | } | ||
58 | else if (arg[0] == '-') | ||
59 | { | ||
60 | fprintf (stderr, "%s: unknown option %s\n", progname, arg); | ||
61 | exit (1); | ||
62 | } | ||
63 | else | ||
64 | break; | ||
65 | } | ||
66 | |||
67 | if (argc < 2) | ||
68 | { | ||
69 | fprintf (stderr, "%s: wrong arguments\n", progname); | ||
70 | exit (1); | ||
71 | } | ||
72 | dbname = *argv; | ||
73 | |||
74 | if (dbminit (dbname)) | ||
75 | { | ||
76 | fprintf (stderr, "dbminit failed\n"); | ||
77 | exit (1); | ||
78 | } | ||
79 | |||
80 | while (--argc) | ||
81 | { | ||