[Dbconfig-common-changes] [dbconfig-common] r436 - in trunk/test: . data scripts

Sean Finney seanius at alioth.debian.org
Sun Apr 6 15:40:14 UTC 2008


Author: seanius
Date: 2008-04-06 15:40:14 +0000 (Sun, 06 Apr 2008)
New Revision: 436

Added:
   trunk/test/data/dbc_mysql_check_user.localhost.exists.stdout.txt
   trunk/test/data/dbc_mysql_check_user.localhost.nogrant.stdout.txt
   trunk/test/data/dbc_mysql_check_user.remote.exists.stdout.txt
   trunk/test/data/dbc_mysql_createdb.verifyfail.txt
   trunk/test/data/dbc_mysql_createdb.verifyok.txt
   trunk/test/data/dbc_mysql_createuser.nohost.log.verifyfail.txt
   trunk/test/data/dbc_mysql_createuser.nohost.log.verifyok.txt
   trunk/test/data/dbc_mysql_createuser.nohost.sql.txt
   trunk/test/data/dbc_mysql_createuser.remote.log.verifyfail.txt
   trunk/test/data/dbc_mysql_createuser.remote.log.verifyok.txt
   trunk/test/data/dbc_mysql_createuser.remote.sql.txt
   trunk/test/data/dbc_mysql_dropdb.verifyfailed.txt
   trunk/test/data/dbc_mysql_dropdb.verifyok.txt
   trunk/test/data/mockup.stdout.txt
Modified:
   trunk/test/functions
   trunk/test/mockdb.sh
   trunk/test/scripts/mockup
Log:
checkpoint on more test cases, before introducing newer/cleanup mockup scripts


Added: trunk/test/data/dbc_mysql_check_user.localhost.exists.stdout.txt
===================================================================
--- trunk/test/data/dbc_mysql_check_user.localhost.exists.stdout.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_check_user.localhost.exists.stdout.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,3 @@
+Grants for testdbuser at localhost
+GRANT USAGE ON *.* TO 'testdbuser'@'localhost' IDENTIFIED BY PASSWORD 'blah'
+GRANT ALL PRIVILEGES ON `testdbname`.* TO 'testdbuser'@'localhost'

Added: trunk/test/data/dbc_mysql_check_user.localhost.nogrant.stdout.txt
===================================================================
--- trunk/test/data/dbc_mysql_check_user.localhost.nogrant.stdout.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_check_user.localhost.nogrant.stdout.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,3 @@
+Grants for testdbuser at localhost
+GRANT USAGE ON *.* TO 'testdbuser'@'localhost' IDENTIFIED BY PASSWORD 'blah'
+GRANT ALL PRIVILEGES ON `testdbname2`.* TO 'testdbuser'@'localhost'

Added: trunk/test/data/dbc_mysql_check_user.remote.exists.stdout.txt
===================================================================
--- trunk/test/data/dbc_mysql_check_user.remote.exists.stdout.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_check_user.remote.exists.stdout.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,3 @@
+Grants for testdbuser at host2
+GRANT USAGE ON *.* TO 'testdbuser'@'host2'
+GRANT ALL PRIVILEGES ON `testdbname`.* TO 'testdbuser'@'host2'

Added: trunk/test/data/dbc_mysql_createdb.verifyfail.txt
===================================================================
--- trunk/test/data/dbc_mysql_createdb.verifyfail.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createdb.verifyfail.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+creating database testdbname: success.
+verifying database testdbname exists: failed.

Added: trunk/test/data/dbc_mysql_createdb.verifyok.txt
===================================================================
--- trunk/test/data/dbc_mysql_createdb.verifyok.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createdb.verifyok.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+creating database testdbname: success.
+verifying database testdbname exists: success.

Added: trunk/test/data/dbc_mysql_createuser.nohost.log.verifyfail.txt
===================================================================
--- trunk/test/data/dbc_mysql_createuser.nohost.log.verifyfail.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createuser.nohost.log.verifyfail.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+granting access to database testdbname for testdbuser at localhost: success.
+verifying access for testdbuser at localhost: failed.

Added: trunk/test/data/dbc_mysql_createuser.nohost.log.verifyok.txt
===================================================================
--- trunk/test/data/dbc_mysql_createuser.nohost.log.verifyok.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createuser.nohost.log.verifyok.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+granting access to database testdbname for testdbuser at localhost: success.
+verifying access for testdbuser at localhost: success.

Added: trunk/test/data/dbc_mysql_createuser.nohost.sql.txt
===================================================================
--- trunk/test/data/dbc_mysql_createuser.nohost.sql.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createuser.nohost.sql.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+GRANT ALL PRIVILEGES ON `testdbname`.* TO `testdbuser`@'localhost' IDENTIFIED BY 'testdbpass';
+FLUSH PRIVILEGES;

Added: trunk/test/data/dbc_mysql_createuser.remote.log.verifyfail.txt
===================================================================
--- trunk/test/data/dbc_mysql_createuser.remote.log.verifyfail.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createuser.remote.log.verifyfail.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+granting access to database testdbname for testdbuser at host2: success.
+verifying access for testdbuser at host2: failed.

Added: trunk/test/data/dbc_mysql_createuser.remote.log.verifyok.txt
===================================================================
--- trunk/test/data/dbc_mysql_createuser.remote.log.verifyok.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createuser.remote.log.verifyok.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+granting access to database testdbname for testdbuser at host2: success.
+verifying access for testdbuser at host2: success.

Added: trunk/test/data/dbc_mysql_createuser.remote.sql.txt
===================================================================
--- trunk/test/data/dbc_mysql_createuser.remote.sql.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_createuser.remote.sql.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+GRANT ALL PRIVILEGES ON `testdbname`.* TO `testdbuser`@'host2' IDENTIFIED BY 'testdbpass';
+FLUSH PRIVILEGES;

Added: trunk/test/data/dbc_mysql_dropdb.verifyfailed.txt
===================================================================
--- trunk/test/data/dbc_mysql_dropdb.verifyfailed.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_dropdb.verifyfailed.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+dropping database testdbname: success.
+verifying database testdbname was dropped: failed.

Added: trunk/test/data/dbc_mysql_dropdb.verifyok.txt
===================================================================
--- trunk/test/data/dbc_mysql_dropdb.verifyok.txt	                        (rev 0)
+++ trunk/test/data/dbc_mysql_dropdb.verifyok.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1,2 @@
+dropping database testdbname: success.
+verifying database testdbname was dropped: success.

Added: trunk/test/data/mockup.stdout.txt
===================================================================
--- trunk/test/data/mockup.stdout.txt	                        (rev 0)
+++ trunk/test/data/mockup.stdout.txt	2008-04-06 15:40:14 UTC (rev 436)
@@ -0,0 +1 @@
+first mockup stdout

Modified: trunk/test/functions
===================================================================
--- trunk/test/functions	2008-03-30 18:43:28 UTC (rev 435)
+++ trunk/test/functions	2008-04-06 15:40:14 UTC (rev 436)
@@ -1,6 +1,12 @@
 # override the installation root
 _dbc_root="`dirname \"$0\"`/.."
 
+# print out a tab-indented line informing of what's happening in a test
+log_tc(){
+	tc_case_no=`expr $tc_case_no + 1`
+	printf "\\tcase $tc_case_no: $1\\n"
+}
+
 # takes a single argument and escapes it literally in a fashion that
 # allows it to be used without further quoting
 escape(){
@@ -109,9 +115,14 @@
 
 	# specify where the mockup logs should go
 	mockup_logdir="${curdir}/tmp"
+	export mockup_lockfile="${mockup_logdir}/mockup.lock"
 	export mockup_cmdline="${mockup_logdir}/mockup.cmdline"
 	export mockup_errfile="${mockup_logdir}/mockup.errors"
 	export mockup_inlog="${mockup_logdir}/mockup.in.log"
+	export mockup_parallel=""
+	export mockup_stdin=""
+	export mockup_stdout=""
+	export mockup_stderr=""
 
 	# splice in the mockup script path
 	export ORIG_PATH=$PATH
@@ -119,14 +130,19 @@
 	export PATH=$MOCKUP_PATH
 }
 
-setUp(){
-	rm -rf ./tmp; 
+purge_tmp(){
+	rm -rf ./tmp
 	mkdir -p "$TMPDIR"
 	# for convenience, since we make a really ugly TMPDIR for tests
 	ln -s "$TMPDIR" ./tmp/tmpdir
 	touch $_dbc_logfile
 }
 
+setUp(){
+	purge_tmp
+	tc_case_no=0
+}
+
 tearDown(){ 
 	assertDirectoryEmpty "cruft files left behind" "$TMPDIR" 
 } 

Modified: trunk/test/mockdb.sh
===================================================================
--- trunk/test/mockdb.sh	2008-03-30 18:43:28 UTC (rev 435)
+++ trunk/test/mockdb.sh	2008-04-06 15:40:14 UTC (rev 436)
@@ -1,7 +1,9 @@
 #!/bin/sh 
 
 dbc_dbname="testdbname"
+dbc_dbuser="testdbuser"
 dbc_dbadmin="testadmin"
+dbc_dbpass="testdbpass"
 dbc_dbadmpass="testadmpass"
 dbc_dbserver="testserver"
 dbc_dbport="testport"
@@ -22,7 +24,7 @@
 }
 
 test_mysql_check_connect(){
-	_dbc_mysql_check_connect
+	_dbc_mysql_check_connect </dev/null
 	assertTrue "mysql_check_connect failed" $?
 	subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
 	assertFilesEqual ./data/mysql_check_connect.txt "$mockup_cmdline"
@@ -34,13 +36,13 @@
 
 	sql=`mktemp -t`
 
-	# basic test
+	log_tc "expected behaviour for existing file"
 	dbc_mysql_exec_file "$sql" >/dev/null
 	assertTrue "dbc_mysql_exec_file (withdb) failed" $?
 	subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
 	assertFilesEqual ./data/dbc_mysql_exec_file.withdb.txt "$mockup_cmdline"
 
-	# test with non-existing sqlfile
+	log_tc "expected behaviour for missing file"
 	dbc_mysql_exec_file "does not exist.sql" >/dev/null
 	assertFalse "dbc_mysql_exec_file (withdb) should have failed" $?
 	subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
@@ -48,11 +50,13 @@
 
 	# same as before, but with _dbc_nodb set
 	_dbc_nodb=yes
+	log_tc "expected behaviour for existing file, no database"
 	dbc_mysql_exec_file "$sql" >/dev/null 
 	assertTrue "dbc_mysql_exec_file (nodb) failed" $?
 	subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
 	assertFilesEqual ./data/dbc_mysql_exec_file.nodb.txt "$mockup_cmdline"
 
+	log_tc "expected behaviour for missing file, no database"
 	dbc_mysql_exec_file "does not exist.sql" >/dev/null
 	assertFalse "dbc_mysql_exec_file (nodb) should have failed" $?
 	subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
@@ -62,6 +66,8 @@
 }
 
 test_mysql_exec_command(){
+	local mockup_stdin
+	export mockup_stdin=/dev/stdin
 	dbc_mysql_exec_command "select * from foo where bar = 1"
 	assertTrue "dbc_mysql_exec_command failed" $?
 	assertFilesEqual ./data/mysql_exec_command.sql.txt "$mockup_inlog"
@@ -71,12 +77,271 @@
 	local mockup_stdout
 	export mockup_stdout=./data/dbc_mysql_check_database.exists.stdout.txt
 
+	log_tc "database exists"
 	_dbc_mysql_check_database "$dbc_dbname"
 	assertTrue "_dbc_mysql_check_database failed to find db" $?
 
+	log_tc "database does not exist"
 	mockup_stdout=./data/dbc_mysql_check_database.missing.stdout.txt
 	_dbc_mysql_check_database "$dbc_dbname"
 	assertFalse "_dbc_mysql_check_database shouldn't have found db" $?
 }
 
+test_dbc_mysql_check_user(){
+	local mockup_stdout dbc_dballow
+	export mockup_stdout
+
+	# check the standard case, existing user, with grant, localhost
+	mockup_stdout=./data/dbc_mysql_check_user.localhost.exists.stdout.txt
+	dbc_mysql_check_user
+	assertTrue "dbc_mysql_check_user failed to find user" $?
+
+	# case 2: user does not exist at all
+	mockup_stdout=/dev/null
+	dbc_mysql_check_user
+	assertFalse "dbc_mysql_check_user shouldn't have found user" $?
+
+	# case 3: user exists, does not have grant
+	mockup_stdout=./data/dbc_mysql_check_user.localhost.nogrant.stdout.txt
+	dbc_mysql_check_user
+	assertFalse "dbc_mysql_check_user shouldn't have found grant" $?
+
+	# case 4: same as case 2 but at remote host
+	dbc_dballow="host2"
+	mockup_stdout=./data/dbc_mysql_check_user.remote.exists.stdout.txt
+	dbc_mysql_check_user
+	assertTrue "dbc_mysql_check_user failed to find user on remote" $?
+}
+
+test_dbc_mysql_createdb(){
+	local mockup_stdout_1 mockup_stdout_3 mockup_returncode_2 mockup_parallel 
+	local output
+	export mockup_parallel=1
+	export mockup_stdout_1 mockup_stdout_3 mockup_returncode_2
+
+	log_tc "database already exists"
+	mockup_stdout_1=./data/dbc_mysql_check_database.exists.stdout.txt
+	output=`dbc_mysql_createdb 2>&1`
+	assertTrue "dbc_mysql_createdb failed" $?
+	assertEquals "creating database testdbname: already exists." "$output"
+
+	log_tc "database does not exist, creation successful"
+	purge_tmp
+	mockup_stdout_1=./data/dbc_mysql_check_database.missing.stdout.txt
+	mockup_stdout_3=./data/dbc_mysql_check_database.exists.stdout.txt
+	output=`dbc_mysql_createdb 2>&1`
+	assertTrue "dbc_mysql_createdb failed" $?
+	assertFilesEqual "./data/dbc_mysql_createdb.verifyok.txt" "$_dbc_logfile"
+
+	log_tc "database does not exist, creation failed"
+	purge_tmp
+	mockup_stdout_1=./data/dbc_mysql_check_database.missing.stdout.txt
+	mockup_returncode_2=1
+	output=`dbc_mysql_createdb 2>&1`
+	assertFalse "dbc_mysql_createdb should have failed" $?
+	assertEquals "creating database testdbname: failed." "$output"
+
+	log_tc "database does not exist, creation ok, verify failed"
+	purge_tmp
+	mockup_returncode_2=0
+	mockup_stdout_1=./data/dbc_mysql_check_database.missing.stdout.txt
+	mockup_stdout_3=./data/dbc_mysql_check_database.missing.stdout.txt
+	output=`dbc_mysql_createdb 2>&1`
+	assertFalse "dbc_mysql_createdb should have failed" $?
+	assertFilesEqual "./data/dbc_mysql_createdb.verifyfail.txt" "$_dbc_logfile"
+}
+
+test_dbc_mysql_dropdb(){
+	local mockup_stdout_1 mockup_stdout_3 mockup_returncode_2 mockup_parallel 
+	local output
+	export mockup_parallel=1
+	export mockup_stdout_1 mockup_stdout_3 mockup_returncode_2
+
+	log_tc "database does not exist"
+	mockup_stdout_1=./data/dbc_mysql_check_database.missing.stdout.txt
+	output=`dbc_mysql_dropdb 2>&1`
+	assertTrue "dbc_mysql_dropdb failed" $?
+	assertEquals "dropping database testdbname: database does not exist." "$output"
+
+	log_tc "database exists, drop successful"
+	purge_tmp
+	mockup_stdout_1=./data/dbc_mysql_check_database.exists.stdout.txt
+	mockup_stdout_3=./data/dbc_mysql_check_database.missing.stdout.txt
+	output=`dbc_mysql_dropdb 2>&1`
+	assertTrue "dbc_mysql_dropdb failed" $?
+	assertFilesEqual "./data/dbc_mysql_dropdb.verifyok.txt" "$_dbc_logfile"
+
+	log_tc "database exists, drop failed"
+	purge_tmp
+	mockup_stdout_1=./data/dbc_mysql_check_database.exists.stdout.txt
+	mockup_stdout_3=./data/dbc_mysql_check_database.missing.stdout.txt
+	mockup_returncode_2=1
+	output=`dbc_mysql_dropdb 2>&1`
+	assertFalse "dbc_mysql_dropdb should have failed" $?
+	assertEquals "dropping database testdbname: failed." "$output"
+	mockup_returncode_2=0
+
+	log_tc "database exists, drop ok, verify failed"
+	purge_tmp
+	mockup_stdout_1=./data/dbc_mysql_check_database.exists.stdout.txt
+	mockup_stdout_3=./data/dbc_mysql_check_database.exists.stdout.txt
+	rm -f "$_dbc_logfile"
+	output=`dbc_mysql_dropdb 2>&1`
+	assertFalse "dbc_mysql_dropdb should have failed" $?
+	assertFilesEqual "./data/dbc_mysql_dropdb.verifyfailed.txt" "$_dbc_logfile"
+}
+
+test_dbc_mysql_createuser(){
+	local mockup_stdout_1 mockup_stdout_3 mockup_stdin_2 mockup_parallel output
+	local dbc_dballow dbc_dbserver mockup_returncode_2
+	export mockup_parallel=1
+	export mockup_stdout_1 mockup_stdout_3 mockup_stdin_2 mockup_returncode_2
+
+	# what's being checked, roughly:
+	# connecting with no hostname
+	# 	user exists
+	#   user does not exist
+	#	  grant input
+	#     creation succeeds
+	#       verify succeeds
+	#         log message
+	#       verify fails
+	#         log message
+	#     creation fails
+	# 	    log message
+	# connecting with hostname
+	# 	user exists
+	#   user does not exist
+	#	  grant input
+	#     creation succeeds
+	#       verify succeeds
+	#         log message
+	#       verify fails
+	#         log message
+	#     creation fails
+	# 	    log message
+
+
+	log_tc "local host, user exists"
+	mockup_stdout_1="./data/dbc_mysql_check_user.localhost.exists.stdout.txt"
+	output=`dbc_mysql_createuser 2>&1`
+	assertTrue "dbc_mysql_createuser failed" $?
+	assertEquals "granting access to database testdbname for testdbuser at localhost: already exists." "$output"
+
+	log_tc "local host, user does not exist, creation success, verify ok"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_check_user.localhost.missing.stdout.txt"
+	mockup_stdin_2="/dev/stdin"
+	mockup_stdout_3="./data/dbc_mysql_check_user.localhost.exists.stdout.txt"
+	output=`dbc_mysql_createuser 2>&1`
+	assertTrue "dbc_mysql_createuser failed" $?
+	assertFilesEqual "./data/dbc_mysql_createuser.nohost.sql.txt" "${mockup_inlog}.2"
+	assertFilesEqual "data/dbc_mysql_createuser.nohost.log.verifyok.txt" "$_dbc_logfile"
+	mockup_stdin_2=
+
+	log_tc "local host, user does not exist, creation success, verify fails"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_checkuser.localhost.nogrant.stdout.txt"
+	mockup_stdout_3="./data/dbc_mysql_checkuser.localhost.nogrant.stdout.txt"
+	output=`dbc_mysql_createuser 2>&1`
+	assertFalse "dbc_mysql_createuser should have failed" $?
+	assertFilesEqual "data/dbc_mysql_createuser.nohost.log.verifyfail.txt" "$_dbc_logfile"
+
+	log_tc "local host, user does not exist, creation fails"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_check_user.localhost.nogrant.stdout.txt"
+	mockup_returncode_2=1
+	output=`dbc_mysql_createuser 2>&1`
+	assertFalse "dbc_mysql_createuser should have failed" $?
+	assertEquals "granting access to database testdbname for testdbuser at localhost: failed." "$output"
+	mockup_returncode_2=
+
+	log_tc "remote host, user exists"
+ 	export dbc_dballow="host2"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_check_user.remote.exists.stdout.txt"
+	output=`dbc_mysql_createuser 2>&1`
+	assertTrue "dbc_mysql_createuser failed" $?
+	assertEquals "granting access to database testdbname for testdbuser at host2: already exists." "$output"
+
+	log_tc "remote host, user does not exist, creation success, verify ok"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_check_user.remote.nogrant.stdout.txt"
+	mockup_stdin_2="/dev/stdin"
+	mockup_stdout_3="./data/dbc_mysql_check_user.remote.exists.stdout.txt"
+	output=`dbc_mysql_createuser 2>&1`
+	assertTrue "dbc_mysql_createuser failed" $?
+	assertFilesEqual "./data/dbc_mysql_createuser.remote.sql.txt" "${mockup_inlog}.2"
+	assertFilesEqual "./data/dbc_mysql_createuser.remote.log.verifyok.txt" "$_dbc_logfile"
+	mockup_stdin_2=
+
+	log_tc "remote host, user does not exist, creation success, verify fails"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_check_user.remote.nogrant.stdout.txt"
+	mockup_stdout_3="./data/dbc_mysql_check_user.remote.nogrant.stdout.txt"
+	output=`dbc_mysql_createuser 2>&1`
+	assertFalse "dbc_mysql_createuser should have failed" $?
+	assertFilesEqual "data/dbc_mysql_createuser.remote.log.verifyfail.txt" "$_dbc_logfile"
+
+	log_tc "remote host, user does not exist, creation fails"
+	purge_tmp
+	mockup_stdout_1="./data/dbc_mysql_check_user.remote.nogrant.stdout.txt"
+	mockup_returncode_2=1
+	output=`dbc_mysql_createuser 2>&1`
+	assertFalse "dbc_mysql_createuser should have failed" $?
+	assertEquals "granting access to database testdbname for testdbuser at host2: failed." "$output"
+	mockup_returncode_2=
+	cat ./tmp/dbconfig-common.sql*
+}
+
+test_dbc_mysql_dropuser(){
+	log_tc TODO
+	# to check:
+	# connecting with no hostname
+	#   user doesn't exist
+	#   user exists
+	#     revoke input
+	#     revoke succeeds
+	#       log msg
+	#     revoke fails
+	#       verifying revoke succeeds
+	#         log msg
+	#       verifying revoke fails
+	#         log msg
+	# connecting with hostname
+	#   user doesn't exist
+	#   user exists
+	#     revoke input
+	#     revoke succeeds
+	#       log msg
+	#     revoke fails
+	#       verifying revoke succeeds
+	#         log msg
+	#       verifying revoke fails
+	#         log msg
+}
+
+test_dbc_mysql_dump(){
+	log_tc TODO
+	# to check:
+	# mysqldump cmdline
+	# mysqldump succeeds
+	#   log msg
+	# mysqldump fails
+	#   log msg
+}
+
+test_dbc_mysql_db_installed(){
+	log_tc TODO
+	# mysqld in path
+	# mysqld not in path
+}
+
+test_dbc_mysql_escape_str(){
+	log_tc TODO
+	# normal string
+	# string with \
+	# string with '
+}
+
 . /usr/share/shunit2/shunit2

Modified: trunk/test/scripts/mockup
===================================================================
--- trunk/test/scripts/mockup	2008-03-30 18:43:28 UTC (rev 435)
+++ trunk/test/scripts/mockup	2008-04-06 15:40:14 UTC (rev 436)
@@ -2,22 +2,69 @@
 # database client mockup implementation
 set -eu
 
+trap cleanup 0
+cleanup(){
+	[ -z ${have_lockfile:-} ] || rm -f ${mockup_lockfile}
+}
+
+# if we're running in parallel with other instances of mockup, do some
+# primitive locking to try to serialize and make things a little more sane
+parallel=${mockup_parallel:-}
+if [ -n "$parallel" ]; then
+	lockfile ${mockup_lockfile}
+	have_lockfile=1
+fi
+
+# get our called-as name (in case we're symlinked)
 mockup=`basename $0`
 # where mockup should print its cmdline
 cmdfile="${mockup_cmdline}"
 # where mockup should print internal errors
 errfile="${mockup_errfile}"
 
-stdout="${mockup_stdout:-/dev/null}"
-stderr="${mockup_stderr:-/dev/null}"
+# locations of mock input/output files
+stdout="${mockup_stdout:-}"
+stderr="${mockup_stderr:-}"
 stdin="${mockup_stdin:-}"
+
+# log the input we were given
+inputlog="${mockup_inlog}"
+
+# if we should return nonzero
 retcode="${mockup_returncode:-0}"
 
-inputlog="$mockup_inlog"
+# increment all the file locations if we're running multiple times in the
+# same test suite
+if [ -n "$parallel" ] && [ -f "$cmdfile" ]; then
+	newcmdfile="$cmdfile"
+	while [ -f "$newcmdfile" ]; do
+		increment=`expr ${increment:-0} + 1`
+		newcmdfile="${cmdfile}.${increment}"
+	done
+	cmdfile="$newcmdfile"
+	errfile="${errfile}.$increment"
+	inputlog="${inputlog}.$increment"
+	newretcodename="\${mockup_returncode_$increment:-}"
+	newstdoutname="\${mockup_stdout_$increment:-}"
+	newstderrname="\${mockup_stderr_$increment:-}"
+	newstdinname="\${mockup_stdin_$increment:-}"
+	newretcode=`eval echo "\$newretcodename" 2>"$errfile"`
+	newstdout=`eval echo "\$newstdoutname" 2>"$errfile"`
+	newstderr=`eval echo "\$newstderrname" 2>"$errfile"`
+	newstdin=`eval echo "\$newstdinname" 2>"$errfile"`
+	stdout=${newstdout:-}
+	stderr=${newstderr:-}
+	stdin=${newstdin:-}
+	retcode=${newretcode:-}
+fi
 
-cmdline=''
-needs_input=''
+touch "$cmdfile"
+if [ -z "$parallel" ]; then rm -f ${mockup_lockfile}; fi
 
+[ -n "$stdout" ] || stdout=/dev/null
+[ -n "$stderr" ] || stderr=/dev/null
+[ -n "$stdin" ] || stdin=/dev/null
+
 # replace commonly used variables in the cmdline
 replace_variables(){
 	local esc_tmpdir
@@ -28,7 +75,7 @@
 set $mockup "$@"
 while [ $# -gt 0 ]; do
 	escaped="`echo $1 | replace_variables | sed -e \"s/'/'\\\\\\''/g\"`"
-	if [ "$cmdline" ]; then
+	if [ -n "${cmdline:-}" ]; then
 		cmdline="$cmdline '$escaped'"
 	else
 		cmdline="'$escaped'"
@@ -39,7 +86,7 @@
 echo "$@" > "$cmdfile"
 
 if [ "$stdin" ]; then 
-	exec 0<&"$stdin"
+	exec 0<"$stdin"
 fi
 cat > "$inputlog" 2>"$errfile"
 cat "$stdout" 2>"$errfile"




More information about the Dbconfig-common-changes mailing list