Skip to content

Commit 2088439

Browse files
committed
Update validate.sh to have proper centralized cleanup that will prevent disk space issues
Signed-off-by: Teoh Suh Haw <suh.haw.teoh@intel.com>
1 parent 0770484 commit 2088439

1 file changed

Lines changed: 35 additions & 5 deletions

File tree

validate.sh

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ else
3636
echo "QEMU boot tests will be skipped"
3737
fi
3838

39+
# Centralized cleanup function for image files
40+
cleanup_image_files() {
41+
local cleanup_type="${1:-all}" # Options: all, raw, extracted
42+
43+
case "$cleanup_type" in
44+
"raw")
45+
echo "Cleaning up raw image files from build directories..."
46+
sudo rm -rf ./tmp/*/imagebuild/*/*.raw 2>/dev/null || true
47+
;;
48+
"extracted")
49+
echo "Cleaning up extracted image files in current directory..."
50+
rm -f *.raw 2>/dev/null || true
51+
;;
52+
"all"|*)
53+
echo "Cleaning up all temporary image files..."
54+
sudo rm -rf ./tmp/*/imagebuild/*/*.raw 2>/dev/null || true
55+
rm -f *.raw 2>/dev/null || true
56+
;;
57+
esac
58+
}
59+
3960
run_qemu_boot_test() {
4061
local IMAGE_PATTERN="$1"
4162
if [ -z "$IMAGE_PATTERN" ]; then
@@ -125,11 +146,8 @@ run_qemu_boot_test() {
125146
result=1
126147
fi
127148
128-
# Clean up extracted raw file
129-
if [ -f \"\$RAW_IMAGE\" ]; then
130-
echo \"Cleaning up extracted image file: \$RAW_IMAGE\"
131-
rm -f \"\$RAW_IMAGE\"
132-
fi
149+
# Clean up extracted raw file using centralized function
150+
cleanup_image_files extracted
133151
134152
# Return to original directory
135153
cd \"\$ORIGINAL_DIR\"
@@ -262,6 +280,8 @@ build_azl3_raw_image() {
262280
echo "QEMU boot test FAILED for AZL3 raw image"
263281
exit 1
264282
fi
283+
# Clean up after QEMU test to free space
284+
cleanup_image_files raw
265285
fi
266286
else
267287
echo "AZL3 raw Image build failed."
@@ -313,6 +333,8 @@ build_emt3_raw_image() {
313333
echo "QEMU boot test FAILED for EMT3 raw image"
314334
exit 1
315335
fi
336+
# Clean up after QEMU test to free space
337+
cleanup_image_files raw
316338
fi
317339
else
318340
echo "EMT3 raw Image build failed."
@@ -363,6 +385,8 @@ build_elxr12_raw_image() {
363385
echo "QEMU boot test FAILED for ELXR12 raw image"
364386
exit 1
365387
fi
388+
# Clean up after QEMU test to free space
389+
cleanup_image_files raw
366390
fi
367391
else
368392
echo "ELXR12 raw Image build failed."
@@ -412,6 +436,8 @@ build_elxr12_immutable_raw_image() {
412436
echo "QEMU boot test FAILED for ELXR12 immutable raw image"
413437
exit 1
414438
fi
439+
# Clean up after QEMU test to free space
440+
cleanup_image_files raw
415441
fi
416442
else
417443
echo "ELXR12 immutable raw Image build failed."
@@ -437,6 +463,8 @@ build_emt3_immutable_raw_image() {
437463
echo "QEMU boot test FAILED for EMT3 immutable raw image"
438464
exit 1
439465
fi
466+
# Clean up after QEMU test to free space
467+
cleanup_image_files raw
440468
fi
441469
else
442470
echo "EMT3 immutable raw Image build failed."
@@ -462,6 +490,8 @@ build_azl3_immutable_raw_image() {
462490
echo "QEMU boot test FAILED for AZL3 immutable raw image"
463491
exit 1
464492
fi
493+
# Clean up after QEMU test to free space
494+
cleanup_image_files raw
465495
fi
466496
else
467497
echo "AZL3 immutable raw Image build failed."

0 commit comments

Comments
 (0)