- #!/usr/bin/ksh93
- # needs ksh93 for floating-point math in $((...))
- function isvalidpid
- {
- integer pid=$1
- # POSIX uses $ kill -0 ... # to check whether the pid is valid
- if kill -0 $pid 2>'/dev/null' ; then
- return 0
- else
- return 1
- fi
- }
- function test_cycle
- {
- typeset s
- integer x
- nameref tc=$1
- cd '/opt/rovema/rds/' || return 1
- tc.rds_output_logfile="rds_statistics_myrdslog_${tc.i}.log"
- rm -f "${tc.rds_output_logfile}"
- ./rds -dl 7 >"${tc.rds_output_logfile}" 2>&1 &
- (( tc.rds_pid=$! ))
- (( tc.rds_starttime=SECONDS, tc.rds_stoptime=0 ))
- for (( x=20 ; x > 0 ; x-- )) ; do
- sleep 3
- s="$( <"${tc.rds_output_logfile}" )"
- #
- # parse output:
- # rds success output: "transferDataOfPhase '4' with bReady = 1"
- # rds waiting for input "Input:"
- # rds failed to switch to phase 4: "Error during switching to CP4 in startup"
- #
- if [[ "$s" == *"Input:"* ]] ; then
- printf $"Rds ready for input\n"
- (( x=0 ))
- fi
- if [[ "$s" == *"transferDataOfPhase '4' with bReady = 1"* ]] ; then
- printf $"Success: phase 4 reached\n"
- (( tc.runs_ok++ ))
- (( x=0 ))
- fi
- if [[ "$s" == ~(E)(Error\ during.+to\ CP4) ]] ; then
- printf $"Failure: phase 4 not reached\n"
- (( tc.runs_failed++ ))
- (( x=0 ))
- # log last twenty lines of output if we failed
- tc.output_of_failed_runs[tc.i]="$( tail -n 20 <<<"$s" )"
- fi
- done
- #
- # wait 20 seconds for process to finish with SIGINT
- # and send him a SIGKILL when it refuses to obey
- #
- kill -s INT ${tc.rds_pid}
- for (( x=10 ; x > 0 ; x-- )) ; do
- sleep 2
- isvalidpid ${tc.rds_pid} || break
- done
- isvalidpid ${tc.rds_pid} && kill -s KILL ${tc.rds_pid}
- wait
- (( tc.rds_pid=-1 ))
- (( tc.rds_stoptime=SECONDS ))
- (( tc.rds_runtime=tc.rds_stoptime-tc.rds_starttime ))
- return 0
- }
- function main
- {
- # variables for the test runs
- compound c=(
- typeset rds_output_logfile
- integer rds_pid=-1
- float rds_starttime
- float rds_stoptime
- float rds_runtime
- integer i
- integer runs_failed=0
- integer runs_ok=0
- typeset -a output_of_failed_runs
- )
- set -o errexit
- set -o xtrace
- #
- # prechecks
- #
- [[ -x '/opt/rovema/rds/start' ]] || return 1
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rovema/lib
- modprobe -f simatic_ipc_nvram
- ulimit -c unlimited
- #
- # test loop
- #
- for (( c.i=0 ; c.i < 30 ; c.i++ )) ; do
- test_cycle c
- # print statistics
- printf $"#### Statistics:\n"
- print -v c
- sleep 2
- done
- #
- # done
- #
- printf $"#\n#Done:\n#\n"
- print -v c
- return 0
- }
- main "$@"
- # EOF.
statistics rds test script for Phase4
Posted by Anonymous on Mon 20th Sep 2021 09:16
raw | new post
view followups (newest first): statistics rds test script for Phase4 by Anonymous
modification of post by Anonymous (view diff)
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.