#!/bin/bash # $HeadURL$ $LastChangedRevision$ # Note this error message is sent to the terminal as it is imperative the user understands the failure. [ $(id -u) = 0 ] || { echo "${0##*/}: this test can only pass when run as root" >/dev/tty; exit 1; } echo "setting up environment ..." export JS_NAME=$(tr -dc A-Za-z0-9 &1 | sed -r -e 's/.*[Kk]illed.*/KILLED/' -e '/child processes \([1-9][0-9, ]*\) are still running/d' | sort -u & JSD_PID=$! sleep 5 # settle time #echo "submitting a blocking job and letting it start ..." #jss -r mem:$MAX_MEM,slots:1 "sleep 10" > /dev/null #sleep 2 #jsq echo "submitting jobs restricted to progressively less and less memory ..." MEM=$MAX_MEM while :; do # We use 'od' rather than 'dd' because od can output hex without needing # '... | base64', which means that it's exit code can be caught be the # while loop, which in turn means that the job can detect when, not it, # but *od* gets OOM-killed. (With 'dd | bash64' the while loop keeps # looping because the OOM killer only kills a *single* process, not the # entire cgroup. # # Note that we choose not to put an echo after all the 'echo -n's: this # helps ensure that each job produces precisely one line of output which # makes it easier to grep out acceptable lines, which, even when # successful vary quite a lot in format. jss -r mem:$MEM,slots:1 "error() { echo \"\$JS_JOB_ID: ERROR: \$1\" >&2; exit 1; }; echo -n \"\${JS_MEM_LIMIT}KB: \"; BLOBS=(); while BLOBS[\${#BLOBS[*]}]=\"\$(od -A n -N1M -t x8 < /dev/urandom)\"; do echo -n '.'; done; error \"od got killed; exiting ...\"" > /dev/null [ $MEM != 1 ] || break ((MEM/=2)) done #jsq echo "waiting for jobs to complete ..." jsc resume wait_for_jobs #while [ $(jsq | egrep -c '^[0-9]+ +(running|pending)') != 0 ]; do # sleep 5 #done echo "cleaning up ..." jsc quit wait $JSD_PID echo "all done"