X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=dpdk-tests%2Fdpdk_scripts%2Fcleanup_dpdk.sh;h=7961a5b40fec52a7183a0536aee38b076b97f5d9;hp=c4d0828ac15f50aefe6a5f243cc8ac81e51f6ab6;hb=44270521c22729cf6d58ea63ba6ddd1aa535b1c5;hpb=6dd47ed60a15c9f4c86d095844839610783a8393 diff --git a/dpdk-tests/dpdk_scripts/cleanup_dpdk.sh b/dpdk-tests/dpdk_scripts/cleanup_dpdk.sh index c4d0828ac1..7961a5b40f 100755 --- a/dpdk-tests/dpdk_scripts/cleanup_dpdk.sh +++ b/dpdk-tests/dpdk_scripts/cleanup_dpdk.sh @@ -1,54 +1,63 @@ #!/bin/bash +set -x + +# Setting variables +DPDK_VERSION=dpdk-17.02 ROOTDIR=/tmp/openvpp-testing +TESTPMDLOG=screenlog.0 PWDDIR=$(pwd) -TESTPMD_LOG=/tmp/testpmd.log -TESTPMD_PID=/tmp/testpmd.pid - +# Setting command line arguments port1_driver=$1 port1_pci=$2 port2_driver=$3 port2_pci=$4 -#kill the dpdk application +# Try to kill the testpmd sudo pgrep testpmd if [ $? -eq "0" ]; then success=false - sudo pkill tail sudo pkill testpmd + echo "RC = $?" for attempt in {1..5}; do + echo "Checking if testpmd is still alive, attempt nr ${attempt}" sudo pgrep testpmd if [ $? -eq "1" ]; then + echo "testpmd is dead" success=true break fi + echo "testpmd is still alive, waiting 1 second" sleep 1 done if [ "$success" = false ]; then echo "The command sudo pkill testpmd failed" + sudo pkill -9 testpmd + echo "RC = $?" exit 1 fi - cat ${TESTPMD_LOG} +else + echo "testpmd is not running" fi -sudo rm -f ${TESTPMD_LOG} -sudo rm -f ${TESTPMD_PID} +# Remove hugepages sudo rm -f /dev/hugepages/* -cd ${ROOTDIR}/dpdk-16.07/ -./tools/dpdk-devbind.py -b ${port1_driver} ${port1_pci} -./tools/dpdk-devbind.py -b ${port2_driver} ${port2_pci} +# Unbind interfaces +cd ${ROOTDIR}/${DPDK_VERSION}/ +sudo ./usertools/dpdk-devbind.py -b ${port1_driver} ${port1_pci} || \ + { echo "Unbind ${port1_pci} failed"; exit 1; } +sudo ./usertools/dpdk-devbind.py -b ${port2_driver} ${port2_pci} || \ + { echo "Unbind ${port1_pci} failed"; exit 1; } sleep 2 -if1_name=`./tools/dpdk-devbind.py --s | grep "${port1_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'` -if2_name=`./tools/dpdk-devbind.py --s | grep "${port2_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'` - -ifconfig ${if1_name} up -ifconfig ${if2_name} up +if1_name=`./usertools/dpdk-devbind.py --s | grep "${port1_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'` +if2_name=`./usertools/dpdk-devbind.py --s | grep "${port2_pci}" | sed -n 's/.*if=\(\S\)/\1/p' | awk -F' ' '{print $1}'` -rmmod igb_uio -rmmod uio +# Remove igb_uio driver +rmmod igb_uio || \ + { echo "Removing igb_uio failed"; exit 1; } -cd ${PWDDIR} +cd ${PWDDIR} \ No newline at end of file