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     20   
    21     21   SUBDIRS = lib src doc
    22     22   AMFLAGS_ACLOCAL = -I m4
    23     23   EXTRA_DIST = psf/PSF-src-dist.in psf/PSF-src-dist psf/PSF-src-sw.in	\
    24     24   psf/PSF-src-sw psf/PSF-bin.in psf/PSF psf/source_control.sh.in			\
    25     25   psf/source_control.sh psf/bin_control.sh.in psf/bin_control.sh		\
    26     26   m4/gnulib-cache.m4
           27  +
           28  +TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
           29  +				  $(top_srcdir)/build-aux/tap-driver.sh
           30  +TESTS = tests/system_tests.test
    27     31   
    28     32   # Environment Controls for swign:
    29     33   #   To enter passphrase via gpg-agent: SWPACKAGEPASSFD="agent"
    30     34   #   To enter passphrase via the tty:   SWPACKAGEPASSFD="tty" or unset, because this is the default
    31     35   #   To specify the GPG User:    export GNUPGNAME="Your-GPG-Name"
    32     36   #   To specify the GPG homedir: export GNUPGHOME="Your-GPG-homedir"
    33     37   

Changes to configure.ac.

    24     24   AM_INIT_AUTOMAKE
    25     25   
    26     26   AC_PROG_CC_C99
    27     27   gl_EARLY
    28     28   
    29     29   AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
    30     30   AC_PROG_RANLIB
           31  +AC_PROG_AWK
    31     32   AC_FUNC_ALLOCA
    32     33   
    33     34   gl_INIT
    34     35   AC_ARG_WITH([kyotocabinet],
    35     36               [AS_HELP_STRING([--with-kyotocabinet],
    36     37                               [enable Kyoto Cabinet as the DBM backend instead of GDBM])],
    37     38               [], [with_kyotocabinet=no])
    38     39   
    39     40   LIBKYOTOCABINET=
    40     41   LIBGDBM=
    41     42   AS_IF([test "x$with_kyotocabinet" != xno],
           43  +      [AC_SUBST([WITH_KYOTOCABINET], ["1"])]
    42     44         [AC_CHECK_LIB([kyotocabinet], [kcdbopen],
    43     45                       [AC_SUBST([LIBKYOTOCABINET], ["-lkyotocabinet"])
    44     46                        AC_DEFINE([HAVE_KYOTOCABINET], [1],
    45     47                        [Define if you have libkyotocabiet])],
    46     48                       [AC_MSG_FAILURE(
    47     49                        [--with-kyotocabinet was given, but test for libkyotocabinet failed])])]
    48     50         [AC_CHECK_HEADER([kclangc.h], [],
................................................................................
    54     56                        [Define if you have libgdbm])],
    55     57                       [AC_MSG_ERROR([--with-gdbm was given, but libgdbm was not found!])])]
    56     58         [AC_CHECK_HEADER([gdbm.h], [],
    57     59                          [AC_MSG_ERROR([gdbm.h was not found!])])])
    58     60   
    59     61   AC_CONFIG_FILES([Makefile psf/source_control.sh psf/PSF-src-sw psf/PSF-src-dist
    60     62                    psf/PSF-bin psf/bin_control.sh src/Makefile doc/Makefile
    61         -                 lib/Makefile])
           63  +                 lib/Makefile tests/system_tests.test], [chmod +x tests/system_tests.test])
           64  +AC_REQUIRE_AUX_FILE([tap-driver.sh])
    62     65   AC_OUTPUT

Added tests/system_tests.test.in.

            1  +#!/bin/sh
            2  +# system_tests.test --- Run system tests on the zeptodb executables
            3  +
            4  +# Copyright (C) 2013 Brandon Invergo <brandon@invergo.net>
            5  +
            6  +# Author: Brandon Invergo <brandon@invergo.net>
            7  +
            8  +# This program is free software; you can redistribute it and/or
            9  +# modify it under the terms of the GNU General Public License
           10  +# as published by the Free Software Foundation; either version 3
           11  +# of the License, or (at your option) any later version.
           12  +
           13  +# This program is distributed in the hope that it will be useful,
           14  +# but WITHOUT ANY WARRANTY; without even the implied warranty of
           15  +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
           16  +# GNU General Public License for more details.
           17  +
           18  +# You should have received a copy of the GNU General Public License
           19  +# along with this program. If not, see <http://www.gnu.org/licenses/>.
           20  +
           21  +BINDIR="@srcdir@/src"
           22  +ZDBC="${BINDIR}/zdbc"
           23  +ZDBF="${BINDIR}/zdbf"
           24  +ZDBR="${BINDIR}/zdbr"
           25  +ZDBS="${BINDIR}/zdbs"
           26  +
           27  +if [ @WITH_KYOTOCABINET@ ]; then
           28  +    TESTDB=test.kch
           29  +else
           30  +    TESTDB=test.db
           31  +fi
           32  +
           33  +msg () {
           34  +    printf "%s\n" "$1"
           35  +}
           36  +
           37  +fail () {
           38  +    msg "not ok $1 - $2"
           39  +}
           40  +
           41  +pass () {
           42  +    msg "ok $1 - $2"
           43  +}
           44  +
           45  +xfail () {
           46  +    msg "ok $1 - $2"
           47  +}
           48  +
           49  +test_create_db () {
           50  +    "${ZDBC}" ${TESTDB} || fail $1 "database creation failed"
           51  +    if [ -f ${TESTDB} ]; then
           52  +        pass $1 "database created"
           53  +    else
           54  +        fail $1 "database creation process succeeded but file does not exist"
           55  +    fi
           56  +    rm ${TESTDB}
           57  +}
           58  +
           59  +test_create_large_db () {
           60  +    "${ZDBC}" --num-buckets=1000000000000000000 \
           61  +        --mmap-size=1000000000000000000 ${TESTDB} || \
           62  +        fail $1 "large database creation failed"
           63  +    if [ -f ${TESTDB} ]; then
           64  +        pass $1 "large database creation succeeded"
           65  +    else
           66  +        fail $1 "large database creation succeeded but file does not exist"
           67  +    fi
           68  +    rm ${TESTDB}
           69  +    return $?
           70  +}
           71  +
           72  +create_test_db () {
           73  +    "${ZDBC}" ${TESTDB}
           74  +}
           75  +
           76  +remove_test_db () {
           77  +    rm ${TESTDB}
           78  +}
           79  +
           80  +test_store_records () {
           81  +    "${ZDBS}" ${TESTDB} <<EOF
           82  +foo|bar
           83  +baz|quux
           84  +blah|bleh
           85  +another|record
           86  +EOF
           87  +    [ $? ] || fail $1 "store records failed"
           88  +    pass $1 "store records succeeded"
           89  +    return $?
           90  +}
           91  +
           92  +test_store_records_with_alt_delim () {
           93  +    "${ZDBS}" -d'~' ${TESTDB} <<EOF
           94  +1~2
           95  +3~4
           96  +5~6
           97  +EOF
           98  +    [ $? ] || fail $1 "store records with alternate delimiter failed"
           99  +    pass $1 "store records with alternate delimiter succeeded"
          100  +    return $?
          101  +}
          102  +
          103  +test_fetch_records () {
          104  +    vals=`"${ZDBF}" ${TESTDB} <<EOF
          105  +foo
          106  +baz
          107  +EOF
          108  +` || fail $1 "fetch records failed"
          109  +    if [[ "$vals" != `printf "bar\nquux"` ]]; then
          110  +        fail $1 "fetch records returned the wrong results"
          111  +    else
          112  +        pass $1 "fetch records succeeded"
          113  +    fi
          114  +    return $?
          115  +}
          116  +
          117  +test_fetch_records_with_delim () {
          118  +    vals=`"${ZDBF}" -d'~' ${TESTDB} <<EOF
          119  +foo
          120  +baz
          121  +EOF
          122  +` || fail $1 "fetch records with a delimiter failed"
          123  +    if [[ "$vals" != `printf "foo~bar\nbaz~quux"` ]]; then
          124  +        fail $1 "fetch records with a delimiter returned the wrong results"
          125  +    else
          126  +        pass $1 "fetch records with delimiter succeeded"
          127  +    fi
          128  +    return $?
          129  +}
          130  +
          131  +test_fetch_all_records () {
          132  +    numrecs=`"${ZDBF}" -a ${TESTDB} | wc -l` || fail $1 "fetch all records failed"
          133  +    if [[ "$numrecs" != "7" ]]; then
          134  +        fail $1 "fetch all records returned the wrong results"
          135  +    else
          136  +        pass $1 "fetch all records succeeded"
          137  +    fi
          138  +    return $?
          139  +}
          140  +
          141  +test_remove_records () {
          142  +    "${ZDBR}" ${TESTDB} <<EOF
          143  +foo
          144  +baz
          145  +blah
          146  +another
          147  +1
          148  +3
          149  +5
          150  +EOF
          151  +    [ $? ] || fail $1 "remove records failed"
          152  +    if [[ "x`"${ZDBF}" -a ${TESTDB}`" != "x" ]]; then
          153  +        fail $1 "remove records - some records remain"
          154  +    else
          155  +        pass $1 "remove records succeeded"
          156  +    fi
          157  +    return $?
          158  +}
          159  +
          160  +run_tests () {
          161  +    test_create_db 1
          162  +    test_create_large_db 2
          163  +    create_test_db
          164  +    test_store_records 3
          165  +    test_store_records_with_alt_delim 4
          166  +    test_fetch_records 5
          167  +    test_fetch_records_with_delim 6
          168  +    test_fetch_all_records 7
          169  +    test_remove_records 8
          170  +    remove_test_db
          171  +}
          172  +
          173  +echo 1..8
          174  +run_tests