aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/storage/fio_benchmark.bash
blob: 2ef7f4949b8edabd78cbf8a4bd3196840eb59b48 (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
#!/bin/sh

##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

set -e

# Commandline arguments
FIO_FILENAME=$1
shift
OPTIONS="$@"

# setup data file for fio
setup()
{
    if [ ! -f $FIO_FILENAME ]; then
        dd if=/dev/zero of=$FIO_FILENAME bs=1M count=1024 oflag=direct > /dev/null 2>&1
    fi
}

# run fio test and write json format result to stdout
run_test()
{
    fio $OPTIONS
}

# main entry
main()
{
    # setup the test
    setup

    # run the test
    run_test
}

main