Skip to content

Commit

Permalink
testing/local/linux: add trap exit to remove container
Browse files Browse the repository at this point in the history
Fixes #507
  • Loading branch information
Choraden authored and mmatczuk committed Nov 13, 2023
1 parent 5cab4f4 commit 572710d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions testing/local/linux/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ function run_interactive() {
podman exec "$container_name" systemctl status forwarder
podman exec -it "$container_name" /bin/bash
}

# Usage: remove_container CONTAINER_NAME
function remove_container() {
local container_name="$1"
podman rm --force "$container_name"
}
3 changes: 2 additions & 1 deletion testing/local/linux/run-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ build_image "$IMG" debian-systemd.Dockerfile
create_package "$DIST" forwarder.deb

podman run -p 3128:3128 -d -v ./forwarder.deb:/forwarder.deb --name "$CONTAINER" --replace "$IMG"
trap "remove_container $CONTAINER" EXIT

podman exec "$CONTAINER" dpkg --force-confdef -i /forwarder.deb
run_interactive "$CONTAINER"
podman rm --force "$CONTAINER"
3 changes: 2 additions & 1 deletion testing/local/linux/run-fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ build_image "$IMG" fedora-systemd.Dockerfile
create_package "$DIST" forwarder.rpm

podman run -p 3128:3128 -d -v ./forwarder.rpm:/forwarder.rpm --name "$CONTAINER" --replace "$IMG"
trap "remove_container $CONTAINER" EXIT

podman exec "$CONTAINER" dnf -y install /forwarder.rpm
run_interactive "$CONTAINER"
podman rm --force "$CONTAINER"

0 comments on commit 572710d

Please sign in to comment.