! Test for a bad nmsf file.
!
! Author:  J. Czechowski IV
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  pipe on
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! Tests for /CMDRUNMODE= (Bug 2922)
    waveform/ID=WAVE0 ram:data elem=1M
    waveform/ID=WAVE1 ram:data elem=1M /CMDRUNMODE=Default
    waveform/ID=WAVE2 ram:data elem=1M /CMDRUNMODE=RunToCompletion
    assert/text="WAVE0 used Default run mode (no switch)"   reg.WAVE0  REXISTS
    assert/text="WAVE1 used Default run mode (with switch)" reg.WAVE1  REXISTS
    assert/text="WAVE2 used RunToCompletion run mode"       reg.WAVE2 NREXISTS
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    res passFail "FAIL"
    invoke pid shell.getnmpid
    if ^{env.NMROOT} EQS "classpath:" AND ^pid eqs "0000" then
       warn "SKIPPING ^reg.main.name PID test in jar:  add -DNMPID=1234 to java command to have this test active."
    else
      assert/text="^reg.main.name: ENV.PID= ^pid" pid neqs "0000"
    endif
    nxm.sys.test.test_shell_slow TIME=10 LABEL=passFail VALUE="PASS"
    assert/text="^reg.main.name: Test to ensure Shell waits for open() to finish" passFail eqss "PASS"
  pipe off

  if baseline AND interAct then
    ! Test can only be run in baseline mode since this tests an error condition

    res inst "Open up a second OS shell and start NeXtMidas in it. (Note: on Solaris machines replace 'dir' with 'ls') \n\n&
              1. From the OS prompt (NOT the nM> prompt), type 'nm dir'. \n   &
                 You should see a directory listing and the prompt should still be &
                 the OS prompt, NOT the nM> prompt.\n\n&
              2. Type 'nm' to get to the nM> prompt. Then type 'dir'. \n   You should see &
                 the same directory listing and the prompt should still be the nM> prompt.\n\n&
              3. Type 'exit' to return to the OS prompt.\n\n&
              4. Type 'nm' to return to the nM> prompt and then type 'home test sys' followed by &
                 '%test_shell_bad_nmsf' that macro will print out further instructions. \n\n&
                 If all the above passed then click PASS in this window. Otherwise click FAIL."

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label macro "MACRO"
      gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
      set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      gcontrol text idtext "INSTRUCTIONS" "^inst" 24 26 /title
    pipe off
  elseif interAct then
    info "SHELL: For additional error condition tests specify /BASELINE"
  endif
endmacro

!**************************************************************************************************!
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Test for shell with bad NMSF file" msg.data eqss "PASS"
    pipe stop
  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return