3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
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 ##############################################################################
14 # Commandline arguments
17 OUTPUT_FILE=/tmp/netperf-out.log
22 netperf $OPTIONS > $OUTPUT_FILE
25 # write the result to stdout in json format
30 read -r -a ARR <<< "$OPTIONS"
32 while [ $opt_size -lt "$OPTIONS_SIZE" ]
34 if [ "${ARR[$opt_size]}" = "-O" ]
38 opt_size=$((opt_size+1))
40 opt_size=$((opt_size+1))
41 out_opt="${ARR[$opt_size]}"
42 IFS=, read -r -a PARTS <<< "$out_opt"
46 for f in "${PARTS[@]}"
48 array_name[$tran_num]=$(echo "$f" | tr '[A-Z]' '[a-z]')
49 tran_num=$((tran_num+1))
51 read -r -a DATA_PARTS <<< "$(sed -n '$p' $OUTPUT_FILE)"
53 for((i=0;i<part_num-1;i++))
55 modify_str=\"${array_name[i]}\":\"${DATA_PARTS[i]}\",
56 out_str=$out_str$modify_str
58 modify_str=\"${array_name[part_num-1]}\":\"${DATA_PARTS[part_num-1]}\"
59 out_str=$out_str$modify_str"}"