Merge "NSB Topology fix for Prox 4 port test case"
[yardstick.git] / yardstick / benchmark / scenarios / networking / netperf_benchmark.bash
index a425c5d..f6245c9 100755 (executable)
@@ -12,6 +12,7 @@
 set -e
 
 # Commandline arguments
+OPTIONS_SIZE="$#"
 OPTIONS="$@"
 OUTPUT_FILE=/tmp/netperf-out.log
 
@@ -24,14 +25,40 @@ run_netperf()
 # write the result to stdout in json format
 output_json()
 {
-    mean=$(awk '/\/s/{print $3}' $OUTPUT_FILE)
-    troughput=$(awk '/\/s/{print $1}' $OUTPUT_FILE)
-    unit=$(awk '/\/s/{print $2}' $OUTPUT_FILE)
-    echo -e "{ \
-        \"mean_latency\":\"$mean\", \
-        \"troughput\":\"$troughput\", \
-        \"troughput_unit\":\"$unit\" \
-    }"
+    #ARR=($OPTIONS)
+    #declare -p ARR
+    read -r -a ARR <<< "$OPTIONS"
+    opt_size=0
+    while [ $opt_size -lt "$OPTIONS_SIZE" ]
+    do
+        if [ "${ARR[$opt_size]}" = "-O" ]
+        then
+            break
+        fi
+        opt_size=$((opt_size+1))
+    done
+    opt_size=$((opt_size+1))
+    out_opt="${ARR[$opt_size]}"
+    IFS=, read -r -a PARTS <<< "$out_opt"
+    #declare -p PARTS
+    part_num=${#PARTS[*]}
+    tran_num=0
+    for f in "${PARTS[@]}"
+    do
+        array_name[$tran_num]=$(echo "$f" | tr '[A-Z]' '[a-z]')
+        tran_num=$((tran_num+1))
+    done
+    read -r -a DATA_PARTS <<< "$(sed -n '$p' $OUTPUT_FILE)"
+    out_str="{"
+    for((i=0;i<part_num-1;i++))
+    do
+        modify_str=\"${array_name[i]}\":\"${DATA_PARTS[i]}\",
+        out_str=$out_str$modify_str
+    done
+    modify_str=\"${array_name[part_num-1]}\":\"${DATA_PARTS[part_num-1]}\"
+    out_str=$out_str$modify_str"}"
+
+    echo -e "$out_str"
 }
 
 # main entry
@@ -44,4 +71,4 @@ main()
     output_json
 }
 
-main
\ No newline at end of file
+main