mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Add some examples for using libmysqld, including a hack for running the
mysql test suite. A few minor libmysqld fixes. Add mysql_server_init() and _end() to mysql.cc and mysqltest.c, so they can be linked against libmysqlclient or libmysqld. sql/mysqld.cc: have unireg_end() exit(), instead of pthread_exit() if inside the EMBEDDED_LIBRARY. This is a hack which hopefully won't be needed. But without it, the program hangs at end. client/mysql.cc: Don't call mysql_ssl_clear() unless HAVE_OPENSSL. client/mysqltest.c: Add mysql_server_init() and _end(). acinclude.m4: change .. to $(top_builddir) in innodb_libs Makefile.am: Add libmysqld/examples to link_sources target configure.in: output libmysqld/examples/Makefile Also, change .. to $(top_builddir) in readline_link BitKeeper/etc/ignore: added linked_libmysqldex_sources mysql-test/mysql-test-run.sh: use latin1, not latin1_de, in tests libmysqld/libmysqld.c: Add replication functions.
This commit is contained in:
33
libmysqld/examples/Makefile.am
Normal file
33
libmysqld/examples/Makefile.am
Normal file
@ -0,0 +1,33 @@
|
||||
bin_PROGRAMS = mysqltest mysql
|
||||
client_sources = $(mysqltest_SOURCES) $(mysql_SOURCES)
|
||||
link_sources:
|
||||
for f in $(client_sources); do \
|
||||
rm -f $(srcdir)/$$f; \
|
||||
@LN_CP_F@ $(srcdir)/../../client/$$f $(srcdir)/$$f; \
|
||||
done;
|
||||
|
||||
DEFS = -DEMBEDDED_SERVER
|
||||
INCLUDES = -I$(top_srcdir)/include $(openssl_includes) \
|
||||
-I$(srcdir) -I$(top_srcdir) -I..
|
||||
LIBS = @LIBS@
|
||||
LDADD = $(top_builddir)/libmysqld/libmysqld.la \
|
||||
$(top_builddir)/isam/libnisam.a \
|
||||
$(top_builddir)/myisam/libmyisam.a \
|
||||
$(top_builddir)/heap/libheap.a \
|
||||
$(top_builddir)/merge/libmerge.a \
|
||||
$(top_builddir)/myisammrg/libmyisammrg.a \
|
||||
@innodb_libs@ @bdb_libs@ \
|
||||
$(top_builddir)/mysys/libmysys.a \
|
||||
$(top_builddir)/strings/libmystrings.a \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/regex/libregex.a
|
||||
|
||||
mysqltest_DEPENDENCIES = ../libmysqld.la
|
||||
mysqltest_SOURCES = mysqltest.c
|
||||
|
||||
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc \
|
||||
my_readline.h sql_string.h completion_hash.h
|
||||
mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD)
|
||||
|
||||
clean:
|
||||
rm -f $(client_sources)
|
131
libmysqld/examples/test-run
Executable file
131
libmysqld/examples/test-run
Executable file
@ -0,0 +1,131 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This is slapped together as a quick way to run the tests and
|
||||
# is not meant for prime time. Please hack at it and submit
|
||||
# changes, though, so we can gradually turn it into something
|
||||
# that will run on all platforms (or incorporate it into the
|
||||
# standard mysql-test-run).
|
||||
|
||||
#test_data_dir=/tmp/mysql-data
|
||||
test_data_dir=../../mysql-test/var/master-data
|
||||
cd "$test_data_dir" || {
|
||||
echo "can't cd to $test_data_dir" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# All paths below must be relative to $test_data_dir
|
||||
#top_builddir=/home/tim/my/4
|
||||
top_builddir=../../..
|
||||
mysql_test_dir=$top_builddir/mysql-test
|
||||
examples=$top_builddir/libmysqld/examples
|
||||
mysqltest=$examples/mysqltest
|
||||
testdir=./test
|
||||
|
||||
gdb=0
|
||||
list=0
|
||||
run=
|
||||
tests=
|
||||
start=
|
||||
|
||||
cr="
|
||||
"
|
||||
er="\b\b\b\b\b\b\b\b"
|
||||
|
||||
usage () {
|
||||
cat <<EOF
|
||||
usage: $0 [-g|-h|-r] [test-name ...]
|
||||
|
||||
-g | --gdb run $mysqltest in gdb
|
||||
-h | --help show this help
|
||||
-l | --list ) list all available tests
|
||||
-r | --run automatically 'run' program in gdb
|
||||
-s t | --start=t start with test t (skip all tests before t)
|
||||
EOF
|
||||
}
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
arg=
|
||||
argset=0
|
||||
case "$1" in
|
||||
--?*=* ) arg=`echo "$1" | sed -e 's,^[^=][^=]*=,,'`; argset=1 ;;
|
||||
esac
|
||||
|
||||
case "$1" in
|
||||
-g | --gdb ) gdb=1; shift;;
|
||||
-h | --help | -\? ) usage; exit 0;;
|
||||
-l | --list ) list=1 ; shift ;;
|
||||
-r | --run ) run="${cr}run"; shift;;
|
||||
-s | --start=* )
|
||||
test $argset -eq 0 && { shift; arg="$1"; }
|
||||
start="$arg"
|
||||
shift
|
||||
;;
|
||||
-* ) usage; exit 1;;
|
||||
* ) tests="$tests $1"; shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -d "$mysql_test_dir/t" -a -d "$mysql_test_dir/r" -a \
|
||||
-f $mysqltest -a -d $testdir || {
|
||||
echo "bad setup (is '$testdir', from '$test_data_dir', missing?)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -n "$tests" ||
|
||||
tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \
|
||||
sed -e 's,^.*/,,' -e 's,.test$,,'`
|
||||
|
||||
echo "cleaning data directory '$test_data_dir'"
|
||||
rm -f $test_data_dir/ib_* $test_data_dir/ibdata* log.*
|
||||
echo "cleaning test directory '$testdir'"
|
||||
rm -f $testdir/*
|
||||
|
||||
rm -f test-gdbinit
|
||||
|
||||
TZ=GMT-3; export TZ
|
||||
|
||||
skip=1
|
||||
test -z "$start" && skip=0
|
||||
|
||||
for b in $tests
|
||||
do
|
||||
test $list -eq 1 && { echo " $b"; continue; }
|
||||
test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0
|
||||
test $skip -eq 1 && { echo "skipping '$b'"; continue; }
|
||||
|
||||
t="$mysql_test_dir/t/$b.test"
|
||||
r="$mysql_test_dir/r/$b.result"
|
||||
c="$mysql_test_dir/r/$b.reject"
|
||||
|
||||
# Only test if $t exists; there is no $r for some tests
|
||||
test -f $t || {
|
||||
echo "test '$b' doesn't exist" >&2
|
||||
continue
|
||||
}
|
||||
args="-v -S /tmp/mysql.sock -R $r -x $t test"
|
||||
echo "set args $args$run" > test-gdbinit
|
||||
#if false && test -n "$run"
|
||||
if test -n "$run" -o $gdb -eq 1
|
||||
then
|
||||
echo -e "$er>>> $b"
|
||||
else
|
||||
echo -e "$er>>> $b> \c"
|
||||
read junk
|
||||
fi
|
||||
if test $gdb -eq 1
|
||||
then
|
||||
if [ -x "$top_builddir/libtool" ]; then
|
||||
$top_builddir/libtool gdb -x test-gdbinit -q $mysqltest
|
||||
else
|
||||
gdb -x test-gdbinit -q $mysqltest
|
||||
fi
|
||||
res=$?
|
||||
rm -f test-gdbinit
|
||||
else
|
||||
$mysqltest $args
|
||||
res=$?
|
||||
fi
|
||||
|
||||
test $res -eq 0 || echo "!!! error: $res"
|
||||
done
|
Reference in New Issue
Block a user