pastebin - collaborative debugging tool
rovema.kpaste.net RSS


multitorture1.ksh - torture system with many many parallel processes
Posted by Anonymous on Wed 26th Jul 2023 14:37
raw | new post

  1. #!/bin/ksh93
  2.  
  3. #
  4. # multitorture1.ksh - torture system with many many parallel processes
  5. #
  6. # Used to trigger MCE errors on specific hardware
  7. #
  8.  
  9. function dmesg_count_mces
  10. {
  11.         nameref c=$1
  12.        
  13.         c.msgs="${ dmesg | fgrep 'mce:' ; }"
  14.  
  15.         c.count=${ wc -l <<<"${c.msgs}" ; }
  16.         return 0
  17. }
  18.  
  19. #
  20. # compound variable to store filtered dmesg(1) output and
  21. # statistics/counts
  22. #
  23. compound dmsg_mces=(
  24.         compound before=(
  25.                 typeset msgs
  26.                 integer count
  27.         )
  28.         compound after=(
  29.                 typeset msgs
  30.                 integer count
  31.         )
  32. )
  33.  
  34. #
  35. # main
  36. #
  37. export PATH='/bin:/usr/bin'
  38.  
  39. builtin cat
  40. builtin wc
  41.  
  42. typeset x
  43. integer i j
  44.  
  45.  
  46. set -o bgnice # background jobs will be nice'ed
  47.  
  48. printf $"# Start.\n"
  49.  
  50. #
  51. # get a horribly large string
  52. #
  53. x="$( for ((i=0 ; i < 60000 ; i++)) ; do printf "%d\n" i; done )"
  54.  
  55. dmesg_count_mces dmsg_mces.before
  56.  
  57. for ((j=0 ; j < 50 ; j++)) ; do
  58.         printf $"\n# Starting child processes (cycle %d) ...\n" j
  59.         for ((i=0 ; i < 100 ; i++)) ; do
  60.                 {
  61.                         printf '.'
  62.                         # sleep, so parent process has enough time
  63.                         # to |fork()| the other children
  64.                         sleep 5
  65.  
  66.                         #
  67.                         # torture!!
  68.                         #
  69.                         sort <<<"$x" | \
  70.                                 sort -r | \
  71.                                 sort | \
  72.                                 sort -r -n | \
  73.                                 sort -n | \
  74.                                 sort -u | openssl sha512
  75.                 } &
  76.         done
  77.         sleep 3
  78.         printf '\n'
  79.  
  80.         # wait until all children are done
  81.         wait
  82.  
  83.         dmesg_count_mces dmsg_mces.after
  84.  
  85.         if (( dmsg_mces.after.count > dmsg_mces.before.count )) ; then
  86.                 printf $"# Congratulations: You have new mce entries in dmesg (\u[2620]) after %d cycles\n" j
  87.                 diff -u <( cat <<<"${dmsg_mces.before.msgs}" ) <( cat <<<"${dmsg_mces.after.msgs}" )
  88.                 break
  89.         fi
  90. done
  91.  
  92. printf $"# Done.\n"
  93. exit 0
  94. # 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