Remove intrusive useless logging
[csit.git] / resources / libraries / bash / function / device.sh
index 7363dc0..0b1a090 100644 (file)
@@ -108,8 +108,8 @@ function bind_interfaces_to_driver () {
 
 
 function clean_environment () {
-    # Cleanup environment by removing topology containers and binding
-    # interfaces back to original driver.
+    # Cleanup environment by removing topology containers and shared volumes
+    # and binding interfaces back to original driver.
     #
     # Variables read:
     # - DCR_UUIDS - Docker Container UUIDs.
@@ -124,6 +124,12 @@ function clean_environment () {
     # Kill docker containers.
     docker rm --force "${DCR_UUIDS[@]}" || die "Cleanup containers failed!"
 
+    # Check if there are some leftover containers and remove all. Command will
+    # not fail in case there are no containers to remove.
+    docker rm --force $(docker ps -q --filter name=${DCR_UUIDS[dut1]}) || {
+        warn "Failed to remove hanged containers or nothing to remove!"
+    }
+
     # Rebind interfaces back to kernel drivers.
     for ADDR in ${TG_PCIDEVS[@]}; do
         DRIVER="${TG_DRIVERS[0]}"
@@ -251,8 +257,8 @@ function get_available_interfaces () {
             # Add Intel Corporation 82545EM Gigabit Ethernet Controller to the
             # whitelist.
             pci_id="0x100f"
-            tg_netdev=(eth1 eth2)
-            dut1_netdev=(eth3 eth4)
+            tg_netdev=(enpTGa enpTGb)
+            dut1_netdev=(enpSUTa enpSUTb)
             ;;
         *)
             die "Unknown specification: ${case_text}!"
@@ -292,12 +298,26 @@ function get_available_interfaces () {
         fi
     done
 
-    for netdev in "${tg_side[@]::2}"; do
-        TG_NETDEVS+=(${netdev})
-    done
-    for netdev in "${dut1_side[@]::2}"; do
-        DUT1_NETDEVS+=(${netdev})
-    done
+    case "${case_text}" in
+        "1n_skx")
+            # Pick up first two DUT1 interfaces binded to i40evf.
+            for netdev in "${dut1_side[@]::2}"; do
+                DUT1_NETDEVS+=(${netdev})
+            done
+            # Corresponding TG interfaces will be same ID.SUB_ID, but on
+            # opposite linked device.
+            for netdev in "${DUT1_NETDEVS[@]}"; do
+                TG_NETDEVS+=(${netdev/$dut1_netdev/$tg_netdev})
+            done
+            ;;
+        *)
+            for netdev in "${tg_side[@]::2}"; do
+                TG_NETDEVS+=(${netdev})
+            done
+            for netdev in "${dut1_side[@]::2}"; do
+                DUT1_NETDEVS+=(${netdev})
+            done
+    esac
 
     for NETDEV in "${TG_NETDEVS[@]}"; do
         get_pci_addr
@@ -519,6 +539,8 @@ function start_topology_containers () {
     dcr_stc_params+="--volume /dev/vfio:/dev/vfio "
     # Mount nested_vm image to be able to run VM tests.
     dcr_stc_params+="--volume /var/lib/vm/vhost-nested.img:/var/lib/vm/vhost-nested.img "
+    # Mount docker.sock to be able to use docker deamon of the host.
+    dcr_stc_params+="--volume /var/run/docker.sock:/var/run/docker.sock "
 
     # Docker Container UUIDs.
     declare -gA DCR_UUIDS