SPRL/I - an interpreter for Informix Stored Procedure regression
Posted in 1999
Hi all
I have written an interpreter for a simple scripting language I call SPRL/I,
that will allow one to run a series of canned tests for a group of stored
procedures. It is written using GNU flex, bison and ESQL/gcc and is available
for download at my web site:
http://www.geocities.com/sujitpal/artdb006.html
If you are just interested in the source code, there is a listing at:
http://www.geocities.com/sujitpal/cdldb008.html
The software is free. In case you people think it is useful I will contact Walt
to include it in the IIUG software archives.
Here is the README file that is included in the tarball, which will probably
explain more: The first URL in the mail contains an HTML version of the same
thing.
------------------------------------------------8<-----------------------------------------------------
SPRL/I - a scripting language for regression testing
Informix Stored Procedures
--------------------------
INTRODUCTION
------------
SPRL/I is a scripting language which is designed to be used as a scripting
language to set up a regression test for a group of stored procedures
written in the Informix Stored Procedure Language (SPL).
The lexer and parser parse a small grammar which I call SPRL/I (Stored
Procedure Regression testing Language for Informix), pronounced sprawl or
spiral, depending on your preference. This program takes the tokens and
converts them to ESQL/C calls to run the stored procedure, and compare the
output with the result specified in the SPRL script file. The SPRL language
is described in this document in the Language Specifications section.
The rationale for creating a language and a language interpreter to do
stored procedure regression testing is to ensure that changes made to a
stored procedure to keep it in line with business requirements does not
inadverdently break something in some other stored procedure. It is possible
to manually check each stored procedure to make sure, but that becomes
quite time-consuming as the number of stored procedures grows. SPRL allows
you to check each stored procedure by feeding it values and comparing it
to expected results, but it does so automatically, thereby resulting in
large time-savings. You are also sure that the test plan you created is
adhered to each time the regression test occurs.
An HTML copy of this document is available at
http://www.geocities.com/sujitpal/artdb006.html.
LANGUAGE SPECIFICATIONS
-----------------------
1. Comments are indicated by a #. Anything followed by a # sign is ignored
till the end of line. This means that you can put inline comments as well
as block comments using #. Example:
# This is a block comment
set $varname = "Value"; # setting varname (inline comment)
2. The SET keyword assigns a value to a variable name. Example:
set $varname = "Value";
will assign a value "Value" to the variable $varname.
3. The ECHO keyword prints the string following the ECHO to STDOUT. Example:
echo "The quick brown fox jumped over the lazy dog";
will print the string "The quick brown..." to STDOUT.
4. The SYSTEM keyword executes the string following the SYSTEM from the
operating system. Example:
system "ls -l";
will make the operating system execute the command "ls -l".
5. The DATABASE keyword sets the database to be used for subsequent stored
procedure calls. Example:
database quix;will make the database quix the current database. It can be overriden by
specifying the database from the sprl command line with -d=database_name.
6. The PROC keyword instructs the sprl program to run the stored procedure
named in the PROC command. Example:
PROC procname ([var1, ...]) [>> $outvar1 [, $outvar2,...]];
where procname is the stored procedure name, [var1, ...] is an optional
number of input variables, >> is the assignment to the output variables
outvar1 [, outvar2, ...]. Note that you dont need to explicitly name all
the output variables. Assume that you have a procedure returning three
values, out of which you only need the first variable for later processing,
then you would say:
PROC procname ([var1, ...]) >> $outvar1;
However, if you need only the second output variable, then you would say:
PROC procname ([var1, ...]) >> $outvar1, $outvar2;
where you would then discard the value of $outvar1.
7. The CMP keyword specifies a string that is expected and which will be
compared to the output of the PROC command. It is followed by a string
which is a comma-separated sequence of variables and/or values. Example:
CMP 'row0:0,$variable,Value 1,Value 2,$variable2';
Note that there are no spaces between the commas. However, if your value
contains a space, such as Value 1, then you can put it as shown above.
The rown: precedes each result line, where n is the row number. For multiple
line results, you need to separate the lines with a \\ (backslash). Example:
CMP 'row0:0,$variable1,Value 1\\row1:0,$variable2,Value 2';
8. A PROC must be followed by one and only one CMP.
9. Variables are indicated by preceding it with a $ (dollar) sign, like Perl
or Basic.
10. All commands are terminated by a ; (semi-colon).
COMMAND LINE USAGE
------------------
If you type the sprl command with a -h option, it will tell you the
command line syntax, like so:
prompt> sprl -h
Informix Stored Procedure Regression Tester
ver. 0.01, written by Sujit Pal, November 1999
Usage: isprt [-h] [-c] [-d=dbname] scriptfile
Options:
-h : Display this message
-c : Check Syntax of file
-g=n : Debug mode
-d=dbname : Specify database name
Using the -c option, you can check the syntax of the SPRL script file
without running the stored procedures or doing the compares. Note that
this will not check for syntax errors in the stored procedures itself
or bad calls (insufficient arguments, etc) to the stored procedures.
Using the -g=n option, you can generate a trace and a symbol table
dump in case you need to debug the SPRL interpreter. There are 3 debug
levels you can specify by setting the value of n. With n=1, the
interpreter prints out the stored procedure it is executing currently.
With n=2, it prints out a trace of the function names it executes as
well as the current stored procedure. With n=3, it prints out the
parser trace (same as setting yydebug=1) as well as the above. The
default is -g=0, where it does not print out any trace information at all.
Using the -d=dbname option, you can override the database specified
inside the script file. You can also not have the database specified
inside the script file and specify it here instead.
The scriptfile name is the scriptfile that you are using to invoke the
stored procedures you are testing.
ERROR MESSAGES
--------------
1. parse error at line <line_number>, token: <string>
This points to a syntax error in the SPRL scriptfile, at the line specified
by <line_number>. The token where the parse failed is <string>.
2. Too many input arguments for procedure <procedure_name>, max <m