Basic support for functional/regression testing.

This commit is contained in:
Alexey Kopytov
2016-09-04 20:24:07 +03:00
parent 755a61b6cf
commit 6d5bba1fe6
7 changed files with 143 additions and 1 deletions

2
.gitignore vendored
View File

@ -59,3 +59,5 @@ GTAGS
/sysbench/drivers/attachsql/.deps/
/config/test-driver
*.DS_Store
/tests/*.log
/tests/*.trs

View File

@ -17,6 +17,9 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = doc sysbench
SUBDIRS = doc sysbench tests
EXTRA_DIST = autogen.sh README.md README-WIN.txt ChangeLog
test:
cd tests && $(MAKE) test

View File

@ -461,5 +461,6 @@ sysbench/tests/db/Makefile
sysbench/scripting/Makefile
sysbench/scripting/lua/Makefile
sysbench/scripting/lua/src/Makefile
tests/Makefile
])
AC_OUTPUT

1
tests/1st.t Normal file
View File

@ -0,0 +1 @@
$ sysbench help >/dev/null 2>&1

55
tests/Makefile.am Normal file
View File

@ -0,0 +1,55 @@
# Copyright (C) 2016 Alexey Kopytov <akopytov@gmail.com>
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
TESTS = test_run.sh
test_SCRIPTS = test_run.sh
EXTRA_DIST = $(test_SCRIPTS) \
README.org
testroot = $(datadir)
testdir = $(testroot)/sysbench/tests
test_dirs= .
# Used by dist-hook and install-data-local to copy all
# test files into either dist or install directory
install_test_files:
@if test -z "$(INSTALL_TO_DIR)"; then \
echo "Set INSTALL_TO_DIR!" && exit 1; \
fi
@for dir in $(test_dirs); do \
from_dir="$(srcdir)/$$dir"; \
to_dir="$(INSTALL_TO_DIR)/$$dir"; \
$(mkinstalldirs) "$$to_dir"; \
for f in `(cd $$from_dir && ls *.t)`; do \
if test -f "$$from_dir/$$f"; then \
$(INSTALL_DATA) "$$from_dir/$$f" "$$to_dir/$$f" ; \
fi; \
done \
done
dist-hook:
$(MAKE) INSTALL_TO_DIR="$(distdir)" install_test_files
install-data-local:
$(MAKE) INSTALL_TO_DIR="$(DESTDIR)$(testdir)" install_test_files
uninstall-local:
rm -f -r $(DESTDIR)$(testdir)
test:
./test_run.sh

25
tests/README.org Normal file
View File

@ -0,0 +1,25 @@
* sysbench Test Suite
sysbench uses the [[https://bitheap.org/cram/][Cram]] framework for functional and regression
testing. If your system has Python 2.7.9 or later, or Python 3.4 or
later, installing Cram is as simple as executing =pip install cram=.
If you use an older Python version, you may need to [[https://pip.pypa.io/en/latest/installing/][install pip]] first:
#+BEGIN_EXAMPLE
curl https://bootstrap.pypa.io/get-pip.py | python
#+END_EXAMPLE
To run the sysbench test suite, invoke the =test_run.sh= script in the
=tests= directory like this:
#+BEGIN_EXAMPLE
./test_run.sh [test_name]...
#+END_EXAMPLE
Each =test_name= argument is name of a test case file. Functional and
regression tests are located in the same directory in files with the
=.t= suffix.
If no tests are named on the =test_run.sh= command line, it will execute
all files with the =.t= suffix in the current directory.

55
tests/test_run.sh Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Copyright (C) 2016 Alexey Kopytov <akopytov@gmail.com>
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
set -eu
if [ -x "$PWD/../sysbench/sysbench" ]
then
# Invoked from a source directory?
export PATH=$PWD/../sysbench:$PATH
elif [ -x "$PWD/../bin" ]
then
# Invoked from a standalone install root directory?
export PATH=$PWD/../bin:$PATH
elif [ -x "$PWD/../../../bin/sysbench" ]
then
# Invoked from a system-wide install (e.g. /usr/local/share/sysbench/tests)?
export PATH=$PWD/../../../bin:$PATH
fi
if ! which sysbench >/dev/null 2>&1
then
echo "Cannot find sysbench in PATH=$PATH"
exit 1
fi
if [ $# -lt 1 ]
then
# Automake defines $srcdir where test datafiles are located on 'make check'
if [ -z ${srcdir+x} ]
then
testroot="."
else
testroot="$srcdir"
fi
tests="${testroot}/*.t"
else
tests="$*"
fi
cram --shell=/bin/bash --verbose $tests