[libvirt] [test-API] Delete the script to generate the testing coverage statistics

Osier Yang jyang at redhat.com
Tue Apr 17 16:23:24 UTC 2012


lib/*.py were destroyed. And there is no way to count the API
coverage now.

---
I tried to write a rough patch to generate the statistics, but
failed. There is no way to detect if the API is covered by the
cases, because the different class can have same methods name,
though I can filter out the APIs for each libvirt object by:

libvirt_module="/usr/lib64/python2.7/site-packages/libvirt.py"

declare -a arr=($(grep -E "class vir[A-Za-z]+:" $libvirt_module | \
    cut -d' ' -f2))

for i in $(seq 0 $((${#arr[@]} - 1))); do
    j=$(($i + 1))
    echo "[ == ${arr[$i]} == ]"
    if [ $j -lt ${#arr[@]} ]; then
        sed -n -e "/${arr[$i]}/,/${arr[$j]}/{/${arr[$j]}/!p}" \
        $libvirt_module | grep '^    def ' | grep -E -v "__del|__init" | \
        sed -e "s/\s*def //g" -e "s/(.*)://g"
    fi
done
---
 utils/stats.sh |   72 --------------------------------------------------------
 1 files changed, 0 insertions(+), 72 deletions(-)
 delete mode 100755 utils/stats.sh

diff --git a/utils/stats.sh b/utils/stats.sh
deleted file mode 100755
index cf2765b..0000000
--- a/utils/stats.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#! /bin/bash
-
-if [ ! -d $(pwd)/coverage ]; then
-  mkdir -p $(pwd)/coverage
-fi
-
-VIRT_STATS_FILE="$(pwd)/coverage/libvirt_API_statistics.txt"
-PYTHON="python$(python -V 2>&1|cut -c 8-10)"
-SUMMARY="coverage/coverage.txt"
-
-if [ $(uname -p) = "x86_64" ]; then
-  export LIB="lib64"
-else
-  export LIB="lib"
-fi
-
-function delimiter()
-{
-    local i=1
-    local separator=$1
-    local line=''
-    while [ $i -le $2 ]
-    do
-        line=${line}${separator}
-        i=$((i+1))
-    done
-    echo "+$line+" | tee -a $SUMMARY
-}
-
-echo
-echo "Generate Libvirt API Statistics Report under the "
-echo "$(pwd)/coverage"
-echo
-delimiter '=' 50
-echo -e "|	Libvirt API statistics of coverage\t   |" | tee -a $SUMMARY
-echo -e "|	  $(date +'%F %T') ($(whoami))\t\t   |" | tee -a $SUMMARY
-delimiter '=' 50
-
-VIRT_PATH="/usr/$LIB/$PYTHON/site-packages/libvirt.py"
-grep 'def ' $VIRT_PATH|grep -v "#"|grep -v "__init__" |grep -v "__del__"|cut -d"(" -f 1 |awk '{print NR, $2}' > $VIRT_STATS_FILE
-
-TOTAL_API_NUM=$(grep 'def ' $VIRT_PATH|grep -v "#"|grep -v "__init__" |grep -v "__del__"|wc -l)
-WRAPPER_API_PATH="$(pwd)/lib/Python"
-WRAPPER_API_NUM=0
-
-for wrapper in connect domain network storage nodedev interface secret nwfilter
-do
-  export EVERY_API_NUM=$(grep 'def ' $WRAPPER_API_PATH/$wrapper'API.py'|grep -v '#'|grep -v '__init__' |grep -v '__del__r'|wc -l)
-  API_NUM=${EVERY_API_NUM}
-  let WRAPPER_API_NUM=$WRAPPER_API_NUM+$API_NUM
-  echo -e "| cover $wrapper API number\t|\t$API_NUM\t   |" | tee -a $SUMMARY
-  if [ $wrapper != "nwfilter" ]; then
-    delimiter '-' 50
-  else
-    continue
-  fi
-done
-
-delimiter '=' 50
-echo -e "| cover libvirt API total number|\t$WRAPPER_API_NUM\t   |" | tee -a $SUMMARY
-delimiter '-' 50
-
-echo -e "| libvirt API real total number\t|\t$TOTAL_API_NUM\t   |" | tee -a $SUMMARY
-delimiter '=' 50
-
-RATE=$(printf "%.0f%%" `echo "scale=2;$WRAPPER_API_NUM/$TOTAL_API_NUM*100"|bc`)
-echo -e "| libvirt API coverage rate\t|\t$RATE\t   |" | tee -a $SUMMARY
-delimiter '=' 50
-
-echo | tee -a $SUMMARY
-
-
-- 
1.7.7.3




More information about the libvir-list mailing list