Skip to content

Commit 41a76ae

Browse files
authored
Merge pull request #623 from portante/test-cleanup
Add an easy cleanup for tests
2 parents bc15b7c + 437e65a commit 41a76ae

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ docs:
106106
.PHONY: clean
107107
clean:
108108
rm -rf bin/ src/*.o src/*.gcno src/*.gcda *.gcov
109+
$(MAKE) -C test clean
109110
$(MAKE) -C docs clean
110111

111112
.PHONY: install install.bin install.crio install.podman podman crio

test/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: clean
2+
clean:
3+
-chmod -R 700 /tmp/conmon-test-*
4+
rm -rf /tmp/conmon-test-* /tmp/conmon-term.*

test/test_helper.bash

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ RUNTIME_BINARY="${RUNTIME_BINARY:-/usr/bin/runc}"
2525

2626
# UBI10-micro container image for test rootfs
2727
UBI10_MICRO_IMAGE="registry.access.redhat.com/ubi10/ubi-micro:latest"
28-
ROOTFS_CACHE_DIR="/tmp/conmon-test-images"
29-
ROOTFS_CACHE_MARKER="/tmp/conmon-test-images/.ubi10-micro-cached"
3028
VALID_PATH="/tmp"
3129
INVALID_PATH="/not/a/path"
3230

@@ -35,23 +33,12 @@ generate_ctr_id() {
3533
echo "conmon-test-$(date +%s)-$$-$RANDOM"
3634
}
3735

38-
# Cache UBI10-micro rootfs for container tests
39-
cache_ubi10_rootfs() {
40-
if [[ -f "$ROOTFS_CACHE_MARKER" ]]; then
41-
return 0
42-
fi
43-
44-
mkdir -p "$ROOTFS_CACHE_DIR"
45-
36+
# Pull UBI10-micro rootfs for container tests
37+
pull_ubi10_rootfs() {
4638
# Pull UBI10-micro image if not already present
47-
if ! podman image exists "$UBI10_MICRO_IMAGE" 2>/dev/null; then
48-
if ! podman pull "$UBI10_MICRO_IMAGE" >/dev/null 2>&1; then
49-
skip "Failed to pull UBI10-micro image"
50-
fi
39+
if ! podman pull --policy=newer "$UBI10_MICRO_IMAGE" >/dev/null 2>&1; then
40+
skip "Failed to pull UBI10-micro image"
5141
fi
52-
53-
# Mark as cached
54-
touch "$ROOTFS_CACHE_MARKER"
5542
}
5643

5744
# Run conmon with given arguments and capture output
@@ -340,8 +327,8 @@ setup_container_env() {
340327
local use_terminal="$2"
341328
setup_test_env
342329

343-
# Cache UBI10-micro image
344-
cache_ubi10_rootfs
330+
# Pull UBI10-micro image
331+
pull_ubi10_rootfs
345332

346333
# Create the rootfs directory
347334
mkdir -p "$ROOTFS"

0 commit comments

Comments
 (0)