summaryrefslogtreecommitdiff
path: root/test/buildah-bud/buildah-tests.diff
blob: bba737848f5c79c0a5d3914743650266db784022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From b948e99cb6cb4765987711e8d8948841f6d3f7e2 Mon Sep 17 00:00:00 2001
From: Ed Santiago <santiago@redhat.com>
Date: Tue, 9 Feb 2021 17:28:05 -0700
Subject: [PATCH] tweaks for running buildah tests under podman

Signed-off-by: Ed Santiago <santiago@redhat.com>
---
 tests/helpers.bash | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/tests/helpers.bash b/tests/helpers.bash
index 99c290af..c5572840 100644
--- a/tests/helpers.bash
+++ b/tests/helpers.bash
@@ -70,7 +70,7 @@ function _prefetch() {
         mkdir -p ${_BUILDAH_IMAGE_CACHEDIR}
     fi

-    local _podman_opts="--root ${TESTDIR}/root --storage-driver ${STORAGE_DRIVER}"
+    local _podman_opts="--root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER}"

     for img in "$@"; do
         echo "# [checking for: $img]" >&2
@@ -138,15 +138,35 @@ function run_buildah() {
         --retry)         retry=3;        shift;;  # retry network flakes
     esac

+    local podman_or_buildah=${BUILDAH_BINARY}
+    if [[ $1 == "bud" || $1 == "build-using-dockerfile" ]]; then
+        shift
+        # podman defaults to --layers=true; buildah to --false.
+        # If command line includes explicit --layers, leave it untouched,
+        # but otherwise update command line so podman mimics buildah default.
+        if [[ "$*" =~ --layers || "$*" =~ --squash ]]; then
+            set "build" "--force-rm=false" "$@"
+        else
+            set "build" "--force-rm=false" "--layers=false" "$@"
+        fi
+        podman_or_buildah=${PODMAN_BINARY}
+
+        # podman always exits 125 where buildah exits 1 or 2
+        case $expected_rc in
+            1|2)   expected_rc=125 ;;
+        esac
+    fi
+    local cmd_basename=$(basename ${podman_or_buildah})
+
     # Remember command args, for possible use in later diagnostic messages
-    MOST_RECENT_BUILDAH_COMMAND="buildah $*"
+    MOST_RECENT_BUILDAH_COMMAND="$cmd_basename $*"

     while [ $retry -gt 0 ]; do
         retry=$(( retry - 1 ))

         # stdout is only emitted upon error; this echo is to help a debugger
-        echo "\$ $BUILDAH_BINARY $*"
-        run timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${BUILDAH_BINARY} --registries-conf ${TESTSDIR}/registries.conf --root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER} "$@"
+        echo "\$ $cmd_basename $*"
+        run timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${podman_or_buildah} --registries-conf ${TESTSDIR}/registries.conf --root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER} "$@"
         # without "quotes", multiple lines are glommed together into one
         if [ -n "$output" ]; then
             echo "$output"
--
2.30.2