[comp.software-eng] Need PD Random Expression generator tool.

paulr@sequent.uucp (Paul Reger) (11/17/90)

I test C compilers for a living.  I need a tool that could produce
random expressions to be used in compiler tests.  Does anyone know of
any PD tools of this sort?  The use I am specifically interested in
was the following.  The tool would generate a program that would
automatically validate its results.  For example:

int
f(int i)
{
    return 2*i;
}

int x1 = 23,x2 = 20;

main()
{
    register char *x3 = "Hi mom";
    short x4[4] = {1,2,3,4};
    struct s1 {
    	int s1_e1;
    	char s1_e2;
    } x5 = {2,'a'},*x6 = &x5;

    {
	int ov = ((long) x6->s1_e2 << f(x5.s1_e1+x4[x1-x2])) - x3[0] +
    	    	    *(x3 + x4[0]);
	printf("observed value: %d expected value: %d\n",ov,397345);
	exit (ov != 397345);
    }
}

Some of the needed features:

1.  Test function calls, with expressions as parameters.
2.  Expressions within array indices. and pointer arithmetic.
3.  Structure dereferencing operators: `->' and `.'.
4.  The usual arithmetic operator tests.
5.  Predict floating point error allowances (example not shown).
6.  Predict resulting type of expression, as well as its value.
7.  Stuff expression in a program template and be compilable for
    automatic verification.
8.  The expressions generated should be random, arbitrary, yet
controllable (I'd want to be able to tell it what types of expressions
to generate).

Also, if you know of any papers on the subject, I'd be interested in
this as well.

Thank you,


			paulr    (Paul Reger)
	     Compilers/Product Integration and Evaluation
	      Sequent Computer Systems, Beaverton Oregon
	     {uunet,ucbvax!rutgers!ogccse}!sequent!paulr
			  paulr@sequent.com