Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add system tests
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:237b3881b06067d0e447ad377cec4d13f088189b
User & Date: brandon 2013-11-17 12:58:27
Context
2013-11-17
13:02
fix distribution of tests check-in: d50170d84b user: brandon tags: trunk
12:58
add system tests check-in: 237b3881b0 user: brandon tags: trunk
2013-11-13
22:59
update help text check-in: 0320372b34 user: brandon tags: trunk
Changes

Changes to Makefile.am.

20
21
22
23
24
25
26




27
28
29
30
31
32
33

SUBDIRS = lib src doc
AMFLAGS_ACLOCAL = -I m4
EXTRA_DIST = psf/PSF-src-dist.in psf/PSF-src-dist psf/PSF-src-sw.in	\
psf/PSF-src-sw psf/PSF-bin.in psf/PSF psf/source_control.sh.in			\
psf/source_control.sh psf/bin_control.sh.in psf/bin_control.sh		\
m4/gnulib-cache.m4





# Environment Controls for swign:
#   To enter passphrase via gpg-agent: SWPACKAGEPASSFD="agent"
#   To enter passphrase via the tty:   SWPACKAGEPASSFD="tty" or unset, because this is the default
#   To specify the GPG User:    export GNUPGNAME="Your-GPG-Name"
#   To specify the GPG homedir: export GNUPGHOME="Your-GPG-homedir"








>
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

SUBDIRS = lib src doc
AMFLAGS_ACLOCAL = -I m4
EXTRA_DIST = psf/PSF-src-dist.in psf/PSF-src-dist psf/PSF-src-sw.in	\
psf/PSF-src-sw psf/PSF-bin.in psf/PSF psf/source_control.sh.in			\
psf/source_control.sh psf/bin_control.sh.in psf/bin_control.sh		\
m4/gnulib-cache.m4

TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
				  $(top_srcdir)/build-aux/tap-driver.sh
TESTS = tests/system_tests.test

# Environment Controls for swign:
#   To enter passphrase via gpg-agent: SWPACKAGEPASSFD="agent"
#   To enter passphrase via the tty:   SWPACKAGEPASSFD="tty" or unset, because this is the default
#   To specify the GPG User:    export GNUPGNAME="Your-GPG-Name"
#   To specify the GPG homedir: export GNUPGHOME="Your-GPG-homedir"

Changes to configure.ac.

24
25
26
27
28
29
30

31
32
33
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
..
54
55
56
57
58
59
60
61

62
AM_INIT_AUTOMAKE

AC_PROG_CC_C99
gl_EARLY

AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
AC_PROG_RANLIB

AC_FUNC_ALLOCA

gl_INIT
AC_ARG_WITH([kyotocabinet],
            [AS_HELP_STRING([--with-kyotocabinet],
                            [enable Kyoto Cabinet as the DBM backend instead of GDBM])],
            [], [with_kyotocabinet=no])

LIBKYOTOCABINET=
LIBGDBM=
AS_IF([test "x$with_kyotocabinet" != xno],

      [AC_CHECK_LIB([kyotocabinet], [kcdbopen],
                    [AC_SUBST([LIBKYOTOCABINET], ["-lkyotocabinet"])
                     AC_DEFINE([HAVE_KYOTOCABINET], [1],
                     [Define if you have libkyotocabiet])],
                    [AC_MSG_FAILURE(
                     [--with-kyotocabinet was given, but test for libkyotocabinet failed])])]
      [AC_CHECK_HEADER([kclangc.h], [],
................................................................................
                     [Define if you have libgdbm])],
                    [AC_MSG_ERROR([--with-gdbm was given, but libgdbm was not found!])])]
      [AC_CHECK_HEADER([gdbm.h], [],
                       [AC_MSG_ERROR([gdbm.h was not found!])])])

AC_CONFIG_FILES([Makefile psf/source_control.sh psf/PSF-src-sw psf/PSF-src-dist
                 psf/PSF-bin psf/bin_control.sh src/Makefile doc/Makefile
                 lib/Makefile])

AC_OUTPUT







>











>







 







|
>

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
56
57
58
59
60
61
62
63
64
65
AM_INIT_AUTOMAKE

AC_PROG_CC_C99
gl_EARLY

AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
AC_PROG_RANLIB
AC_PROG_AWK
AC_FUNC_ALLOCA

gl_INIT
AC_ARG_WITH([kyotocabinet],
            [AS_HELP_STRING([--with-kyotocabinet],
                            [enable Kyoto Cabinet as the DBM backend instead of GDBM])],
            [], [with_kyotocabinet=no])

LIBKYOTOCABINET=
LIBGDBM=
AS_IF([test "x$with_kyotocabinet" != xno],
      [AC_SUBST([WITH_KYOTOCABINET], ["1"])]
      [AC_CHECK_LIB([kyotocabinet], [kcdbopen],
                    [AC_SUBST([LIBKYOTOCABINET], ["-lkyotocabinet"])
                     AC_DEFINE([HAVE_KYOTOCABINET], [1],
                     [Define if you have libkyotocabiet])],
                    [AC_MSG_FAILURE(
                     [--with-kyotocabinet was given, but test for libkyotocabinet failed])])]
      [AC_CHECK_HEADER([kclangc.h], [],
................................................................................
                     [Define if you have libgdbm])],
                    [AC_MSG_ERROR([--with-gdbm was given, but libgdbm was not found!])])]
      [AC_CHECK_HEADER([gdbm.h], [],
                       [AC_MSG_ERROR([gdbm.h was not found!])])])

AC_CONFIG_FILES([Makefile psf/source_control.sh psf/PSF-src-sw psf/PSF-src-dist
                 psf/PSF-bin psf/bin_control.sh src/Makefile doc/Makefile
                 lib/Makefile tests/system_tests.test], [chmod +x tests/system_tests.test])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT

Added tests/system_tests.test.in.





























































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh
# system_tests.test --- Run system tests on the zeptodb executables

# Copyright (C) 2013 Brandon Invergo <brandon@invergo.net>

# Author: Brandon Invergo <brandon@invergo.net>

# This program 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 3
# of the License, or (at your option) any later version.

# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.

BINDIR="@srcdir@/src"
ZDBC="${BINDIR}/zdbc"
ZDBF="${BINDIR}/zdbf"
ZDBR="${BINDIR}/zdbr"
ZDBS="${BINDIR}/zdbs"

if [ @WITH_KYOTOCABINET@ ]; then
    TESTDB=test.kch
else
    TESTDB=test.db
fi

msg () {
    printf "%s\n" "$1"
}

fail () {
    msg "not ok $1 - $2"
}

pass () {
    msg "ok $1 - $2"
}

xfail () {
    msg "ok $1 - $2"
}

test_create_db () {
    "${ZDBC}" ${TESTDB} || fail $1 "database creation failed"
    if [ -f ${TESTDB} ]; then
        pass $1 "database created"
    else
        fail $1 "database creation process succeeded but file does not exist"
    fi
    rm ${TESTDB}
}

test_create_large_db () {
    "${ZDBC}" --num-buckets=1000000000000000000 \
        --mmap-size=1000000000000000000 ${TESTDB} || \
        fail $1 "large database creation failed"
    if [ -f ${TESTDB} ]; then
        pass $1 "large database creation succeeded"
    else
        fail $1 "large database creation succeeded but file does not exist"
    fi
    rm ${TESTDB}
    return $?
}

create_test_db () {
    "${ZDBC}" ${TESTDB}
}

remove_test_db () {
    rm ${TESTDB}
}

test_store_records () {
    "${ZDBS}" ${TESTDB} <<EOF
foo|bar
baz|quux
blah|bleh
another|record
EOF
    [ $? ] || fail $1 "store records failed"
    pass $1 "store records succeeded"
    return $?
}

test_store_records_with_alt_delim () {
    "${ZDBS}" -d'~' ${TESTDB} <<EOF
1~2
3~4
5~6
EOF
    [ $? ] || fail $1 "store records with alternate delimiter failed"
    pass $1 "store records with alternate delimiter succeeded"
    return $?
}

test_fetch_records () {
    vals=`"${ZDBF}" ${TESTDB} <<EOF
foo
baz
EOF
` || fail $1 "fetch records failed"
    if [[ "$vals" != `printf "bar\nquux"` ]]; then
        fail $1 "fetch records returned the wrong results"
    else
        pass $1 "fetch records succeeded"
    fi
    return $?
}

test_fetch_records_with_delim () {
    vals=`"${ZDBF}" -d'~' ${TESTDB} <<EOF
foo
baz
EOF
` || fail $1 "fetch records with a delimiter failed"
    if [[ "$vals" != `printf "foo~bar\nbaz~quux"` ]]; then
        fail $1 "fetch records with a delimiter returned the wrong results"
    else
        pass $1 "fetch records with delimiter succeeded"
    fi
    return $?
}

test_fetch_all_records () {
    numrecs=`"${ZDBF}" -a ${TESTDB} | wc -l` || fail $1 "fetch all records failed"
    if [[ "$numrecs" != "7" ]]; then
        fail $1 "fetch all records returned the wrong results"
    else
        pass $1 "fetch all records succeeded"
    fi
    return $?
}

test_remove_records () {
    "${ZDBR}" ${TESTDB} <<EOF
foo
baz
blah
another
1
3
5
EOF
    [ $? ] || fail $1 "remove records failed"
    if [[ "x`"${ZDBF}" -a ${TESTDB}`" != "x" ]]; then
        fail $1 "remove records - some records remain"
    else
        pass $1 "remove records succeeded"
    fi
    return $?
}

run_tests () {
    test_create_db 1
    test_create_large_db 2
    create_test_db
    test_store_records 3
    test_store_records_with_alt_delim 4
    test_fetch_records 5
    test_fetch_records_with_delim 6
    test_fetch_all_records 7
    test_remove_records 8
    remove_test_db
}

echo 1..8
run_tests