From ec1359416be7cec52f94dc4f7d6fabb2d406d416 Mon Sep 17 00:00:00 2001
From: "sasha@mysql.sashanet.com" <>
Date: Thu, 7 Dec 2000 07:54:59 -0700
Subject: [PATCH] fixed up mysql-test - will not push this yet, as more clean
 up/testing is to follow

---
 .bzrignore                                    |   2 +
 BitKeeper/etc/gone                            |   2 +
 Makefile.am                                   |   2 +-
 configure.in                                  |   1 +
 libmysql/Makefile.am                          |   2 +-
 libmysql/Makefile.shared                      |   2 +-
 mysql-test/Makefile.am                        |   4 +
 mysql-test/include/master-slave.inc           |  11 ++
 .../mysql-test_install_db => install_test_db} |  53 ++++----
 mysql-test/mysql-test-run                     | 123 ++++++++++++++----
 mysql-test/r/{3.23 => }/alt000001.result      |   0
 mysql-test/r/{3.23 => }/ins000001.result      |   0
 mysql-test/r/{3.23 => }/rpl000001.a.result    |   0
 mysql-test/r/{3.23 => }/rpl000001.b.result    |   0
 mysql-test/r/{3.23 => }/rpl000002.result      |   0
 mysql-test/r/{3.23 => }/rpl000003.result      |   0
 mysql-test/r/{3.23 => }/rpl000004.a.result    |   0
 mysql-test/r/{3.23 => }/rpl000004.b.result    |   0
 mysql-test/r/{3.23 => }/rpl000005.result      |   0
 mysql-test/r/{3.23 => }/rpl000006.result      |   0
 mysql-test/r/{3.23 => }/rpl000007.result      |   0
 mysql-test/r/{3.23 => }/rpl000008.result      |   0
 mysql-test/r/{3.23 => }/rpl000009.result      |   0
 mysql-test/r/{3.23 => }/rpl000010.result      |   0
 mysql-test/r/{3.23 => }/rpl000011.result      |   0
 mysql-test/r/{3.23 => }/rpl000012.result      |   0
 .../r/{3.23 => }/rpl000012.status.result      |   0
 mysql-test/r/{3.23 => }/rpl000013.result      |   0
 .../r/{3.23 => }/rpl000013.status.result      |   0
 mysql-test/r/{3.23 => }/sel000001.result      |   0
 mysql-test/r/{3.23 => }/sel000002.result      |   0
 mysql-test/r/{3.23 => }/sel000003.result      |   0
 mysql-test/r/{3.23 => }/sel000004.result      |   0
 mysql-test/r/{3.23 => }/sel000005.result      |   0
 mysql-test/r/{3.23 => }/sel000006.result      |   0
 mysql-test/r/{3.23 => }/sel000007.result      |   0
 mysql-test/r/{3.23 => }/sel000008.result      |   0
 mysql-test/r/{3.23 => }/sel000009.result      |   0
 mysql-test/r/{3.23 => }/sel000010.result      |   0
 mysql-test/r/{3.23 => }/sel000011.result      |   0
 mysql-test/r/{3.23 => }/sel000012.result      |   0
 mysql-test/r/{3.23 => }/sel000013.result      |   0
 mysql-test/r/{3.23 => }/sel000014.result      |   0
 mysql-test/r/{3.23 => }/sel000015.result      |   0
 mysql-test/r/{3.23 => }/sel000016.result      |   0
 mysql-test/r/{3.23 => }/sel000017.result      |   0
 mysql-test/r/{3.23 => }/sel000018.result      |   0
 mysql-test/r/{3.23 => }/sel000019.result      |   0
 mysql-test/r/{3.23 => }/sel000020.result      |   0
 mysql-test/r/{3.23 => }/sel000021.result      |   0
 mysql-test/r/{3.23 => }/sel000022.result      |   0
 mysql-test/r/{3.23 => }/sel000023.result      |   0
 mysql-test/r/{3.23 => }/sel000024.result      |   0
 mysql-test/r/{3.23 => }/sel000025.result      |   0
 mysql-test/r/{3.23 => }/sel000026.result      |   0
 mysql-test/r/{3.23 => }/sel000027.result      |   0
 mysql-test/r/{3.23 => }/sel000028.result      |   0
 mysql-test/r/{3.23 => }/sel000029.result      |   0
 mysql-test/r/{3.23 => }/sel000030.result      |   0
 mysql-test/r/{3.23 => }/sel000100.result      |   0
 mysql-test/r/{3.23 => }/shw000001.result      |   0
 mysql-test/std_data/{words => words.dat}      |   0
 mysql-test/t/{3.23 => }/README                |   0
 mysql-test/t/{3.23 => }/alt000001.test        |   2 +-
 mysql-test/t/{3.23 => }/err000001.test        |   0
 mysql-test/t/{3.23 => }/ins000001.test        |   2 +-
 mysql-test/t/{3.23 => }/rpl000001.test        |   8 +-
 mysql-test/t/{3.23 => }/rpl000002.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000003.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000004.test        |  10 +-
 mysql-test/t/{3.23 => }/rpl000005.test        |   6 +-
 mysql-test/t/{3.23 => }/rpl000006.test        |   6 +-
 mysql-test/t/{3.23 => }/rpl000007-slave.opt   |   0
 mysql-test/t/{3.23 => }/rpl000007.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000008-slave.opt   |   0
 mysql-test/t/{3.23 => }/rpl000008.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000009-slave.opt   |   0
 mysql-test/t/{3.23 => }/rpl000009.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000010-slave.opt   |   0
 mysql-test/t/{3.23 => }/rpl000010.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000011.test        |   4 +-
 mysql-test/t/{3.23 => }/rpl000012.test        |   6 +-
 mysql-test/t/{3.23 => }/rpl000013-slave.opt   |   0
 mysql-test/t/{3.23 => }/rpl000013.test        |   6 +-
 mysql-test/t/{3.23 => }/sel000001.test        |   2 +-
 mysql-test/t/{3.23 => }/sel000002.test        |   2 +-
 mysql-test/t/{3.23 => }/sel000003.test        |   2 +-
 mysql-test/t/{3.23 => }/sel000004.test        |   2 +-
 mysql-test/t/{3.23 => }/sel000005.test        |   2 +-
 mysql-test/t/{3.23 => }/sel000100.test        |   2 +-
 mysql-test/t/{3.23 => }/shw000001.test        |   2 +-
 scripts/make_binary_distribution.sh           |  44 ++++++-
 92 files changed, 229 insertions(+), 105 deletions(-)
 create mode 100644 mysql-test/Makefile.am
 create mode 100644 mysql-test/include/master-slave.inc
 rename mysql-test/{mybin/mysql-test_install_db => install_test_db} (91%)
 rename mysql-test/r/{3.23 => }/alt000001.result (100%)
 rename mysql-test/r/{3.23 => }/ins000001.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000001.a.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000001.b.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000002.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000003.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000004.a.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000004.b.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000005.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000006.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000007.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000008.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000009.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000010.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000011.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000012.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000012.status.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000013.result (100%)
 rename mysql-test/r/{3.23 => }/rpl000013.status.result (100%)
 rename mysql-test/r/{3.23 => }/sel000001.result (100%)
 rename mysql-test/r/{3.23 => }/sel000002.result (100%)
 rename mysql-test/r/{3.23 => }/sel000003.result (100%)
 rename mysql-test/r/{3.23 => }/sel000004.result (100%)
 rename mysql-test/r/{3.23 => }/sel000005.result (100%)
 rename mysql-test/r/{3.23 => }/sel000006.result (100%)
 rename mysql-test/r/{3.23 => }/sel000007.result (100%)
 rename mysql-test/r/{3.23 => }/sel000008.result (100%)
 rename mysql-test/r/{3.23 => }/sel000009.result (100%)
 rename mysql-test/r/{3.23 => }/sel000010.result (100%)
 rename mysql-test/r/{3.23 => }/sel000011.result (100%)
 rename mysql-test/r/{3.23 => }/sel000012.result (100%)
 rename mysql-test/r/{3.23 => }/sel000013.result (100%)
 rename mysql-test/r/{3.23 => }/sel000014.result (100%)
 rename mysql-test/r/{3.23 => }/sel000015.result (100%)
 rename mysql-test/r/{3.23 => }/sel000016.result (100%)
 rename mysql-test/r/{3.23 => }/sel000017.result (100%)
 rename mysql-test/r/{3.23 => }/sel000018.result (100%)
 rename mysql-test/r/{3.23 => }/sel000019.result (100%)
 rename mysql-test/r/{3.23 => }/sel000020.result (100%)
 rename mysql-test/r/{3.23 => }/sel000021.result (100%)
 rename mysql-test/r/{3.23 => }/sel000022.result (100%)
 rename mysql-test/r/{3.23 => }/sel000023.result (100%)
 rename mysql-test/r/{3.23 => }/sel000024.result (100%)
 rename mysql-test/r/{3.23 => }/sel000025.result (100%)
 rename mysql-test/r/{3.23 => }/sel000026.result (100%)
 rename mysql-test/r/{3.23 => }/sel000027.result (100%)
 rename mysql-test/r/{3.23 => }/sel000028.result (100%)
 rename mysql-test/r/{3.23 => }/sel000029.result (100%)
 rename mysql-test/r/{3.23 => }/sel000030.result (100%)
 rename mysql-test/r/{3.23 => }/sel000100.result (100%)
 rename mysql-test/r/{3.23 => }/shw000001.result (100%)
 rename mysql-test/std_data/{words => words.dat} (100%)
 rename mysql-test/t/{3.23 => }/README (100%)
 rename mysql-test/t/{3.23 => }/alt000001.test (74%)
 rename mysql-test/t/{3.23 => }/err000001.test (100%)
 rename mysql-test/t/{3.23 => }/ins000001.test (90%)
 rename mysql-test/t/{3.23 => }/rpl000001.test (52%)
 rename mysql-test/t/{3.23 => }/rpl000002.test (72%)
 rename mysql-test/t/{3.23 => }/rpl000003.test (59%)
 rename mysql-test/t/{3.23 => }/rpl000004.test (58%)
 rename mysql-test/t/{3.23 => }/rpl000005.test (71%)
 rename mysql-test/t/{3.23 => }/rpl000006.test (61%)
 rename mysql-test/t/{3.23 => }/rpl000007-slave.opt (100%)
 rename mysql-test/t/{3.23 => }/rpl000007.test (81%)
 rename mysql-test/t/{3.23 => }/rpl000008-slave.opt (100%)
 rename mysql-test/t/{3.23 => }/rpl000008.test (82%)
 rename mysql-test/t/{3.23 => }/rpl000009-slave.opt (100%)
 rename mysql-test/t/{3.23 => }/rpl000009.test (83%)
 rename mysql-test/t/{3.23 => }/rpl000010-slave.opt (100%)
 rename mysql-test/t/{3.23 => }/rpl000010.test (81%)
 rename mysql-test/t/{3.23 => }/rpl000011.test (79%)
 rename mysql-test/t/{3.23 => }/rpl000012.test (71%)
 rename mysql-test/t/{3.23 => }/rpl000013-slave.opt (100%)
 rename mysql-test/t/{3.23 => }/rpl000013.test (74%)
 rename mysql-test/t/{3.23 => }/sel000001.test (82%)
 rename mysql-test/t/{3.23 => }/sel000002.test (83%)
 rename mysql-test/t/{3.23 => }/sel000003.test (83%)
 rename mysql-test/t/{3.23 => }/sel000004.test (81%)
 rename mysql-test/t/{3.23 => }/sel000005.test (80%)
 rename mysql-test/t/{3.23 => }/sel000100.test (94%)
 rename mysql-test/t/{3.23 => }/shw000001.test (78%)

diff --git a/.bzrignore b/.bzrignore
index 682518d38c..ed9c7b312a 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -401,3 +401,5 @@ mysql-test/var/lib/test/test2.MYI
 mysql-test/var/run/mysqld.pid
 mysql-test/var/tmp/mysql.sock
 mysql-test/var/lib/mysql-bin.008
+libmysql_r/hash.c
+scripts/mysql-3.23.29-gamma-pc-linux-gnu-i686.tar.gz
diff --git a/BitKeeper/etc/gone b/BitKeeper/etc/gone
index 355f5c6b06..18db75b7d5 100644
--- a/BitKeeper/etc/gone
+++ b/BitKeeper/etc/gone
@@ -3,3 +3,5 @@ mwagner@evoq.home.mwagner.org|mysql-test/var/log/README|20001009213643|16203|df5
 mwagner@evoq.home.mwagner.org|mysql-test/var/run/README|20001009213643|17062|acb305e4c2ed5990
 mwagner@evoq.home.mwagner.org|mysql-test/var/tmp/README|20001009213643|17904|b32d866bfd50e72e
 mwagner@evoq.home.mwagner.org|mysql-test/share/README|20001009213643|10987|6cd25db633f30de5
+mwagner@evoq.home.mwagner.org|mysql-test/r/3.23/README|20001009213643|10190|f9fd36f3c3711305
+sasha@mysql.sashanet.com|mysql-test/t/include/master-slave.inc|20001118030458|01636|556fd038c3a3d54
diff --git a/Makefile.am b/Makefile.am
index cc8a387ca4..d5924439e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,7 @@ EXTRA_DIST =		INSTALL-SOURCE README \
 SUBDIRS =		include @docs_dirs@ @readline_dir@ \
 			@thread_dirs@ @sql_client_dirs@ \
 			@sql_server_dirs@ scripts tests man \
-			@bench_dirs@ support-files
+			@bench_dirs@ support-files mysql-test
 
 # Relink after clean
 CLEANFILES =		linked_client_sources linked_server_sources linked_libmysql_sources linked_libmysql_r_sources linked_include_sources
diff --git a/configure.in b/configure.in
index 1df599c373..23fdf2cc8e 100644
--- a/configure.in
+++ b/configure.in
@@ -1887,6 +1887,7 @@ AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile \
  merge/Makefile dbug/Makefile scripts/Makefile \
  include/Makefile sql-bench/Makefile \
  tests/Makefile Docs/Makefile support-files/Makefile \
+ mysql-test/Makefile \
  include/mysql_version.h
  , , [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])
 
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index 758af52fe5..7df01aa4e5 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -65,7 +65,7 @@ nh =		global.h config-win32.h dbug.h errmsg.h global.h \
 		m_ctype.h m_string.h \
 		my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \
 		mysql.h mysql_com.h mysql_version.h mysqld_error.h mysys_err.h \
-		my_pthread.h thr_alarm.h violite.h
+		my_pthread.h thr_alarm.h violite.h hash.h
 # Get a list of the needed objects  
 lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects)
 
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 5263baa1e8..240a520aa1 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -55,7 +55,7 @@ mysysobjects1 =		my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
 			mf_loadpath.lo my_pthread.lo my_thr_init.lo \
 			thr_mutex.lo mulalloc.lo string.lo default.lo \
 			my_compress.lo array.lo my_once.lo list.lo my_net.lo \
-                        charset.lo
+                        charset.lo hash.lo
 # Not needed in the minimum library
 mysysobjects2 =		getopt.lo getopt1.lo getvar.lo my_lib.lo
 mysysobjects =		$(mysysobjects1) $(mysysobjects2)
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
new file mode 100644
index 0000000000..3d114e9dd2
--- /dev/null
+++ b/mysql-test/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST=README README.gcov mysql-test-run t/*.test t/*.opt r/*.result \
+mybin/mysql-test_install_db mybin/start-mysqld mybin/stop-mysqld \
+mybin/translate-tests
+
diff --git a/mysql-test/include/master-slave.inc b/mysql-test/include/master-slave.inc
new file mode 100644
index 0000000000..137749912a
--- /dev/null
+++ b/mysql-test/include/master-slave.inc
@@ -0,0 +1,11 @@
+connect (master,localhost,root,,test,0,var/tmp/mysql.sock);
+connect (master1,localhost,root,,test,0,var/tmp/mysql.sock);
+connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock);
+connect (slave1,localhost,root,,test,0,var/tmp/mysql-slave.sock);
+connection slave;
+!slave stop;
+connection master;
+reset master;
+connection slave;
+reset slave;
+!slave start;
diff --git a/mysql-test/mybin/mysql-test_install_db b/mysql-test/install_test_db
similarity index 91%
rename from mysql-test/mybin/mysql-test_install_db
rename to mysql-test/install_test_db
index c5e6c43cc7..be037b0653 100755
--- a/mysql-test/mybin/mysql-test_install_db
+++ b/mysql-test/install_test_db
@@ -5,26 +5,36 @@
 # This scripts creates the privilege tables db, host, user, tables_priv,
 # columns_priv in the mysql database, as well as the func table.
 
+if [ x$1 = x"-bin" ]; then
+ shift 1
+ execdir=../bin
+ bindir=../bin
+ BINARY_DIST=1
+ fix_bin=mysql-test
+else
+ execdir=../sql
+ bindir=../client
+ fix_bin=.
+fi
 
 if [ x$1 = x"-slave" ] 
 then
- shift $#
- ldata=var/slave-data
+ shift 1
+ data=var/slave-data
+ ldata=$fix_bin/var/slave-data
  logdir=var/log
- mdata=$ldata/mysql
- execdir=../sql
- bindir=../client
 else
- ldata=var/lib
+ data=var/lib
+ ldata=$fix_bin/var/lib
  logdir=var/log
- mdata=$ldata/mysql
- execdir=../sql
- bindir=../client
 fi
 
+mdata=$data/mysql
+
+
 if test ! -x $execdir/mysqld
 then
-  echo "I can't find no stinking mysqld!"
+  echo "mysqld is missing - looked in $execdir"
   exit 1
 fi
 
@@ -36,25 +46,18 @@ resolved=127.0.0.1
 
 
 # Create database directories mysql & test
-if test ! -d $ldata; then (mkdir -p $ldata || exit 1) && \
- (chmod 700  $ldata || exit 1) ; fi
-if test ! -d $ldata/mysql;
-then
- mkdir -p $ldata/mysql || exit 1;
- chmod 700 $ldata/mysql || exit 1 ; fi
-if test ! -d $ldata/test;
-then
- mkdir -p $ldata/test || exit 1;
- chmod 700 $ldata/test || exit 1 ;
- fi
-if test -w / -a ! -z "$user"; then
-  chown $user $ldata $ldata/mysql $ldata/test || exit 1;
-fi
+if [ -d $data ] ; then rm -rf $data ; fi
+mkdir -p $data $data/mysql $data/test 
 
 #for error messages
+if [ x$BINARY_DIST = x1 ] ; then
+basedir=..
+else
+basedir=.
 rm -rf share
 mkdir  share
 ln -sf ../../sql/share share/mysql 
+fi
 
 #create the directory for logs
 mkdir -p $logdir
@@ -192,7 +195,7 @@ then
 fi
 
 if $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \
-    --basedir=. --datadir=$ldata  << END_OF_DATA
+    --basedir=$basedir --datadir=$ldata  << END_OF_DATA
 use mysql;
 $c_d
 $i_d
diff --git a/mysql-test/mysql-test-run b/mysql-test/mysql-test-run
index 740f10f1ca..d2d99724aa 100755
--- a/mysql-test/mysql-test-run
+++ b/mysql-test/mysql-test-run
@@ -1,4 +1,6 @@
 #! /bin/sh
+# mysql-test-run - originally written by Matt Wagner <matt@mysql.com>
+# modified by Sasha Pachev <sasha@mysql.com>
 
 #++
 # Access Definitions
@@ -7,17 +9,42 @@ DB=test
 DBUSER=test
 DBPASSWD=
 
+# Are we on source or binary distribution?
+
+if [ $0 = scripts/mysql-test-run ] ;
+then
+ BINARY_DIST=1
+ cd mysql-test
+else
+ if [ -d mysql-test ] ; then
+  cd mysql-test
+ fi
+  
+ if [ -f ./mysql-test-run ] && [ -d ../sql ] ; then
+ SOURCE_DIST=1
+ else
+  echo "If you are using binary distirubution, run me from install root as \
+   scripts/mysql-test-run. On source distribution run me from source root as \
+   mysql-test/mysql-test-run or from mysql-test as ./mysql-test-run"
+  exit 1  
+ fi
+ 
+fi
+  
+
 
 #++
 # Misc. Definitions
 #--
+
+#BASEDIR is always one above mysql-test directory 
 CWD=`pwd`
 cd ..
 BASEDIR=`pwd`
 cd $CWD
-MYBIN="$CWD/mybin"
-TESTVER=3.23
-TESTDIR="$CWD/t/$TESTVER"
+MYSQL_TEST_DIR=$BASEDIR/mysql-test
+  
+TESTDIR="$MYSQL_TEST_DIR/t/"
 TESTSUFFIX=test
 TOT_PASS=0
 TOT_FAIL=0
@@ -25,8 +52,8 @@ TOT_TEST=0
 USERT=0
 SYST=0
 REALT=0
-MY_TMP_DIR=$CWD/var/tmp
-TIMEFILE="$CWD/var/tmp/mysqltest-time"
+MY_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
+TIMEFILE="$MYSQL_TEST_DIR/var/tmp/mysqltest-time"
 DASHBLANK="----	----	-------"
 MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
  myisammrg heap sql"
@@ -53,18 +80,25 @@ done
 #--
 MYRUN_DIR=var/run
 MASTER_MYPORT=9306
-MASTER_MYDDIR="$CWD/var/lib"
-MASTER_MYSOCK="$CWD/var/tmp/mysql.sock"
-MASTER_MYPID="$CWD/var/run/mysqld.pid"
-MASTER_MYLOG="$CWD/var/log/mysqld.log"
-MASTER_MYERR="$CWD/var/log/mysqld.err"
+MASTER_MYDDIR="$MYSQL_TEST_DIR/var/lib"
+MASTER_MYSOCK="$MYSQL_TEST_DIR/var/tmp/mysql.sock"
+MASTER_MYPID="$MYSQL_TEST_DIR/var/run/mysqld.pid"
+MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
+MASTER_MYERR="$MYSQL_TEST_DIR/var/log/mysqld.err"
+
 
 SLAVE_MYPORT=9307
-SLAVE_MYDDIR="$CWD/var/slave-data"
-SLAVE_MYSOCK="$CWD/var/tmp/mysql-slave.sock"
-SLAVE_MYPID="$CWD/var/run/mysqld-slave.pid"
-SLAVE_MYLOG="$CWD/var/log/mysqld-slave.log"
-SLAVE_MYERR="$CWD/var/log/mysqld-slave.err"
+SLAVE_MYDDIR="$MYSQL_TEST_DIR/var/slave-data"
+SLAVE_MYSOCK="$MYSQL_TEST_DIR/var/tmp/mysql-slave.sock"
+SLAVE_MYPID="$MYSQL_TEST_DIR/var/run/mysqld-slave.pid"
+SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld-slave.log"
+SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
+
+if [ x$SOURCE_DIST = x1 ] ; then
+ MY_BASEDIR=$MYSQL_TEST_DIR
+else
+ MY_BASEDIR=$BASEDIR
+fi  
 
 #++
 # Program Definitions
@@ -81,22 +115,50 @@ RM=/bin/rm
 TIME=/usr/bin/time
 TR=/usr/bin/tr
 XARGS=`which xargs`
-MYSQLD="$BASEDIR/sql/mysqld"
-MYSQL_TEST="$BASEDIR/client/mysqltest"
-MYSQLADMIN="$BASEDIR/client/mysqladmin"
+
+# on source dist, we pick up freshly build executables
+# on binary, use what is installed
+if [ x$SOURCE_DIST = x1 ] ; then
+ MYSQLD="$BASEDIR/sql/mysqld"
+ MYSQL_TEST="$BASEDIR/client/mysqltest"
+ MYSQLADMIN="$BASEDIR/client/mysqladmin"
+ INSTALL_DB="./install_test_db"
+else
+ MYSQLD="$BASEDIR/bin/mysqld"
+ MYSQL_TEST="$BASEDIR/bin/mysqltest"
+ MYSQLADMIN="$BASEDIR/bin/mysqladmin"
+ INSTALL_DB="../scripts/install_test_db -bin"
+fi
+
+
+
 MYSQL_TEST="$MYSQL_TEST --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent"
-INSTALL_DB="$MYBIN/mysql-test_install_db"
 GDB_MASTER_INIT=/tmp/gdbinit.master
 GDB_SLAVE_INIT=/tmp/gdbinit.slave
 
+if [ "$1" = "-force" ] ; then
+ FORCE=1
+ shift 1
+fi
+
 if [ "$1" = "-gcov" ];
 then
+  if [ x$BINARY_DIST = x1 ] ; then
+   echo "Cannot do coverage test without the source - please us source dist"
+   exit 1
+  fi
   DO_GCOV=1
   shift 1
 fi  
 
 if [ "$1" = "-gdb" ];
 then
+# if the user really wanted to run binary dist in a debugger, he can
+# but we should warn him
+  if [ x$BINARY_DIST = x1 ] ; then
+   echo "Note: you will get more meaningful output on a source distribution \
+   compiled with debugging option when running tests with -gdb option"
+  fi
   DO_GDB=1
   shift 1
 fi  
@@ -147,7 +209,7 @@ echo_pass () {
 prompt_user ()
 {
  echo $1
- read
+ read unused
 }
 
 echo_fail () {
@@ -224,7 +286,7 @@ gcov_prepare () {
 	for f in *.h *.cc *.c; do
 	  cp $f $GCOV_SLAVE_SRC/$d
 	done
-	cd $CWD
+	cd $MYSQL_TEST_DIR
    done    
 }
 
@@ -239,12 +301,12 @@ gcov_collect () {
 	for f in *.h *.cc *.c; do
 	    $GCOV $f 2>>$GCOV_MASTER_ERR  >>$GCOV_MASTER_MSG
 	done
-	cd $CWD
+	cd $MYSQL_TEST_DIR
 	cd $GCOV_SLAVE_SRC/$d
 	for f in *.h *.cc *.c; do
 	    $GCOV $f 2>>$GCOV_SLAVE_ERR  >>$GCOV_SLAVE_MSG
 	done
-	cd $CWD
+	cd $MYSQL_TEST_DIR
     done
 
     $ECHO "gcov master info in $GCOV_MASTER_MSG, errors in $GCOV_MASTER_ERR"
@@ -257,7 +319,7 @@ start_master()
     #start master
     master_args="--no-defaults --log-bin \
     	    --server-id=1 \
-            --basedir=$CWD \
+            --basedir=$MY_BASEDIR \
 	    --port=$MASTER_MYPORT \
 	    --core-file \
             --datadir=$MASTER_MYDDIR \
@@ -286,7 +348,7 @@ start_slave()
 	    --master-host=127.0.0.1 \
 	    --master-port=$MASTER_MYPORT \
 	    --core-file \
-            --basedir=$CWD \
+            --basedir=$MY_BASEDIR \
             --datadir=$SLAVE_MYDDIR \
 	    --pid-file=$SLAVE_MYPID \
 	    --port=$SLAVE_MYPORT \
@@ -307,7 +369,7 @@ start_slave()
 mysql_start () {
     start_master
     start_slave
-    cd $CWD
+    cd $MYSQL_TEST_DIR
     return 1
 }
 
@@ -394,7 +456,7 @@ run_testcase ()
   fi  
  fi
 
- cd $CWD
+ cd $MYSQL_TEST_DIR
   
  if [ -f $tf ] ; then
     mytime=`$TIME -p $MYSQL_TEST < $tf 2> $TIMEFILE`
@@ -425,6 +487,13 @@ run_testcase ()
 	$CAT $TIMEFILE
 	$ECHO
 	$ECHO
+	if [ x$FORCE != x1 ] ; then
+	 $SETCOLOR_NORMAL
+	 echo "Aborting, if you want to continue, re-run with -force"
+	 mysql_stop
+	 exit 1
+	fi
+	 
 	$SETCOLOR_NORMAL && $ECHO -n "Restarting mysqld	$DASHBLANK"
 	mysql_restart
 	$SETCOLOR_SUCCESS && echo_ok
diff --git a/mysql-test/r/3.23/alt000001.result b/mysql-test/r/alt000001.result
similarity index 100%
rename from mysql-test/r/3.23/alt000001.result
rename to mysql-test/r/alt000001.result
diff --git a/mysql-test/r/3.23/ins000001.result b/mysql-test/r/ins000001.result
similarity index 100%
rename from mysql-test/r/3.23/ins000001.result
rename to mysql-test/r/ins000001.result
diff --git a/mysql-test/r/3.23/rpl000001.a.result b/mysql-test/r/rpl000001.a.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000001.a.result
rename to mysql-test/r/rpl000001.a.result
diff --git a/mysql-test/r/3.23/rpl000001.b.result b/mysql-test/r/rpl000001.b.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000001.b.result
rename to mysql-test/r/rpl000001.b.result
diff --git a/mysql-test/r/3.23/rpl000002.result b/mysql-test/r/rpl000002.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000002.result
rename to mysql-test/r/rpl000002.result
diff --git a/mysql-test/r/3.23/rpl000003.result b/mysql-test/r/rpl000003.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000003.result
rename to mysql-test/r/rpl000003.result
diff --git a/mysql-test/r/3.23/rpl000004.a.result b/mysql-test/r/rpl000004.a.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000004.a.result
rename to mysql-test/r/rpl000004.a.result
diff --git a/mysql-test/r/3.23/rpl000004.b.result b/mysql-test/r/rpl000004.b.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000004.b.result
rename to mysql-test/r/rpl000004.b.result
diff --git a/mysql-test/r/3.23/rpl000005.result b/mysql-test/r/rpl000005.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000005.result
rename to mysql-test/r/rpl000005.result
diff --git a/mysql-test/r/3.23/rpl000006.result b/mysql-test/r/rpl000006.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000006.result
rename to mysql-test/r/rpl000006.result
diff --git a/mysql-test/r/3.23/rpl000007.result b/mysql-test/r/rpl000007.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000007.result
rename to mysql-test/r/rpl000007.result
diff --git a/mysql-test/r/3.23/rpl000008.result b/mysql-test/r/rpl000008.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000008.result
rename to mysql-test/r/rpl000008.result
diff --git a/mysql-test/r/3.23/rpl000009.result b/mysql-test/r/rpl000009.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000009.result
rename to mysql-test/r/rpl000009.result
diff --git a/mysql-test/r/3.23/rpl000010.result b/mysql-test/r/rpl000010.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000010.result
rename to mysql-test/r/rpl000010.result
diff --git a/mysql-test/r/3.23/rpl000011.result b/mysql-test/r/rpl000011.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000011.result
rename to mysql-test/r/rpl000011.result
diff --git a/mysql-test/r/3.23/rpl000012.result b/mysql-test/r/rpl000012.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000012.result
rename to mysql-test/r/rpl000012.result
diff --git a/mysql-test/r/3.23/rpl000012.status.result b/mysql-test/r/rpl000012.status.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000012.status.result
rename to mysql-test/r/rpl000012.status.result
diff --git a/mysql-test/r/3.23/rpl000013.result b/mysql-test/r/rpl000013.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000013.result
rename to mysql-test/r/rpl000013.result
diff --git a/mysql-test/r/3.23/rpl000013.status.result b/mysql-test/r/rpl000013.status.result
similarity index 100%
rename from mysql-test/r/3.23/rpl000013.status.result
rename to mysql-test/r/rpl000013.status.result
diff --git a/mysql-test/r/3.23/sel000001.result b/mysql-test/r/sel000001.result
similarity index 100%
rename from mysql-test/r/3.23/sel000001.result
rename to mysql-test/r/sel000001.result
diff --git a/mysql-test/r/3.23/sel000002.result b/mysql-test/r/sel000002.result
similarity index 100%
rename from mysql-test/r/3.23/sel000002.result
rename to mysql-test/r/sel000002.result
diff --git a/mysql-test/r/3.23/sel000003.result b/mysql-test/r/sel000003.result
similarity index 100%
rename from mysql-test/r/3.23/sel000003.result
rename to mysql-test/r/sel000003.result
diff --git a/mysql-test/r/3.23/sel000004.result b/mysql-test/r/sel000004.result
similarity index 100%
rename from mysql-test/r/3.23/sel000004.result
rename to mysql-test/r/sel000004.result
diff --git a/mysql-test/r/3.23/sel000005.result b/mysql-test/r/sel000005.result
similarity index 100%
rename from mysql-test/r/3.23/sel000005.result
rename to mysql-test/r/sel000005.result
diff --git a/mysql-test/r/3.23/sel000006.result b/mysql-test/r/sel000006.result
similarity index 100%
rename from mysql-test/r/3.23/sel000006.result
rename to mysql-test/r/sel000006.result
diff --git a/mysql-test/r/3.23/sel000007.result b/mysql-test/r/sel000007.result
similarity index 100%
rename from mysql-test/r/3.23/sel000007.result
rename to mysql-test/r/sel000007.result
diff --git a/mysql-test/r/3.23/sel000008.result b/mysql-test/r/sel000008.result
similarity index 100%
rename from mysql-test/r/3.23/sel000008.result
rename to mysql-test/r/sel000008.result
diff --git a/mysql-test/r/3.23/sel000009.result b/mysql-test/r/sel000009.result
similarity index 100%
rename from mysql-test/r/3.23/sel000009.result
rename to mysql-test/r/sel000009.result
diff --git a/mysql-test/r/3.23/sel000010.result b/mysql-test/r/sel000010.result
similarity index 100%
rename from mysql-test/r/3.23/sel000010.result
rename to mysql-test/r/sel000010.result
diff --git a/mysql-test/r/3.23/sel000011.result b/mysql-test/r/sel000011.result
similarity index 100%
rename from mysql-test/r/3.23/sel000011.result
rename to mysql-test/r/sel000011.result
diff --git a/mysql-test/r/3.23/sel000012.result b/mysql-test/r/sel000012.result
similarity index 100%
rename from mysql-test/r/3.23/sel000012.result
rename to mysql-test/r/sel000012.result
diff --git a/mysql-test/r/3.23/sel000013.result b/mysql-test/r/sel000013.result
similarity index 100%
rename from mysql-test/r/3.23/sel000013.result
rename to mysql-test/r/sel000013.result
diff --git a/mysql-test/r/3.23/sel000014.result b/mysql-test/r/sel000014.result
similarity index 100%
rename from mysql-test/r/3.23/sel000014.result
rename to mysql-test/r/sel000014.result
diff --git a/mysql-test/r/3.23/sel000015.result b/mysql-test/r/sel000015.result
similarity index 100%
rename from mysql-test/r/3.23/sel000015.result
rename to mysql-test/r/sel000015.result
diff --git a/mysql-test/r/3.23/sel000016.result b/mysql-test/r/sel000016.result
similarity index 100%
rename from mysql-test/r/3.23/sel000016.result
rename to mysql-test/r/sel000016.result
diff --git a/mysql-test/r/3.23/sel000017.result b/mysql-test/r/sel000017.result
similarity index 100%
rename from mysql-test/r/3.23/sel000017.result
rename to mysql-test/r/sel000017.result
diff --git a/mysql-test/r/3.23/sel000018.result b/mysql-test/r/sel000018.result
similarity index 100%
rename from mysql-test/r/3.23/sel000018.result
rename to mysql-test/r/sel000018.result
diff --git a/mysql-test/r/3.23/sel000019.result b/mysql-test/r/sel000019.result
similarity index 100%
rename from mysql-test/r/3.23/sel000019.result
rename to mysql-test/r/sel000019.result
diff --git a/mysql-test/r/3.23/sel000020.result b/mysql-test/r/sel000020.result
similarity index 100%
rename from mysql-test/r/3.23/sel000020.result
rename to mysql-test/r/sel000020.result
diff --git a/mysql-test/r/3.23/sel000021.result b/mysql-test/r/sel000021.result
similarity index 100%
rename from mysql-test/r/3.23/sel000021.result
rename to mysql-test/r/sel000021.result
diff --git a/mysql-test/r/3.23/sel000022.result b/mysql-test/r/sel000022.result
similarity index 100%
rename from mysql-test/r/3.23/sel000022.result
rename to mysql-test/r/sel000022.result
diff --git a/mysql-test/r/3.23/sel000023.result b/mysql-test/r/sel000023.result
similarity index 100%
rename from mysql-test/r/3.23/sel000023.result
rename to mysql-test/r/sel000023.result
diff --git a/mysql-test/r/3.23/sel000024.result b/mysql-test/r/sel000024.result
similarity index 100%
rename from mysql-test/r/3.23/sel000024.result
rename to mysql-test/r/sel000024.result
diff --git a/mysql-test/r/3.23/sel000025.result b/mysql-test/r/sel000025.result
similarity index 100%
rename from mysql-test/r/3.23/sel000025.result
rename to mysql-test/r/sel000025.result
diff --git a/mysql-test/r/3.23/sel000026.result b/mysql-test/r/sel000026.result
similarity index 100%
rename from mysql-test/r/3.23/sel000026.result
rename to mysql-test/r/sel000026.result
diff --git a/mysql-test/r/3.23/sel000027.result b/mysql-test/r/sel000027.result
similarity index 100%
rename from mysql-test/r/3.23/sel000027.result
rename to mysql-test/r/sel000027.result
diff --git a/mysql-test/r/3.23/sel000028.result b/mysql-test/r/sel000028.result
similarity index 100%
rename from mysql-test/r/3.23/sel000028.result
rename to mysql-test/r/sel000028.result
diff --git a/mysql-test/r/3.23/sel000029.result b/mysql-test/r/sel000029.result
similarity index 100%
rename from mysql-test/r/3.23/sel000029.result
rename to mysql-test/r/sel000029.result
diff --git a/mysql-test/r/3.23/sel000030.result b/mysql-test/r/sel000030.result
similarity index 100%
rename from mysql-test/r/3.23/sel000030.result
rename to mysql-test/r/sel000030.result
diff --git a/mysql-test/r/3.23/sel000100.result b/mysql-test/r/sel000100.result
similarity index 100%
rename from mysql-test/r/3.23/sel000100.result
rename to mysql-test/r/sel000100.result
diff --git a/mysql-test/r/3.23/shw000001.result b/mysql-test/r/shw000001.result
similarity index 100%
rename from mysql-test/r/3.23/shw000001.result
rename to mysql-test/r/shw000001.result
diff --git a/mysql-test/std_data/words b/mysql-test/std_data/words.dat
similarity index 100%
rename from mysql-test/std_data/words
rename to mysql-test/std_data/words.dat
diff --git a/mysql-test/t/3.23/README b/mysql-test/t/README
similarity index 100%
rename from mysql-test/t/3.23/README
rename to mysql-test/t/README
diff --git a/mysql-test/t/3.23/alt000001.test b/mysql-test/t/alt000001.test
similarity index 74%
rename from mysql-test/t/3.23/alt000001.test
rename to mysql-test/t/alt000001.test
index c6c767b8d5..88defc5b03 100644
--- a/mysql-test/t/3.23/alt000001.test
+++ b/mysql-test/t/alt000001.test
@@ -3,4 +3,4 @@ drop table if exists x;
 create table x (n int);
 insert into x values(9),(3),(12),(10);
 alter table x order by n;
-@r/3.23/alt000001.result select * from x;
+@r/alt000001.result select * from x;
diff --git a/mysql-test/t/3.23/err000001.test b/mysql-test/t/err000001.test
similarity index 100%
rename from mysql-test/t/3.23/err000001.test
rename to mysql-test/t/err000001.test
diff --git a/mysql-test/t/3.23/ins000001.test b/mysql-test/t/ins000001.test
similarity index 90%
rename from mysql-test/t/3.23/ins000001.test
rename to mysql-test/t/ins000001.test
index 7fafd7d48f..1c40d1ffa8 100644
--- a/mysql-test/t/3.23/ins000001.test
+++ b/mysql-test/t/ins000001.test
@@ -8,4 +8,4 @@ insert into emails values ('sasha@mysql.com'),('monty@mysql.com'),
 create table domain(id int not null auto_increment primary key,
  domain varchar(50), unique(domain));
 insert into domain (domain) select distinct substring(email, locate('@', email)+1) from emails;
-@r/3.23/ins000001.result select * from domain;
+@r/ins000001.result select * from domain;
diff --git a/mysql-test/t/3.23/rpl000001.test b/mysql-test/t/rpl000001.test
similarity index 52%
rename from mysql-test/t/3.23/rpl000001.test
rename to mysql-test/t/rpl000001.test
index bd094cd639..5bf0e0dbab 100644
--- a/mysql-test/t/3.23/rpl000001.test
+++ b/mysql-test/t/rpl000001.test
@@ -1,15 +1,15 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 use test;
 drop table if exists words;
 create table words (word char(20) not null);
-load data infile '../../std_data/words' into table words;
+load data infile '../../std_data/words.dat' into table words;
 drop table if exists foo;
 create table foo(n int);
 insert into foo values(1),(2);
 connection slave;
 sleep 2;
 use test;
-@r/3.23/rpl000001.a.result select * from foo;
-@r/3.23/rpl000001.b.result select sum(length(word)) from words;
+@r/rpl000001.a.result select * from foo;
+@r/rpl000001.b.result select sum(length(word)) from words;
 
diff --git a/mysql-test/t/3.23/rpl000002.test b/mysql-test/t/rpl000002.test
similarity index 72%
rename from mysql-test/t/3.23/rpl000002.test
rename to mysql-test/t/rpl000002.test
index b411a0f42c..29741b5b6c 100644
--- a/mysql-test/t/3.23/rpl000002.test
+++ b/mysql-test/t/rpl000002.test
@@ -1,4 +1,4 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 use test;
 drop table if exists x;
@@ -8,4 +8,4 @@ insert into x values (NULL),(NULL),(NULL);
 connection slave;
 use test;
 sleep 0.5;
-@r/3.23/rpl000002.result select * from x;
+@r/rpl000002.result select * from x;
diff --git a/mysql-test/t/3.23/rpl000003.test b/mysql-test/t/rpl000003.test
similarity index 59%
rename from mysql-test/t/3.23/rpl000003.test
rename to mysql-test/t/rpl000003.test
index 8aa6eb09c4..d7e21a3590 100644
--- a/mysql-test/t/3.23/rpl000003.test
+++ b/mysql-test/t/rpl000003.test
@@ -1,4 +1,4 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 drop table if exists x;
 create table x(n int primary key);
@@ -6,4 +6,4 @@ create table x(n int primary key);
 insert into x values (3);
 connection slave;
 sleep 0.5;
-@r/3.23/rpl000003.result select * from x;                                     
+@r/rpl000003.result select * from x;                                     
diff --git a/mysql-test/t/3.23/rpl000004.test b/mysql-test/t/rpl000004.test
similarity index 58%
rename from mysql-test/t/3.23/rpl000004.test
rename to mysql-test/t/rpl000004.test
index 795bb0e32a..b7ab81a055 100644
--- a/mysql-test/t/3.23/rpl000004.test
+++ b/mysql-test/t/rpl000004.test
@@ -1,18 +1,18 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 use test;
 set SQL_LOG_BIN=0;
 drop table if exists words;
 create table words (word char(20) not null, index(word));
-load data infile '../../std_data/words' into table words;
+load data infile '../../std_data/words.dat' into table words;
 drop table if exists words1;
 create table words1 (word char(20) not null);
-load data infile '../../std_data/words' into table words1;
+load data infile '../../std_data/words.dat' into table words1;
 connection slave;
 use test;
 drop table if exists words;
 load table words from master;
 drop table if exists words1;
 load table words1 from master;
-@r/3.23/rpl000004.a.result check table words;
-@r/3.23/rpl000004.b.result select count(*) from words1;
+@r/rpl000004.a.result check table words;
+@r/rpl000004.b.result select count(*) from words1;
diff --git a/mysql-test/t/3.23/rpl000005.test b/mysql-test/t/rpl000005.test
similarity index 71%
rename from mysql-test/t/3.23/rpl000005.test
rename to mysql-test/t/rpl000005.test
index dac48849e2..944f701d76 100644
--- a/mysql-test/t/3.23/rpl000005.test
+++ b/mysql-test/t/rpl000005.test
@@ -1,4 +1,4 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 drop table if exists test;
 CREATE TABLE test (name varchar(64), age smallint(3));
@@ -6,7 +6,7 @@ INSERT INTO  test SET name='Andy', age=31;
 INSERT test SET name='Jacob', age=2;
 INSERT into test SET name='Caleb', age=1;
 ALTER TABLE test ADD id int(8) ZEROFILL AUTO_INCREMENT PRIMARY KEY;
-@r/3.23/rpl000005.result select * from test;
+@r/rpl000005.result select * from test;
 connection slave;
 sleep 0.5;
-@r/3.23/rpl000005.result select * from test;
+@r/rpl000005.result select * from test;
diff --git a/mysql-test/t/3.23/rpl000006.test b/mysql-test/t/rpl000006.test
similarity index 61%
rename from mysql-test/t/3.23/rpl000006.test
rename to mysql-test/t/rpl000006.test
index 8f85b3a795..56971cd049 100644
--- a/mysql-test/t/3.23/rpl000006.test
+++ b/mysql-test/t/rpl000006.test
@@ -1,12 +1,12 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 set SQL_LOG_BIN=0;
 set timestamp=200006;
 drop table if exists foo;
 create table foo(t timestamp not null,a char(1));
 insert into foo ( a) values ('F');
-@r/3.23/rpl000006.result select unix_timestamp(t) from foo;
+@r/rpl000006.result select unix_timestamp(t) from foo;
 connection slave;
 drop table if exists foo;
 load table foo from master;
-@r/3.23/rpl000006.result select unix_timestamp(t) from foo;
+@r/rpl000006.result select unix_timestamp(t) from foo;
diff --git a/mysql-test/t/3.23/rpl000007-slave.opt b/mysql-test/t/rpl000007-slave.opt
similarity index 100%
rename from mysql-test/t/3.23/rpl000007-slave.opt
rename to mysql-test/t/rpl000007-slave.opt
diff --git a/mysql-test/t/3.23/rpl000007.test b/mysql-test/t/rpl000007.test
similarity index 81%
rename from mysql-test/t/3.23/rpl000007.test
rename to mysql-test/t/rpl000007.test
index 5b9ef12bdd..2a3748868d 100644
--- a/mysql-test/t/3.23/rpl000007.test
+++ b/mysql-test/t/rpl000007.test
@@ -1,6 +1,6 @@
 #this one assumes we are ignoring updates on table foo, but doing
 #the ones on bar
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection slave;
 use test;
 drop table if exists foo;
@@ -16,4 +16,4 @@ create table bar (m int);
 insert into bar values(15);
 connection slave;
 sleep 1;
-@r/3.23/rpl000007.result select foo.n,bar.m from foo,bar;
+@r/rpl000007.result select foo.n,bar.m from foo,bar;
diff --git a/mysql-test/t/3.23/rpl000008-slave.opt b/mysql-test/t/rpl000008-slave.opt
similarity index 100%
rename from mysql-test/t/3.23/rpl000008-slave.opt
rename to mysql-test/t/rpl000008-slave.opt
diff --git a/mysql-test/t/3.23/rpl000008.test b/mysql-test/t/rpl000008.test
similarity index 82%
rename from mysql-test/t/3.23/rpl000008.test
rename to mysql-test/t/rpl000008.test
index 58819c2835..a50016ed9c 100644
--- a/mysql-test/t/3.23/rpl000008.test
+++ b/mysql-test/t/rpl000008.test
@@ -1,6 +1,6 @@
 #this one assumes we are ignoring updates on table foo, but doing
 #the ones on all other tables
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection slave;
 use test;
 drop table if exists foo;
@@ -19,4 +19,4 @@ create table choo (k int);
 insert into choo values(55);
 connection slave;
 sleep 1;
-@r/3.23/rpl000008.result select foo.n,bar.m,choo.k from foo,bar,choo;
+@r/rpl000008.result select foo.n,bar.m,choo.k from foo,bar,choo;
diff --git a/mysql-test/t/3.23/rpl000009-slave.opt b/mysql-test/t/rpl000009-slave.opt
similarity index 100%
rename from mysql-test/t/3.23/rpl000009-slave.opt
rename to mysql-test/t/rpl000009-slave.opt
diff --git a/mysql-test/t/3.23/rpl000009.test b/mysql-test/t/rpl000009.test
similarity index 83%
rename from mysql-test/t/3.23/rpl000009.test
rename to mysql-test/t/rpl000009.test
index ae491e1ab9..0a872bb366 100644
--- a/mysql-test/t/3.23/rpl000009.test
+++ b/mysql-test/t/rpl000009.test
@@ -1,6 +1,6 @@
 #this one assumes we are ignoring updates on tables in database foo, but doing
 #the ones in database bar
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 drop database if exists foo;
 create database foo;
@@ -20,4 +20,4 @@ create table bar.bar (m int);
 insert into bar.bar values(15);
 connection slave;
 sleep 1;
-@r/3.23/rpl000009.result select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
+@r/rpl000009.result select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
diff --git a/mysql-test/t/3.23/rpl000010-slave.opt b/mysql-test/t/rpl000010-slave.opt
similarity index 100%
rename from mysql-test/t/3.23/rpl000010-slave.opt
rename to mysql-test/t/rpl000010-slave.opt
diff --git a/mysql-test/t/3.23/rpl000010.test b/mysql-test/t/rpl000010.test
similarity index 81%
rename from mysql-test/t/3.23/rpl000010.test
rename to mysql-test/t/rpl000010.test
index 3bb55dc854..6b5ec69fb5 100644
--- a/mysql-test/t/3.23/rpl000010.test
+++ b/mysql-test/t/rpl000010.test
@@ -1,6 +1,6 @@
 #this tests the offset off by 22 mystery bug
 #must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection slave;
 drop table if exists foo;
 connection master;
@@ -10,4 +10,4 @@ insert into foo values(NULL);
 insert into foo values(2);
 connection slave;
 sleep 5;
-@r/3.23/rpl000010.result select n from foo;
+@r/rpl000010.result select n from foo;
diff --git a/mysql-test/t/3.23/rpl000011.test b/mysql-test/t/rpl000011.test
similarity index 79%
rename from mysql-test/t/3.23/rpl000011.test
rename to mysql-test/t/rpl000011.test
index a5759f52e0..f077613654 100644
--- a/mysql-test/t/3.23/rpl000011.test
+++ b/mysql-test/t/rpl000011.test
@@ -1,4 +1,4 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 use test;
 drop table if exists foo;
@@ -14,5 +14,5 @@ insert into foo values(2);
 connection slave;
 #let slave catch up
 sleep 1;
-@r/3.23/rpl000011.result select * from foo;
+@r/rpl000011.result select * from foo;
 
diff --git a/mysql-test/t/3.23/rpl000012.test b/mysql-test/t/rpl000012.test
similarity index 71%
rename from mysql-test/t/3.23/rpl000012.test
rename to mysql-test/t/rpl000012.test
index 205c78d604..55d6bd4d4f 100644
--- a/mysql-test/t/3.23/rpl000012.test
+++ b/mysql-test/t/rpl000012.test
@@ -1,4 +1,4 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 drop table if exists x;
 create table x(n int);
@@ -15,5 +15,5 @@ insert into x values(6);
 disconnect master1;
 connection slave;
 sleep 1;
-@r/3.23/rpl000012.result select * from x;
-@r/3.23/rpl000012.status.result show status like 'Slave_open_temp_tables';
+@r/rpl000012.result select * from x;
+@r/rpl000012.status.result show status like 'Slave_open_temp_tables';
diff --git a/mysql-test/t/3.23/rpl000013-slave.opt b/mysql-test/t/rpl000013-slave.opt
similarity index 100%
rename from mysql-test/t/3.23/rpl000013-slave.opt
rename to mysql-test/t/rpl000013-slave.opt
diff --git a/mysql-test/t/3.23/rpl000013.test b/mysql-test/t/rpl000013.test
similarity index 74%
rename from mysql-test/t/3.23/rpl000013.test
rename to mysql-test/t/rpl000013.test
index f54482f41e..ec015bbe35 100644
--- a/mysql-test/t/3.23/rpl000013.test
+++ b/mysql-test/t/rpl000013.test
@@ -1,4 +1,4 @@
-source t/include/master-slave.inc;
+source include/master-slave.inc;
 connection master;
 drop table if exists x;
 create table x(n int);
@@ -21,5 +21,5 @@ while ($1)
  sleep 0.2;
  dec $1;
 }
-@r/3.23/rpl000013.result select * from x;
-@r/3.23/rpl000013.status.result show status like 'Slave_open_temp_tables';
+@r/rpl000013.result select * from x;
+@r/rpl000013.status.result show status like 'Slave_open_temp_tables';
diff --git a/mysql-test/t/3.23/sel000001.test b/mysql-test/t/sel000001.test
similarity index 82%
rename from mysql-test/t/3.23/sel000001.test
rename to mysql-test/t/sel000001.test
index 233e986ad3..7f5fb30398 100644
--- a/mysql-test/t/3.23/sel000001.test
+++ b/mysql-test/t/sel000001.test
@@ -14,4 +14,4 @@
 DROP TABLE IF EXISTS t;
 CREATE TABLE t (s CHAR(20) PRIMARY KEY, id INT);
 INSERT INTO t VALUES ('cat', 1), ('mouse', 3), ('dog', 2), ('snake', 77);
-@r/3.23/sel000001.result SELECT s, id FROM t WHERE s = 'mouse';
+@r/sel000001.result SELECT s, id FROM t WHERE s = 'mouse';
diff --git a/mysql-test/t/3.23/sel000002.test b/mysql-test/t/sel000002.test
similarity index 83%
rename from mysql-test/t/3.23/sel000002.test
rename to mysql-test/t/sel000002.test
index 3a0178a05d..27c88b503d 100644
--- a/mysql-test/t/3.23/sel000002.test
+++ b/mysql-test/t/sel000002.test
@@ -13,4 +13,4 @@
 DROP TABLE IF EXISTS t;
 CREATE TABLE t (n INT);
 INSERT INTO t VALUES (1), (2), (3);
-@r/3.23/sel000002.result SELECT * FROM t;
+@r/sel000002.result SELECT * FROM t;
diff --git a/mysql-test/t/3.23/sel000003.test b/mysql-test/t/sel000003.test
similarity index 83%
rename from mysql-test/t/3.23/sel000003.test
rename to mysql-test/t/sel000003.test
index 883be4fb07..cef82ab259 100644
--- a/mysql-test/t/3.23/sel000003.test
+++ b/mysql-test/t/sel000003.test
@@ -14,4 +14,4 @@
 DROP TABLE IF EXISTS t;
 CREATE TABLE t (name CHAR(20) NOT NULL PRIMARY KEY, score SMALLINT NOT NULL, KEY(score));
 INSERT INTO t VALUES ('Sasha', 20), ('Matt', 20), ('Monty', 10), ('David', 10), ('Tim', 10), ('Jeremy', 10);
-@r/3.23/sel000003.result SELECT COUNT(*) as n, score FROM t GROUP BY score;
+@r/sel000003.result SELECT COUNT(*) as n, score FROM t GROUP BY score;
diff --git a/mysql-test/t/3.23/sel000004.test b/mysql-test/t/sel000004.test
similarity index 81%
rename from mysql-test/t/3.23/sel000004.test
rename to mysql-test/t/sel000004.test
index 6146ff641e..d7b59a9f99 100644
--- a/mysql-test/t/3.23/sel000004.test
+++ b/mysql-test/t/sel000004.test
@@ -16,6 +16,6 @@ val int(10) not null);
 insert into elt_ck1 values (1),(2),(4);
 insert into elt_ck2 values (1,1),(2,1),(3,1),(4,2);
 
-@r/3.23/sel000004.result select one.id, elt(two.val,'one','two') from elt_ck1 one, elt_ck2 two 
+@r/sel000004.result select one.id, elt(two.val,'one','two') from elt_ck1 one, elt_ck2 two 
 where two.id=one.id order by one.id;
 
diff --git a/mysql-test/t/3.23/sel000005.test b/mysql-test/t/sel000005.test
similarity index 80%
rename from mysql-test/t/3.23/sel000005.test
rename to mysql-test/t/sel000005.test
index 18541d5d69..d6dbb38165 100644
--- a/mysql-test/t/3.23/sel000005.test
+++ b/mysql-test/t/sel000005.test
@@ -16,6 +16,6 @@ val int(10) not null);
 insert into elt_ck1 values (1),(2),(4);
 insert into elt_ck2 values (1,1),(2,1),(3,1),(4,2);
 
-@r/3.23/sel000005.result select one.id, elt(two.val,'one','two') from elt_ck1 one, elt_ck2 two 
+@r/sel000005.result select one.id, elt(two.val,'one','two') from elt_ck1 one, elt_ck2 two 
 where two.id=one.id ;
 
diff --git a/mysql-test/t/3.23/sel000100.test b/mysql-test/t/sel000100.test
similarity index 94%
rename from mysql-test/t/3.23/sel000100.test
rename to mysql-test/t/sel000100.test
index cd3f700544..718e67de9e 100644
--- a/mysql-test/t/3.23/sel000100.test
+++ b/mysql-test/t/sel000100.test
@@ -21,7 +21,7 @@ CREATE TABLE test2 (
   KEY NAME (NAME)
 );
 
-@r/3.23/sel000100.result SELECT DISTINCT
+@r/sel000100.result SELECT DISTINCT
     test2.id AS key_link_id,
     test2.name AS link
 FROM test1
diff --git a/mysql-test/t/3.23/shw000001.test b/mysql-test/t/shw000001.test
similarity index 78%
rename from mysql-test/t/3.23/shw000001.test
rename to mysql-test/t/shw000001.test
index 0abb940d20..c92d710a49 100644
--- a/mysql-test/t/3.23/shw000001.test
+++ b/mysql-test/t/shw000001.test
@@ -4,4 +4,4 @@ create table test (
   test_set set( 'val1', 'val2', 'val3' ) not null default '',
   name char(20) default 'O''Brien'
   ) comment = 'it\'s a table' ;
-@r/3.23/shw000001.result show create table test ;
+@r/shw000001.result show create table test ;
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 7fc492439d..d687a875f7 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -12,21 +12,36 @@ SOURCE=`pwd`
 
 # Save temporary distribution here (must be full path) 
 TMP=/tmp
-if test $# -gt 0
+if test $# -gt 0 -a x$1 != x"-debug" 
 then
   TMP=$1
+  shift 1
 fi
 
+if test x$1 = x"-debug"
+then
+  DEBUG=1
+  shift 1
+fi  
+
+
 #make
 
 # This should really be integrated with automake and not duplicate the
 # installation list.
 
 BASE=$TMP/my_dist
+
+if [ -d $BASE ] ; then
+ rm -rf $BASE
+fi
+
 mkdir $BASE $BASE/bin $BASE/data $BASE/data/mysql $BASE/data/test \
  $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/share/mysql \
- $BASE/tests $BASE/scripts $BASE/sql-bench
-
+ $BASE/tests $BASE/scripts $BASE/sql-bench $BASE/mysql-test \
+ $BASE/mysql-test/t  $BASE/mysql-test/r \
+ $BASE/mysql-test/include $BASE/mysql-test/std_data
+ 
 chmod o-rwx $BASE/data $BASE/data/*
 
 for i in sql/ChangeLog COPYING COPYING.LIB README Docs/INSTALL-BINARY \
@@ -37,8 +52,9 @@ done
 
 for i in extra/comp_err extra/replace extra/perror extra/resolveip \
  extra/my_print_defaults isam/isamchk isam/pack_isam myisam/myisamchk myisam/myisampack sql/mysqld sql/mysqlbinlog \
- client/mysql sql/mysqld client/mysqlshow client/mysqladmin client/mysqldump client/mysqlimport \
- client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin client/.libs/mysqldump client/.libs/mysqlimport
+ client/mysql sql/mysqld client/mysqlshow client/mysqladmin client/mysqldump \
+ client/mysqlimport client/mysqltest \
+ client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest
 do
   cp -p $i $BASE/bin
 done
@@ -49,7 +65,16 @@ rm $BASE/include/Makefile*; rm $BASE/include/*.in
 cp -p tests/*.res tests/*.tst tests/*.pl $BASE/tests
 cp -p support-files/* $BASE/support-files
 cp -p libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a $BASE/lib
-cp -r -p sql/share/* $BASE/share/mysql; rm -f $BASE/share/mysql/Makefile* $BASE/share/mysql/*/*.OLD $BASE/share/CVS $BASE/share/*/CVS 
+cp -r -p sql/share/* $BASE/share/mysql
+rm -f $BASE/share/mysql/Makefile* $BASE/share/mysql/*/*.OLD
+rm -rf $BASE/share/SCCS  $BASE/share/*/SCCS 
+
+cp  -p mysql-test/mysql-test-run mysql-test/install_test_db $BASE/scripts
+cp -p mysql-test/README $BASE/README
+cp -p mysql-test/include/*.inc $BASE/mysql-test/include
+cp -p mysql-test/std_data/*.dat $BASE/mysql-test/std_data
+cp -p mysql-test/t/*.test mysql-test/t/*.opt $BASE/mysql-test/t
+cp -p mysql-test/r/*.result  $BASE/mysql-test/r
 
 cp -p scripts/* $BASE/bin
 rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution $BASE/bin/setsomevars $BASE/support-files/Makefile* $BASE/support-files/*.sh
@@ -62,6 +87,8 @@ mv $BASE/support-files/binary-configure $BASE/configure
 chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/configure
 cp -r -p sql-bench/* $BASE/sql-bench
 rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
+rm -rf `find $BASE/sql-bench -name SCCS`
+rm -rf `find $BASE/share -name SCCS`
 
 # Change the distribution to a long descreptive name
 NEW_NAME=mysql-$version-$system-$machine
@@ -86,6 +113,11 @@ then
   cd $SOURCE
 fi
 
+#if we are debugging, do not do tar/gz
+if [ x$DEBUG = x1 ] ; then
+ exit
+fi
+
 # This is needed to prefere gnu tar instead of tar because tar can't
 # always handle long filenames
 
-- 
2.30.9