embedded systems developers tools, cross compilers
  Home  |   SwiftX Archive  |   SwiftForth Archive  |

Re: Test automation

From: Ron Oliver <roliver_at_openesque.com>
Date: Tue, 21 Jan 2003 19:48:02 -0500 (EST)

How to reply: Use your email client's "Reply All" function to reply to the
entire list (preferred). Use "Reply" for a private reply to the sender.
--------------------------------------------------------------------------

On Tue, 21 Jan 2003, Noel Henson wrote:

> Is there a way I can run a progam in the interpreter to call individual
> functions in the target as a human does? For example, I need to run
> certain tests, and print their reports on a printer. I'd like to have a
> program running in the SwiftX compiler that would call target tests and
> report their results on the local printer. With all that can be done
> with your tools I can only guess that I can do it. I just don't know how.

The possibilities are pretty much endless. As Leon mentioned,
"Session log" can capture any required output. And, once you've
connected to the target via [F9], any file you INCLUDE will pretty
much act just like you typed its contents in.

If your target isn't short on resources, you can just write TARGET
words that print whatever your report needs. If your target is
running a little thin, or if you don't want to add "non-production"
code, then you can do something like what's shown below.

This is a snippet from a client's test suite, posted with permission.
Here, we're testing a word -UINT ( c-addr n -- n 0|c-addr ), which
returns an unsigned int from the string and 0, or the address where
conversion failed (it's less "sloppy" than NUMBER, if you were
wondering why it exists.) And, this entire test costs you not one
bit of space on the target. Note the use of .( for string output.

Hope this helps.

\ begin test file

TARGET

MARKER TEST-COMPLETED \ to discard all this after test completes.

INTERPRETER

\ Note that you can write conditional test words in INTERPRETER
\ as needed without consuming target resources. ?DIE runs solely
\ on the PC.
: ?DIE ( flag -- ) ABORT" failed" ;

TARGET

CR .( === Begin verify -UINT ==============) CR

DEPTH ?DIE \ assure we're starting with an empty stack.

.( unsigned decimal ints) CR

S" 0" -UINT 0<> ?DIE
                  0 <> ?DIE
                  DEPTH ?DIE
S" 123" -UINT 0<> ?DIE
                  123 <> ?DIE
                  DEPTH ?DIE
S" 2147483647" -UINT 0<> ?DIE
                  $7FFFFFFF <> ?DIE
                  DEPTH ?DIE
S" 2147483648" -UINT 0<> ?DIE
                  $80000000 <> ?DIE
                  DEPTH ?DIE
S" 4294967295" -UINT 0<> ?DIE
                  $FFFFFFFF <> ?DIE
                  DEPTH ?DIE

\ invalid numbers
S" 123n" -UINT 0= ?DIE
                  DEPTH ?DIE
S" n123" -UINT 0= ?DIE
                  DEPTH ?DIE
S" 12345e78" -UINT 0= ?DIE
                  DEPTH ?DIE
\ overflows 32 bits by 1
S" 4294967296" -UINT 0= ?DIE
                  DEPTH ?DIE

S" -53" -UINT 0= ?DIE \ unsigned!
                  DEPTH ?DIE
S" +7" -UINT 0= ?DIE \ unsigned!
                  DEPTH ?DIE

.( unsigned hex ints) CR HEX

S" 0" -UINT 0<> ?DIE
                  0 <> ?DIE
                  DEPTH ?DIE
S" 1" -UINT 0<> ?DIE
                  1 <> ?DIE
                  DEPTH ?DIE
S" 7FFFFFFF" -UINT 0<> ?DIE
                  $7FFFFFFF <> ?DIE
                  DEPTH ?DIE
S" 80000000" -UINT 0<> ?DIE
                  $80000000 <> ?DIE
                  DEPTH ?DIE
S" FFFFFFFF" -UINT 0<> ?DIE
                  -1 <> ?DIE
                  DEPTH ?DIE

\ invalid numbers
S" 34GF" -UINT 0= ?DIE
                  DEPTH ?DIE
S" 100000000" -UINT 0= ?DIE
                  DEPTH ?DIE

DECIMAL

TEST-COMPLETED

.( === End verify -UINT ================) CR

TARGET
\ End of file

-- 
Ron Oliver <roliver_at_openesque.com>
----------------------------------------------------------------------
swiftx_at_forth.com          The SwiftX programming discussion email list
To unsubscribe,  send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
----------------------------------------------------------------------
THIS LIST IS NOT FOR BUG REPORTS!  Send bug reports to support_at_forth.com.
Received on Tue Jan 21 2003 - 16:46:57 PST

This archive was generated by hypermail 2.2.0 : Fri Dec 05 2008 - 03:04:21 PST