March 29, 2018

TC stage and status can now be compared numerically

CCS5
TSC

It is now possible to compare TC stages and states numerically.This can be useful to check when a TC has reached a stage or state “greater than or equal” to an expected one.
It allows you to write TOPE scripts that can efficiently detect when a stage or state has passed before you checked it.

Previously we had:
getstatus – returns the “string” status a TC has reached (e.g. PASSED)
getstage – returns the “string” stage a TC has reached (e.g. MCS_RELEASE)

Now we have
getstatus – as before
getstage – as before
getstateid – gives the numeric representation of the TC status
getstageid – gives the numeric representation of the TC stage

The latter can be compared as numbers, e.g.

waitfor ::TC -timeout 30 -until {[getstageid $::TC] >= $::TC::stageId(MCS_RELEASE)}

The stage/state mappings are accessible as follows:

::TC::stageName maps long stage name e.g. MCS_RELEASE to the short code, e.g. R
::TC::stageId maps the long stage name to the number
::TC::stageCode maps the number to the stage name

::TC::stateCode maps the long state name e.g. PASSED to the short code, e.g. S
::TC::stateId maps the long state name to the number
::TC::stateName maps the number to the state name

Note that if your scripts directly access the contents of TC updates, then you will find that the contents are now different, being numbers instead of strings. You are recommended to always use the provided “get” functions to access these referby variables.