pastebin - collaborative debugging tool
rovema.kpaste.net RSS


statistics rds test script for Phase4
Posted by Anonymous on Tue 14th Sep 2021 13:53
raw | new post
view followups (newest first): statistics rds test script for Phase4 by Anonymous

  1. #!/usr/bin/ksh93
  2. # needs ksh93 for floating-point math in $((...))
  3.  
  4. set -o errexit
  5. set -o xtrace
  6.  
  7. #
  8. # prechecks
  9. #
  10. [[ -x '/opt/rovema/rds/start' ]] || exit 1
  11.  
  12. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rovema/lib
  13. modprobe -f simatic_ipc_nvram
  14. ulimit -c unlimited
  15.  
  16. # variables for the test runs
  17.  
  18. compound c=(
  19.         typeset -r rds_output_logfile='mylog.log'
  20.  
  21.         integer rds_pid=-1
  22.         float   rds_starttime
  23.         float   rds_stoptime
  24.         integer i
  25.         integer runs_failed=0
  26.         integer runs_ok=0
  27. )
  28.  
  29. typeset s
  30. integer x
  31.  
  32. trap "print -v c" INT
  33.  
  34. cd '/opt/rovema/rds/'
  35.  
  36. # rds success output: "transferDataOfPhase '4' with bReady = 1"
  37. # rds waiting for input "Input:"
  38. # rds failed to switch to phase 4: "Error during switching to CP4 in startup"
  39.  
  40. for (( c.i=0 ; c.i < 4 ; c.i++ )) ; do
  41.         ./rds -dl 7 >"${c.rds_output_logfile}" 2>&1     &
  42.         (( c.rds_pid=$! ))
  43.         (( c.rds_starttime = SECONDS ))
  44.        
  45.         for (( x=10 ; x > 0 ; x-- )) ; do
  46.                 sleep 6
  47.  
  48.                 s="$( <"${c.rds_output_logfile}" )"
  49.                
  50.                 if [[ "$s" == *"Input:"* ]] ; then
  51.                         printf $"Rds ready for input\n"
  52.                         (( x=0 ))
  53.                 fi
  54.                 if [[ "$s" == *"transferDataOfPhase '4' with bReady = 1"* ]] ; then
  55.                         printf $"Success: phase 4 reached\n"
  56.                         (( c.runs_ok++ ))
  57.                         (( x=0 ))
  58.                 fi
  59.                 if [[ "$s" == ~(E)(Error\ during.+to\ CP4) ]] ; then
  60.                         printf $"Failure: phase 4 not reached\n"
  61.                         (( c.runs_failed++ ))
  62.                         (( x=0 ))
  63.                 fi
  64.         done
  65.  
  66.        
  67.         #
  68.         # wait 20 seconds for process to finish with SIGINT
  69.         # and send him a SIGKILL when it refuses to obey
  70.         #
  71.         kill -s INT ${c.rds_pid}
  72.         for (( x=10 ; x > 0 ; x-- )) ; do
  73.                 sleep 2
  74.                 [[ ! -d "/proc/${c.rds_pid}/fd" ]] && break
  75.         done
  76.         [[ -d "/proc/${c.rds_pid}/fd" ]] && kill -s KILL ${c.rds_pid}
  77.         wait
  78.  
  79.  
  80.         # print statistics
  81.         printf $"#### Statistics:\n"
  82.         print -v c
  83.  
  84.         sleep 2
  85. done
  86.  
  87. #
  88. # done
  89. #
  90. printf $"#\n#Done:\n#\n"
  91. print -v c
  92.  
  93. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at