#!/bin/sh _root="$(dirname "${0}")"; . "${_root}/lib/sh/env.sh" want log suexec [ "$(hostname -s)" = "nabihinew" ] || wtf "Run this on nabihinew only!" suexec "${0}" "${@}" want stopwatch # Environment and needed stuff tests="${_root}/tests" # Log maintenance logs="${_root}/log" [ -d "${logs}" ] || mkdir -p "${logs}" run_log="${logs}/bench-$(date +%Y-%m-%d_%H:%M:%S).log" # Scratch directory maintenance scratch="/bonnie" clean_scratch() { [ -d "${scratch}" ] || mkdir -p "${scratch}" mount | grep -q ' on '"${scratch}"' ' && umount "${scratch}" || true find "${scratch}" -uid "${bonnie_uid}" -xdev -delete } clean_scratch # Bonnie setup bonnie_uid="4444" bonnie_opts="-q -d /bonnie -u ${bonnie_uid} -s 12288 -n 16:16384:0 -f 0" bonnie_log="${logs}/bonnie-%s-$(date +%Y-%m-%d_%H:%M:%S).csv" run_bonnie() { chown "${bonnie_uid}" "${scratch}" /usr/local/sbin/bonnie++ ${bonnie_opts} -m "${test}" >> "$(printf "${bonnie_log}" "${test}")" } # Default methods setup() { clean_scratch } run() { run_bonnie } teardown() { clean_scratch } # Main event if [ "${#}" -eq 0 ] then log "Considering tests: $(cd "${tests}"; echo *)" | tee -a "${run_log}" script -a "${run_log}" sh -c "( cd '${tests}'; ls -1 ) | xargs -L1 '${0}'" else test="${1}"; shift testfile="${tests}/${test}" [ -f "${testfile}" ] || wtf "Test '${test}' does not exist" ( log "Preparing test: ${test}" . "${testfile}" setup sync log "$(stopwatch run start)" run; result=$? log "$(stopwatch run stop) Test result ${result}" teardown ) fi