114 lines
2.3 KiB
Plaintext
114 lines
2.3 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: Example test case for Unittests
|
|
; @Description:
|
|
; This is an example for a test case which can be executed with lbunit.cmm.
|
|
; @Keywords: lbtest test case
|
|
; @Author: MOB
|
|
; @Copyright: (C) 1989-2015 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Id: test_example.cmm 8648 2015-09-03 17:04:05Z mobermeir $
|
|
|
|
; the following block must be present in the beginning of every test case
|
|
PRIVATE &func &args &result
|
|
ENTRY &func %LINE &args
|
|
GOSUB &func &args // call subroutine and return result
|
|
ENTRY %LINE &result
|
|
ENDDO &result
|
|
; end of mandatory block
|
|
|
|
; SetupTestCase will be called once at the beginning of the test case
|
|
; It can be removed if it is not needed.
|
|
SetupTestCase:
|
|
(
|
|
PRIVATE &date
|
|
&date=DATE.DATE()+" "+DATE.TIME()
|
|
PUTS "test case started at: &date"
|
|
RETURN
|
|
)
|
|
|
|
; SetupTest will be called just before every test
|
|
; It can be removed if it is not needed.
|
|
SetupTest:
|
|
(
|
|
; here can be some setup
|
|
Data.Set VM:0x0--0xFF 0xA
|
|
RETURN
|
|
)
|
|
|
|
; All tests must start with "Test_"
|
|
Test_MyFirstTest:
|
|
(
|
|
; Assertions can be used:
|
|
A_FALSE FALSE()
|
|
A_TRUE (1.+1.==2.)
|
|
RETURN
|
|
)
|
|
|
|
Test_MySecondTest:
|
|
(
|
|
A_NUM_EQ 0xA Data.Byte(VM:0x0)
|
|
A_X_PASS Data.Set VM:0x0 0xB
|
|
A_NUM_EQ 0xB Data.Byte(VM:0x0)
|
|
RETURN
|
|
)
|
|
|
|
Test_MyThirdTest:
|
|
(
|
|
; Tests can return "PASS", "FAIL" or "NOT_EXEC"
|
|
; (alternatively or in addition to assertions)
|
|
IF (0xA!=Data.Byte(VM:0x0))
|
|
(
|
|
RETURN "FAIL"
|
|
)
|
|
ELSE IF (0xB==Data.Byte(VM:0x0))
|
|
(
|
|
RETURN "NOT_EXEC"
|
|
)
|
|
ELSE
|
|
(
|
|
RETURN "PASS"
|
|
)
|
|
RETURN // same as "PASS"
|
|
)
|
|
|
|
MyHelper:
|
|
(
|
|
A_NUM_EQ 0xA Data.Byte(VM:0x10)
|
|
RETURN
|
|
)
|
|
|
|
Test_MyFourthTest:
|
|
(
|
|
; tests can call helper functions
|
|
RePeaT 2.
|
|
(
|
|
GOSUB MyHelper
|
|
)
|
|
RETURN
|
|
)
|
|
|
|
DisabledTest_MyFifthTest:
|
|
(
|
|
; this routine will not be executed since it doesn't start with "Test_"
|
|
RETURN
|
|
)
|
|
|
|
; TearDownTest will be called just after every test
|
|
; It can be removed if it is not needed.
|
|
TearDownTest:
|
|
(
|
|
; here could be some cleanup
|
|
Break.RESet
|
|
RETURN
|
|
)
|
|
|
|
; TearDownTestCase will be called once at the end of the test case
|
|
; It can be removed if it is not needed.
|
|
TearDownTestCase:
|
|
(
|
|
PRIVATE &date
|
|
&date=DATE.DATE()+" "+DATE.TIME()
|
|
PUTS "test case ended at: &date"
|
|
RETURN
|
|
)
|