Support run cyclictest on BareMetal
[yardstick.git] / yardstick / benchmark / scenarios / compute / cyclictest_benchmark.bash
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 set -e
13
14 # Commandline arguments
15 OPTIONS="$@"
16 OUTPUT_FILE=/tmp/cyclictest-out.log
17
18 # run cyclictest test
19 run_cyclictest()
20 {
21     cyclictest $OPTIONS > $OUTPUT_FILE
22 }
23
24 # write the result to stdout in json format
25 output_json()
26 {
27     min=$(awk '/# Min Latencies:/{print $4}' $OUTPUT_FILE)
28     avg=$(awk '/# Avg Latencies:/{print $4}' $OUTPUT_FILE)
29     max=$(awk '/# Max Latencies:/{print $4}' $OUTPUT_FILE)
30     echo -e "{ \
31         \"min\":\"$min\", \
32         \"avg\":\"$avg\", \
33         \"max\":\"$max\" \
34     }"
35 }
36
37 # main entry
38 main()
39 {
40     # run the test
41     run_cyclictest
42
43     # output result
44     output_json
45 }
46
47 main
48