X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/3f78365471d68728e6607ad49aaa6299f69c6f86..5a2a0989efb831472f8edf5c4991953e6140c3ad:/test/scripts/2610-MySQL/2610 diff --git a/test/scripts/2610-MySQL/2610 b/test/scripts/2610-MySQL/2610 index f5765c094..c9e0d5977 100644 --- a/test/scripts/2610-MySQL/2610 +++ b/test/scripts/2610-MySQL/2610 @@ -1,20 +1,36 @@ # mysql lookups +# The mysql-devel (or equivalent) package will be need for Exim to build, and +# the mysql-server (or mariadb-server or equivalent) package for this test to run. # # first, populate a DB to test against sudo rm -fr DIR/mysql +echo Installing DB server dir perl -system 'mysql_install_db --datadir=DIR/mysql'; +system 'mysql_install_db --no-defaults --datadir=DIR/mysql --user=CALLER'; **** sudo rm test-stdout test-stderr # # start a db server +echo Starting DB server background -mysqld_safe --datadir=DIR/mysql --log-error=DIR/mysql/log --port=PORT_N --socket=DIR/mysql/sock --pid-file=DIR/mysql/pidfile +DIR/bin.sys/mysqld --datadir=DIR/mysql --log-error=DIR/mysql/log --bind-address=* --port=PORT_N --socket=DIR/mysql/sock --pid-file=DIR/mysql/pidfile **** # # wait for db startup, insert some data +echo Waiting for DB server startup perl -system 'mysqladmin --protocol=TCP -P PORT_N --connect_timeout=1 --wait=5 -u root create test'; +system 'mysqladmin --protocol=TCP -P PORT_N --connect_timeout=2 --wait=5 -u root create test'; +my $fh; +open($fh, '-|', 'mysql --protocol=TCP -P PORT_N -u root -D test -e "select 1 from mysql.user where User = \'root\' and Host = \'HOSTIPV4\'"'); +my $line = <$fh>; +if (length($line) == 0) { + system 'mysql --protocol=TCP -P PORT_N -u root -D test -e "create user \'root\'@\'HOSTIPV4\'"'; +} +open($fh, '-|', 'mysql --protocol=TCP -P PORT_N -u root -D test -e "select 1 from mysql.user where User = \'CALLER\' and Host = \'HOSTIPV4\'"'); +$line = <$fh>; +if (length($line) == 0) { + system 'mysql --protocol=TCP -P PORT_N -u root -D test -e "create user \'CALLER\'@\'HOSTIPV4\'"'; +} system 'mysql --protocol=TCP -P PORT_N -u root -D test \ -e "CREATE TABLE them ( name text, id text ); \ INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \ @@ -24,8 +40,11 @@ system 'mysql --protocol=TCP -P PORT_N -u root -D test \ INSERT INTO them VALUES ( CONCAT(\'before\', CHAR(13), CHAR(10), \'after\'), \'newline\' ); \ INSERT INTO them VALUES ( CONCAT(\'x\', CHAR(9), \'x\'), \'tab\' ); \ INSERT INTO them VALUES ( CONCAT(CHAR(39), \'stquot\'), \'quote1\' ); \ + GRANT ALL ON *.* TO \'root\'@\'HOSTIPV4\'; \ + GRANT ALL ON *.* TO \'CALLER\'@\'HOSTIPV4\'; \ "'; **** +echo Populated DB sudo rm test-stderr-server # #