diff --git a/tests/test_apt.sh b/tests/test_apt.sh
index 2cb193f278f02e49c8431d03518054dfff4e9163..8c3d15820692dba27d91be53f1cb82914baefe83 100755
--- a/tests/test_apt.sh
+++ b/tests/test_apt.sh
@@ -8,6 +8,19 @@ DEBIAN_FRONTEND=noninteractive
 
 echo "Testing apt-get install."
 
+lock_timeout=120
+lock_counter=0
+tput sc
+while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
+    sleep 1 && echo $lock_counter && (( lock_counter++ ))
+    tput rc
+    if (( $lock_counter > $lock_timeout )); then
+        echo "APT is reported as locked for more than $lock_timeout seconds now..."
+        echo "Either a big upgrade is running or it is hung, please take a look"
+        exit 1
+    fi
+done
+
 echo "Clean repository."
 apt-get clean