summaryrefslogtreecommitdiff
path: root/automated/linux/iozone/iozone.sh
blob: 6c9c005fb08b8c075d54f45d94b3e5593d26eae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh -ex
# shellcheck disable=SC1090
# shellcheck disable=SC2154

TEST_DIR=$(dirname "$(realpath "$0")")
OUTPUT="${TEST_DIR}/output"
LOGFILE="${OUTPUT}/iozone-stdout.txt"
RESULT_FILE="${OUTPUT}/result.txt"

SKIP_INSTALL="false"
VERSION="3_458"

usage() {
    echo "Usage: $0 [-s <skip_install>] [-v <version>]" 1>&2
    exit 1
}

while getopts "s:v:h" opt; do
    case "$opt" in
        s) SKIP_INSTALL="${OPTARG}" ;;
        v) VERSION="${OPTARG}" ;;
        *) usage ;;
    esac
done

. "${TEST_DIR}/../../lib/sh-test-lib"
create_out_dir "${OUTPUT}"
cd "${OUTPUT}"

if [ "$SKIP_INSTALL" = 'true' ] || [ "$SKIP_INSTALL" = 'True' ]; then
    warn_msg "Dependencies and iozone installation skipped!"
else
    install_deps "wget gcc make"
    # Download, compile and install iozone.
    wget "http://www.iozone.org/src/stable/iozone${VERSION}.tar"
    tar xf "iozone${VERSION}.tar"
    cd "iozone${VERSION}/src/current"
    detect_abi
    case "$abi" in
        armeabi|arm64) make linux-arm ;;
        x86_64) make linux ;;
        *) warn_msg "Unsupported architecture" ;;
    esac
    export PATH=$PWD:$PATH
fi

which iozone || error_msg "'iozone' not found, exiting..."
# -a: Auto mode
# -I: Use VxFS VX_DIRECT, O_DIRECT,or O_DIRECTIO for all file operations
iozone -a -I | tee "$LOGFILE"

# Parse iozone stdout.
field_number=3
for test in "write" "rewrite" "read" "reread" "random-read" "random-write" "bkwd-read" \
    "record-rewrite" "stride-read" "fwrite" "frewrite" "fread" "freread"; do
    awk "/kB  reclen/{flag=1; next} /iozone test complete/{flag=0} flag" "$LOGFILE"  \
        | sed '/^$/d' \
        | awk -v tc="$test" -v field_number="$field_number" \
            '{printf("%s-%skB-%sreclen pass %s kBytes/sec\n",tc,$1,$2,$field_number)}' \
        | tee -a "$RESULT_FILE"
    field_number=$(( field_number + 1 ))
done