!******************************************************************************!
! Starter test for SOURCESDDS
!
! @bug      NXM-3919 unable to run sourcesdds to remove/strip SDDS packet headers
! @since    4.1.2
! @author:  Jeanette McCall
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  waveform ram:sbdata sb
  sinksdds ram:sbdata ram:sddspackets
  sourcesdds ram:sddspackets ram:dataonly
  sourcesdds ram:sddspackets ram:datapluspacket /STRIP=n
  key ram:dataonly GET NAME=PACKET VALUE=nopacketval
  key ram:datapluspacket GET NAME=PACKET VALUE=packetval
  assert/text="^reg.main.name: /STRIP=y does not have PACKET keyword" nopacketval ISNULL
  assert/text="^reg.main.name: /STRIP=n has PACKET keyword with value SDDS" packetval eqss "SDDS"
  assert/text="^reg.main.name: /STRIP=y has correct data" ram:dataonly FEQ/D sbdata
  assert/text="^reg.main.name: /STRIP=n has correct data" ram:datapluspacket FEQ/D sbdata

endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
res msg.name
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return