- #!/bin/ksh93
- #
- # fstest_make_numtree1.ksh93 - filesystem stress test using parallel makefile
- #
- # The script builds a makefile to generate number sequence
- # The resulting Makefile is intended to be used with
- # $ bmake -j128 all # as filesystem test
- #
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- function genmakefile_make_number_seq
- {
- set -o nounset
- nameref out_maketarget=$1
- integer start_i=$2
- integer stop_i=$3
- typeset payload=$4
- integer i
- typeset -a make_targets
- if (( (stop_i - start_i) > 10 )) ; then
- (( i=(stop_i - start_i)/2 ))
- genmakefile_make_number_seq make_targets[0] $start_i $(( start_i+i )) "$payload"
- genmakefile_make_number_seq make_targets[1] $(( start_i+i )) $stop_i "$payload"
- else
- for ((i=start_i ; i < stop_i ; i++ )) ; do
- printf 'i_%d:\n' i
- printf '\t@printf "%d\\t%s\\n" >"i_%d"\n' i "$payload" i
- make_targets+=( "i_$i" )
- done
- fi
- out_maketarget="i_${start_i}_${stop_i}"
- printf 'i_%d_%d: %s\n' start_i stop_i "${make_targets[*]}"
- printf '\tcat '
- printf '%q ' "${make_targets[@]}"
- printf ' >"%s"\n' "$out_maketarget"
- return 0
- }
- function genmakefile
- {
- set -o nounset
- typeset make_target
- integer max_num=$1
- typeset string_payload=$2
- genmakefile_make_number_seq make_target 0 ${max_num} "${string_payload}"
- printf 'all: %s\n' "$make_target"
- return 0
- }
- function main
- {
- set -o nounset
- typeset cmd="$1"
- #
- # config
- #
- # max number of iterations
- integer max_num=2000
- # 4096 bytes of payload
- typeset string_payload="$(
- integer p ;
- for ((p=0 ; p < 4096 ; p++ )) ; do
- printf '%x' $((p%0x10)) ;
- done)"
- #
- # We need BSD make, as GNU make -j128 somehow does not
- # yield parallism
- #
- if [[ "$(which bmake 2>'/dev/null')" == '' ]] ; then
- print -u2 -f $"%s: bmake required\n" "${.sh.file}"
- return 1
- fi
- case "$cmd" in
- 'generate')
- set -o xtrace
- genmakefile ${max_num} "${string_payload}" >"make_numtree1.Makefile"
- set +o xtrace
- ;;
- 'run')
- set -o xtrace
- time bmake -j128 -f "make_numtree1.Makefile" all
- set +o xtrace
- ;;
- 'clean')
- set -o xtrace
- rm -- i_*
- rm -- "make_numtree1.Makefile"
- set +o xtrace
- ;;
- # all-in-one
- 'all')
- set -o xtrace
- (
- set -o errexit
- rm -- i_*
- rm -- "make_numtree1.Makefile"
- genmakefile ${max_num} "${string_payload}" >"make_numtree1.Makefile"
- time bmake -j32 -f "make_numtree1.Makefile" all
- ls -l "i_0_${max_num}"
- diff -u <(awk '{ print $1 }' "i_0_${max_num}") <(seq 0 $(( max_num )))
- set +o xtrace
- )
- return $?
- ;;
- *)
- print -u2 -f \
- $"%s: Unknown subcmd, supported are 'generate', 'run', 'clean', 'all'\n" "${.sh.file}"
- return 1
- ;;
- esac
- return 0
- }
- builtin printf
- main "$@"
- # EOF.
fstest_make_numtree1.ksh93 - filesystem stress test using parallel makefile
Posted by Anonymous on Fri 19th Jul 2024 12:06
raw | new post
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.