#!/bin/sh

lTest=1;
ret=0;

# Tests for v 0.1
# ---------------

cat << EOF > input
/u00/app/mysql/product/mysql-5.0.22/bin/mysqld, Version: 5.0.22-max-log. started with:
Tcp port: 3314  Unix socket: /u00/app/mysql/tmp/mysql-5.0.22.sock
Time                 Id Command    Argument
060806 16:53:08	     14 Quit       
060806 16:53:31	     15 Connect     topodb_read@master.rebenweg on topodb
		     15 Query       set autocommit=0
		     15 Quit       
060806 16:53:40	     16 Connect     topodb_read@master.rebenweg on topodb
		     16 Query       set autocommit=0
		     16 Query       SELECT id, file_name, html_map
  FROM image
 WHERE id = '37'
		     16 Query       SELECT COUNT(*)
  FROM continent
 WHERE image_id IS NULL
		     16 Quit       
EOF

./general2bench.pl --general-log=input > output 2>&1

cat <<EOF > result
set autocommit=0;

set autocommit=0;

SELECT id, file_name, html_map
  FROM image
 WHERE id = '37';

SELECT COUNT(*)
  FROM continent
 WHERE image_id IS NULL;
EOF

diff output result
if test  $? -ne 0  ; then
  echo "Test $lTest failed"
  let ret=$ret+1
else
  echo "Test $lTest OK"
fi

let lTest=$lTest+1

# Tests for v 0.1.1
# -----------------

cat << EOF > input
060806  6:59:51      21 Connect     root@localhost on
                     21 Query       SHOW VARIABLES LIKE 'pid_file'
                     21 Shutdown
060806  6:59:52      21 Connect     root@localhost on
EOF

./general2bench.pl --general-log=input > output 2>&1

cat << EOF > result
SHOW VARIABLES LIKE 'pid_file';
EOF

diff output result
if test  $? -ne 0  ; then
  echo "Test $lTest failed"
  let ret=$ret+1
else
  echo "Test $lTest OK"
fi

let lTest=$lTest+1

rm input output result
echo "Failed tests: $ret"
exit $ret

