dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing program with random output [newbie]


From: Robert Hartmann
Subject: Re: Testing program with random output [newbie]
Date: Sun, 18 Aug 2013 22:49:19 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

Hi Ben and others,

Am 25.07.2013 00:07, schrieb Ben E.:
Hi Robert

Is it possible to create a test runnable with dejagnu for checking a
commandline-program which has randomized output: Testing concrete
single threaded commandline java programs which use Math.random().

Sure, why not?  If you can express verbally how you decide that the
test has passed, it can be implemented in Tcl.  You can use something
like "expr rand()" to generate random numbers.

Ben


First the program, which should be checked via DejaGNU, produces
an arbitary number of strings (ending with newline).

Well ok, I could verify by "hand" if the output (the randomized generated string) is valid.

For validating one string (= one line) I need two integer variables, say A and B.

The output string only containts the symbols  < > ^ v -
 and four defined words, say "WordA" "WordB" "WordC" "WordD".

Now I have to parse the string, and modify A=0 and B=0 this way:

For every
   < : A--,
   > : A++,
   ^ : B++,
   v : B--,
   - : do nothing

A string called "valid" if:
  B<0 and "WordD" is the last substring,
  B>0 + -2<A<2 + "WordC" is the last substring,
  A>=2 + "WordB" is the last substring,
  A<=2 + "WordA" is the last substring.
All other strings are "invalid"


If I look at my dejagnu "echo word", then there are lines like:

========================
[...]
proc PROGRAM_test {expr result} {
        global feedback
        send "$expr\n"
        expect {
          -gl "$result\r\n" {pass "$expr"}
          "*\r\n" { fail "$expr"}
          timeout { fail "timeout $expr"}
        }
}

PROGRAM_start
PROGRAM_test "Test1" "Echo: Test1"
PROGRAM_test "Test2" "Echo: Test2"
send_user "$feedback\n"
PROGRAM_exit
========================


For shure I have to modify the procedure PROGRAM_test for
validating PROGRAM output. But I don't get it.

I did not see, how I can do my string parsing in the "expect"-language,
and I don't see, how I can check for an indeterministic number of lines.


Best regards,
Robert




reply via email to

[Prev in Thread] Current Thread [Next in Thread]