From: Mark O'D. <mar...@lu...> - 2001-08-05 16:22:51
|
Just to keep you up to date: experimenting with dejagnu for limit, Here is how the results of running dejagnu on my still simple test script for limit: golem:~/src/interbase/TCS/new/test1> make check runtest WARNING: Couldn't find the global config file. WARNING: Couldn't find tool init file Test Run By odonohue on Mon Aug 6 02:09:48 2001 Native configuration is i686-pc-linux-gnu === isql tests === Schedule of variations: unix Running target unix Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using ./testsuite/config/unix.exp as tool-and-target-specific interface file. Running ./testsuite/isql.test/isql_sample.exp ... Running ./testsuite/isql.test/isql_sample2.exp ... Running ./testsuite/isql.test/limit/isql_sample2.exp ... FAIL: DSQL_Limit_skip3 (wrong count - 7 records found expected 6 ) FAIL: DSQL_Limit_skipFail2 (bad match) FAIL: DSQL_Limit_firstFail1 (bad match) === isql Summary === # of expected passes 15 # of unexpected failures 3 /opt/interbase/bin/isql version ISQL Version: LI-T0.9.5.309 Firebird Beta1 It also leaves an isql.log file with a trace of the transcript as well. And below is the current expect test script: The way it works is that in a global spot (different for each platform) it starts up the sub task (isql basically), then the command send "select X \r" will send that string to the sub isql process, then expect { <pattern> { actions } } are used to workout if the test succeeded. The spawned child processes that are run can be anything, and you can spawn many of them so you can in an advanced script spawn shells to compile test programs or run two seperate tasks at once. But also having a procedural language (basically tcl/expect) to specify the interaction makes it easy to write simple procedures to handle a large amount of the tricky pattern matching and error handling. There are still issues to work out, like where to store the additional data files, and suchlike, but nothing really difficult. Cheers Mark #_______________________________________________________________ # # expectations that clean up in case of error. Note that `$test' is # a purely local variable. # # The first of these is used to match any bad responses, and resynchronise # things by finding a prompt. The second is a timeout error, and shouldn't # ever be triggered. # expect_after { -re "\[^\n\r\]*$prompt$" { fail "${moduleName}_$test (bad match)" if { $verbose > 0 } { regexp ".*\r\n(\[^\r\n\]+)(\[\r\n\])+$prompt$" \ $expect_out(buffer) "" output send_user "\tUnmatched output: \"$output\"\n" } } timeout { fail "${moduleName}_$test (timeout)" } } # Build the database used for testing limit proc runBuildLimitDb {} { global moduleName global prompt set test "buildLimitDB" send "[exec cat data/builddb.sql]\n" expect { "$prompt$" { } "Statement failed" { fail "${moduleName}_$test (unable to build database)" } } } # Build the database used for testing limit proc runConnectLimitDb {} { global moduleName global prompt global databaseName set test "connectLimitDB" send "connect $databaseName;\n" expect { "$prompt$" { } "Statement failed" { fail "${moduleName}_$test (unable to connect to database)" } timeout { fail "${moduleName}_$test (timeout)" } } } #______________________________________________________________________________ # This process runs an sqlStmt and counts the number of results returned # checking them against the match mattern # success if the results equal fail if they do not. proc runBasicLimitTest { test sqlStmt matchPattern expectNum } { global moduleName global prompt global verbose set counter 0 send "$sqlStmt\r" expect { -re "$matchPattern" { set counter [expr $counter + 1] exp_continue } timeout { fail "${moduleName}_$test (timeout)" } -re "$prompt$" { } } # In the following expected counts is one more than real since we also match # the value as passed in so we decrement it. # maybe this could be done by setting echo off, or having a bit previously that # sucks up until we the echoed sql stmt, or the first "=====" which is the title # header. set counter [ expr $counter - 1 ] if { $counter == $expectNum } { pass "${moduleName}_$test" } else { fail "${moduleName}_$test (wrong count - $counter records found expected $expectNum )" } } #______________________________________________________________________________ # We expect these stmt to get back 'Statment failed' result; proc runMatchStmtTest { test sqlStmt matchPattern } { global moduleName global prompt global verbose set counter 0 send "$sqlStmt\n" expect { -re "$matchPattern" { pass "${moduleName}_$test" } timeout { fail "${moduleName}_$test (timeout)" } # -re "$prompt$" { # fail "${moduleName}_$test (statement did not fail)" # } } } # Here are the tests # set moduleName DSQL_Limit set databaseName "work/limits.gdb" #send_user "$argv0\n" set timeout 1000 #set verbose 1 runBuildLimitDb set timeout 3 runConnectLimitDb runBasicLimitTest "basicSelect" "select 'XXXX' from project;" "XXXX" 11 runBasicLimitTest "basic1" "select first 4 'XXXX' from project;" "XXXX" 4 runBasicLimitTest "basic2" "select first 4 skip 3 'XXXX' from project;" "XXXX" 4 runBasicLimitTest "basic4" "select first 5 skip 8 'XXXX' from project;" "XXXX" 4 runBasicLimitTest "skip1" "select skip 10 'XXXX' from project;" "XXXX" 2 runBasicLimitTest "skip2" "select skip 1 'XXXX' from project;" "XXXX" 11 runBasicLimitTest "skip3" "select skip 5 'XXXX' from project;" "XXXX" 7 runBasicLimitTest "first1" "select first 5 'XXXX' from project;" "XXXX" 5 runBasicLimitTest "first2" "select first 20 'XXXX' from project;" "XXXX" 11 runBasicLimitTest "first3" "select first 1 'XXXX' from project;" "XXXX" 1 # Some error cases that result in failure runMatchStmtTest "skipFail1" "select skip -1 'XXXX' from project;" "Statement failed" runMatchStmtTest "skipFail2" "select skip 0 'XXXX' from project;" "Statement failed" runMatchStmtTest "skipFail3" "select skip 1.8 'XXXX' from project;" "Statement failed" runMatchStmtTest "firstFail1" "select first -1 'XXXX' from project;" "Statement failed" runMatchStmtTest "firstFail2" "select first 0 'XXXX' from project;" "Statement failed" runMatchStmtTest "firstFail3" "select first 1.8 'XXXX' from project;" "Statement failed" -- Your database needs YOU! http://firebird.sourceforge.net GPL: free software today - and still free tomorrow |