all.sh: fix cleanup happening during an out-of-tree build
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index 96b33a1..312ca82 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -131,6 +131,10 @@
 # remove built files as well as the cmake cache/config
 cleanup()
 {
+    if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
+        cd "$MBEDTLS_ROOT_DIR"
+    fi
+
     command make clean
 
     # Remove CMake artefacts
@@ -699,6 +703,7 @@
 make test
 cd "$MBEDTLS_ROOT_DIR"
 rm -rf "$OUT_OF_SOURCE_DIR"
+unset MBEDTLS_ROOT_DIR