github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/buildah-bud/apply-podman-deltas (about) 1 #!/bin/bash 2 # 3 # *** NOTE TO READER: Please skip down to "user-customizable section" below! 4 # 5 # Not all tests in buildah/tests/bud.bats work under podman. 6 # Some work, but emit different error messages. 7 # 8 # This script is used to skip the former, and munge expect_output messages 9 # for the latter. 10 # 11 ME=$(basename $0) 12 13 BUD=tests/bud.bats 14 15 if [[ ! -e $BUD ]]; then 16 echo "$ME: $BUD not found: please run me from buildah subdir" >&2 17 exit 1 18 fi 19 20 ############################################################################### 21 # BEGIN handlers 22 # 23 # *** NOTE TO READER (again): Please skip down to "user-customizable section" 24 # 25 # You almost certainly don't care about anything in this section. 26 # 27 set -e 28 29 RC=0 30 31 ECHO=':' 32 if [[ -n $DEBUG_PODMAN_DELTAS ]]; then 33 ECHO='echo' 34 fi 35 36 # Issue a warning, and set exit status (but do not exit now) 37 function warn() { 38 echo "$ME: ERROR: $*" >&2 39 RC=1 40 } 41 42 # errmsg: used to change the text of a message, probably in expect_output() 43 function errmsg() { 44 local msg_orig=${1//\//\\/}; shift 45 local msg_new=${1//\//\\/}; shift 46 47 for t in "$@"; do 48 if fgrep -qx "@test \"$t\" {" $BUD; then 49 $ECHO "@test \"$t\" : updating to \"$msg_new\"" 50 t=${t//\//\\/} 51 # FIXME: emit error if msg_orig not found 52 sed -i -e "/^\@test \"$t\" {/,/^}/s/\"$msg_orig\"/\"$msg_new\"/" $BUD 53 else 54 warn "[errmsg] Did not find test \"$t\" in $BUD" 55 fi 56 done 57 } 58 59 # _skip: used to add a 'skip' or 'skip_if_remote' to one specific test 60 function _skip() { 61 local skip=$1; shift 62 local reason=$1; shift 63 64 # All further arguments are test names 65 for t in "$@"; do 66 if fgrep -qx "@test \"$t\" {" $BUD; then 67 $ECHO "@test \"$t\" : $skip \"$reason\"" 68 t=${t//\//\\/} 69 sed -i -e "/^\@test \"$t\" {/ a \ \ $skip \"$reason\"" $BUD 70 else 71 warn "[$skip] Did not find test \"$t\" in $BUD" 72 fi 73 done 74 } 75 76 function skip() { 77 _skip "skip" "$@" 78 } 79 80 function skip_if_remote() { 81 _skip "skip_if_remote" "$@" 82 } 83 84 # END handlers 85 ############################################################################### 86 # BEGIN user-customizable section 87 # 88 # These are the hand-maintained exceptions. This is what you want to edit 89 # or update as needed. 90 # 91 # There are three directives you can use below: 92 # 93 # errmsg "old-message" "new-message" "test name" ["test name"...] 94 # 95 # This replaced "old-message" with "new-message" in @test "test name". 96 # It is used when a podman error message differs from buildah's. 97 # 98 # [skip | skip_if_remote] "reason" "test name" ["test name"...] 99 # 100 # This adds a 'skip' statement as the first line of @test "test name". 101 # It is used when a test does not work in podman, either for permanent 102 # design-related reasons or for hopefully-temporary bug-in-podman reasons. 103 # (If the latter, please file an issue before adding the skip, and include 104 # the issue number in your skip message. This makes it possible to remove 105 # the skip once the issue is fixed). 106 # 107 # For both cases, you can list multiple "test names" at the end. This 108 # is not used much right now, but will be once I file my podman-remote PR 109 # because there are some cases where the same issue affects up to fifty 110 # different bud.bats tests. 111 # 112 113 ############################################################################### 114 # BEGIN differences in error messages between buildah and podman 115 116 errmsg "non-directory/Dockerfile: not a directory" \ 117 "Error: context must be a directory:" \ 118 "bud with a path to a Dockerfile (-f) containing a non-directory entry" 119 120 errmsg "no such file or directory" \ 121 "Error: context must be a directory:" \ 122 "bud with dir for file but no Dockerfile in dir" \ 123 "bud with bad dir Dockerfile" 124 125 errmsg "no such file or directory" \ 126 "Error: no context directory and no Containerfile specified" \ 127 "bud without any arguments should fail when no Dockerfile exist" 128 129 errmsg "is not a file" \ 130 "Error: open .*: no such file or directory" \ 131 "bud with specified context should fail if assumed Dockerfile is a directory" 132 133 errmsg "no such file or directory" \ 134 "context must be a directory" \ 135 "bud with specified context should fail if context contains not-existing Dockerfile" 136 137 # 2022-04-26 after buildah PR 3926 (where Ed added error-message checks" 138 errmsg "no FROM statement found" \ 139 "Error: no FROM statement found" \ 140 "bud with Dockerfile from invalid URL" 141 142 errmsg "no contents in .*" \ 143 "Error: context must be a directory: .*" \ 144 "bud with specified context should fail if context contains empty Dockerfile" 145 146 errmsg "checking authfile: stat /tmp/nonexistent: no such file or directory" \ 147 "Error: checking authfile: stat /tmp/nonexistent: no such file or directory" \ 148 "bud with Containerfile should fail with nonexistent authfile" 149 150 ############################################################################### 151 # BEGIN tests that don't make sense under podman due to fundamental differences 152 153 # TODO 154 # Normally, when buildah exits 1 on error, podman exits 125. 155 # These tests are the exception. They exit 1 under podman. 156 skip "these tests exit 1 under podman, not 125" \ 157 "bud with --add-host" \ 158 "bud - invalid runtime flags test" 159 160 skip "does not work under podman" \ 161 "bud without any arguments should succeed" 162 163 # ...or due to a fundamental arg-parsing difference between buildah and podman 164 # which we could and perhaps should fix in the buildah repo via: 165 # - ... ${TESTSDIR}/bud/layers-squash/Dockerfile.hardlinks 166 # + ... -f Dockerfile.hardlinks ${TESTSDIR}/bud/layers-squash 167 skip "FIXME FIXME FIXME: argument-order incompatible with podman" \ 168 "bud-squash-hardlinks" 169 170 skip "FIXME FIXME FIXME: this passes on Ed's laptop, fails in CI??" \ 171 "bud-multi-stage-nocache-nocommit" 172 173 ############################################################################### 174 # BEGIN tests which are skipped because they make no sense under podman-remote 175 176 skip_if_remote "--runtime-flags does not work with podman-remote" \ 177 "bud - invalid runtime flags test" 178 179 skip_if_remote "--target does not work with podman-remote" \ 180 "bud-target" 181 182 skip_if_remote "--runtime not meaningful under podman-remote" \ 183 "bud with --runtime and --runtime-flag" 184 185 skip_if_remote "secret files not implemented under podman-remote" \ 186 "bud with containerfile secret" \ 187 "bud with containerfile secret accessed on second RUN" \ 188 "bud with containerfile secret options" \ 189 "bud with containerfile env secret" \ 190 "bud with containerfile env secret priority" 191 192 skip_if_remote "volumes don't work with podman-remote" \ 193 "buildah bud --volume" \ 194 "buildah-bud-policy" 195 196 skip_if_remote "--build-context option not implemented in podman-remote" \ 197 "build-with-additional-build-context and COPY, additional context from host" \ 198 "build-with-additional-build-context and RUN --mount=from=, additional-context not image and also test conflict with stagename" \ 199 200 skip_if_remote "env-variable for Containerfile.in pre-processing is not propogated on remote" \ 201 "bud with Containerfile.in, via envariable" \ 202 203 # Requires a local file outside context dir 204 skip_if_remote "local keyfile not sent to podman-remote" \ 205 "bud with encrypted FROM image" 206 207 # See podman #9890 for discussion 208 skip_if_remote "--stdin option will not be implemented in podman-remote" \ 209 "bud test no --stdin" 210 211 # https://github.com/containers/buildah/pull/3823 212 # If this is possible with podman-remote, it'll take way more Go skills 213 # to implement than what Ed can do. 214 skip_if_remote "--output option not implemented in podman-remote" \ 215 "build with custom build output and output rootfs to directory" \ 216 "build with custom build output and output rootfs to tar" \ 217 "build with custom build output and output rootfs to tar by pipe" \ 218 "build with custom build output must fail for bad input" 219 220 ############################################################################### 221 # BEGIN tests which are skipped due to actual podman or podman-remote bugs. 222 223 skip_if_remote "Podman #12838: different error messages" \ 224 "bud with .dockerignore #2" 225 226 # These two tests, new in 2022-01, invoke podman (create, export) in ways 227 # that don't work with podman-remote due to the use of --registries-conf 228 skip_if_remote "FIXME FIXME FIXME: find a way to clean up their podman calls" \ 229 "bud with run should not leave mounts behind cleanup test" \ 230 "bud with custom files in /run/ should persist cleanup test" 231 232 skip_if_remote "Do envariables work with -remote? Please look into this." \ 233 "build proxy" 234 235 ############################################################################### 236 # Done. 237 238 exit $RC