Testsuite: MySQL portability
[exim.git] / test / scripts / 2610-MySQL / 2610
... / ...
CommitLineData
1# mysql lookups
2# The mysql-devel (or equivalent) package will be need for Exim to build, and
3# the mysql-server (or mariadb-server or equivalent) package for this test to run.
4#
5# first, populate a DB to test against
6sudo rm -fr DIR/mysql
7perl
8system 'mysql_install_db --no-defaults --datadir=DIR/mysql --user=CALLER';
9****
10sudo rm test-stdout test-stderr
11#
12# start a db server
13background
14mysqld_safe --datadir=DIR/mysql --log-error=DIR/mysql/log --port=PORT_N --socket=DIR/mysql/sock --pid-file=DIR/mysql/pidfile
15****
16#
17# wait for db startup, insert some data
18perl
19system 'mysqladmin --protocol=TCP -P PORT_N --connect_timeout=1 --wait=5 -u root create test';
20system 'mysql --protocol=TCP -P PORT_N -u root -D test \
21 -e "CREATE TABLE them ( name text, id text ); \
22 INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \
23 INSERT INTO them VALUES ( \'Aristotle\', \'aaaa\' ); \
24 INSERT INTO them VALUES ( \'\', \'nothing\' ); \
25 INSERT INTO them VALUES ( \'\"stquot\', \'quote2\' ); \
26 INSERT INTO them VALUES ( CONCAT(\'before\', CHAR(13), CHAR(10), \'after\'), \'newline\' ); \
27 INSERT INTO them VALUES ( CONCAT(\'x\', CHAR(9), \'x\'), \'tab\' ); \
28 INSERT INTO them VALUES ( CONCAT(CHAR(39), \'stquot\'), \'quote1\' ); \
29 CREATE USER IF NOT EXISTS \'root\'@\'HOSTIPV4\', \'CALLER\'@\'HOSTIPV4\'; \
30 GRANT ALL ON *.* TO \'root\'@\'HOSTIPV4\'; \
31 GRANT ALL ON *.* TO \'CALLER\'@\'HOSTIPV4\'; \
32 "';
33****
34sudo rm test-stderr-server
35#
36#
37exim -d-all+lookup -be
38${lookup mysql {select name from them where id='ph10';}}
39${lookup mysql {select name from them where id='ph10';}}
40${lookup mysql {select name from them where id='xxxx';}}
41${lookup mysql {select name from them where id='nothing';}}
42${lookup mysql {select id,name from them where id='nothing';}}
43${lookup mysql {delete from them where id='nonexist';}}
44${lookup mysql {select * from them where id='quote';}}
45${lookup mysql {select * from them where id='filter';}}
46${lookup mysql {select * from them where id='quote2';}}
47${lookup mysql {select * from them where id='nlonly';}}
48${lookup mysql {servers=x:127.0.0.1::PORT_N; select name from them where id='ph10';}}
49${lookup mysql {servers=127.0.0.1::PORT_N:x; select name from them where id='ph10';}}
50${lookup mysql {servers=127.0.0.1::PORT_N/test/root/:x; select name from them where id='ph10';}}
51${lookup mysql {servers=HOSTIPV4::PORT_N/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';}}
52${lookup mysql {servers=localhost(DIR/mysql/sock)/test/root/; select name from them where id='ph10';}}
53x
54${lookup mysql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}}
55${lookup mysql {SELECT * FROM them WHERE id IN ('ph10', 'aaaa');}}
56${lookup mysql {delete from them where id='aaaa'}}
57****
58exim -d -bh 10.0.0.0
59mail from:<a@b>
60rcpt to:<c@d>
61quit
62****
63exim -odi -d ph10
64Test message
65.
66****
67#
68perl
69system 'mysqladmin --protocol=TCP -P PORT_N -u root shutdown';
70****
71killdaemon
72sudo rm -fr DIR/mysql