blob: a09e750e270721f21a980e0fd8979da6301ee522 [file] [log] [blame]
Chase Qibe6a4b52016-11-04 18:38:30 +08001#!/bin/sh -e
2
3. ../../lib/sh-test-lib
4OUTPUT="$(pwd)/output"
5RESULT_FILE="${OUTPUT}/result.txt"
6LOG_FILE="${OUTPUT}/blogbench.txt"
7ITERATION="30"
8PARTITION=""
9
10usage() {
11 echo "Usage: $0 [-i <iterations>] [-p </dev/sda1>]" 1>&2
12 exit 1
13}
14
15while getopts "i:p:h" o; do
16 case "$o" in
17 i) ITERATION="${OPTARG}" ;;
18 p) PARTITION="${OPTARG}" ;;
19 h|*) usage ;;
20 esac
21done
22
23! check_root && error_msg "You need to be root to run this script."
Daniel Díaz6f49a1b2017-02-15 18:56:15 -060024create_out_dir "${OUTPUT}"
Chase Qibe6a4b52016-11-04 18:38:30 +080025
26# Set the directory for blogbench test.
27if [ -n "${PARTITION}" ]; then
28 if mount | grep -q "${PARTITION}"; then
29 mount "${PARTITION}" /mnt
30 cd /mnt/
31 else
32 mount_point=$(mount | grep "${PARTITION}" | awk '{print $3}')
33 cd "${mount_point}"
34 fi
35fi
36mkdir ./bench
37
38# Run blogbench test.
39detect_abi
40# shellcheck disable=SC2154
41./bin/"${abi}"/blogbench -i "${ITERATION}" -d ./bench 2>&1 | tee "${LOG_FILE}"
42
43# Parse test result.
44for i in writes reads; do
45 grep "Final score for $i" "${LOG_FILE}" \
46 | awk -v i="$i" '{printf("blogbench-%s pass %s blogs\n", i, $NF)}' \
47 | tee -a "${RESULT_FILE}"
48done
49
50rm -rf ./bench