github.com/containers/podman/v5@v5.1.0-rc1/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 grep -F -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. Make sure we're invoked with some! 65 if [[ -z "$*" ]]; then 66 echo "$ME: FATAL: Invalid use of '${FUNCNAME[1]}' at line ${BASH_LINENO[1]}: missing test-name argument(s)." >&2 67 exit 1 68 fi 69 70 for t in "$@"; do 71 if grep -F -qx "@test \"$t\" {" $BUD; then 72 $ECHO "@test \"$t\" : $skip \"$reason\"" 73 # Escape slash in test name, 'custom files in /run/' 74 t=${t//\//\\/} 75 # Escape star in test name, 'bud with --dns* flags' 76 t=${t//\*/\\\*} 77 sed -i -e "/^\@test \"$t\" {/ a \ \ $skip \"$reason\"" $BUD 78 else 79 warn "[$skip] Did not find test \"$t\" in $BUD" 80 fi 81 done 82 } 83 84 function skip() { 85 _skip "skip" "$@" 86 } 87 88 function skip_if_remote() { 89 _skip "skip_if_remote" "$@" 90 } 91 92 function skip_if_rootless() { 93 _skip "skip_if_rootless_environment" "$@" 94 } 95 96 function skip_if_rootless_remote() { 97 _skip "skip_if_rootless_remote" "$@" 98 } 99 100 # END handlers 101 ############################################################################### 102 # BEGIN user-customizable section 103 # 104 # These are the hand-maintained exceptions. This is what you want to edit 105 # or update as needed. 106 # 107 # There are three directives you can use below: 108 # 109 # errmsg "old-message" "new-message" "test name" ["test name"...] 110 # 111 # This replaced "old-message" with "new-message" in @test "test name". 112 # It is used when a podman error message differs from buildah's. 113 # 114 # [skip | skip_if_remote] "reason" "test name" ["test name"...] 115 # 116 # This adds a 'skip' statement as the first line of @test "test name". 117 # It is used when a test does not work in podman, either for permanent 118 # design-related reasons or for hopefully-temporary bug-in-podman reasons. 119 # (If the latter, please file an issue before adding the skip, and include 120 # the issue number in your skip message. This makes it possible to remove 121 # the skip once the issue is fixed). 122 # 123 # For both cases, you can list multiple "test names" at the end. This 124 # is not used much right now, but will be once I file my podman-remote PR 125 # because there are some cases where the same issue affects up to fifty 126 # different bud.bats tests. 127 # 128 129 ############################################################################### 130 # BEGIN differences in error messages between buildah and podman 131 132 errmsg "non-directory/Dockerfile: not a directory" \ 133 "Error: context must be a directory:" \ 134 "bud with a path to a Dockerfile (-f) containing a non-directory entry" 135 136 errmsg "no such file or directory" \ 137 "Error: context must be a directory:" 138 139 errmsg "no such file or directory" \ 140 "Error: no context directory and no Containerfile specified" \ 141 "bud without any arguments should fail when no Dockerfile exists" 142 143 errmsg "is not a file" \ 144 "Error: no Containerfile or Dockerfile specified or found in context directory" \ 145 "bud with specified context should fail if Dockerfile in context directory is actually a file" 146 147 errmsg "no such file or directory" \ 148 "context must be a directory" \ 149 "bud with specified context should fail if context directory does not exist" 150 151 # 2022-04-26 after buildah PR 3926 (where Ed added error-message checks" 152 errmsg "no FROM statement found" \ 153 "Error: no FROM statement found" \ 154 "bud with Dockerfile from invalid URL" 155 156 errmsg "no contents in .*" \ 157 "Error: context must be a directory: .*" \ 158 "bud with specified context should fail if context contains empty Dockerfile" 159 160 errmsg "credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory" \ 161 "Error: credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory" \ 162 "bud with Containerfile should fail with nonexistent authfile" 163 164 errmsg "cannot find Containerfile or Dockerfile" \ 165 "no such file or directory" \ 166 "bud-github-context-from-commit" 167 168 ############################################################################### 169 # BEGIN tests that don't make sense under podman due to fundamental differences 170 171 # Fails with "Error: no context directory and no Containerfile specified" 172 skip "does not work under podman" \ 173 "bud without any arguments should succeed" 174 175 # ...or due to a fundamental arg-parsing difference between buildah and podman 176 # which we could and perhaps should fix in the buildah repo via: 177 # - ... ${TESTSDIR}/bud/layers-squash/Dockerfile.hardlinks 178 # + ... -f Dockerfile.hardlinks ${TESTSDIR}/bud/layers-squash 179 skip "argument-order incompatible with podman" \ 180 "bud-squash-hardlinks" 181 182 # Fails with "Error: context must be a directory: /path/to/Dockerfile" 183 skip "podman-build fails with 'context must be a directory'" \ 184 "bud with specified context should succeed if context contains existing Dockerfile" 185 186 # See https://github.com/containers/podman/pull/20483#issuecomment-1782683979 187 skip "does not pass in Podman CI: needs investigation" \ 188 "bud with --no-hostname" 189 190 ############################################################################### 191 # BEGIN tests which are skipped because they make no sense under podman-remote 192 193 skip_if_remote "--runtime-flags does not work with podman-remote" \ 194 "bud - invalid runtime flags test" 195 196 skip_if_remote "--target does not work with podman-remote" \ 197 "bud-target" 198 199 skip_if_remote "--runtime not meaningful under podman-remote" \ 200 "bud with --runtime and --runtime-flag" 201 202 skip_if_remote "secret files not implemented under podman-remote" \ 203 "bud with containerfile secret" \ 204 "bud with containerfile secret accessed on second RUN" \ 205 "bud with containerfile secret options" \ 206 "bud with containerfile env secret" \ 207 "bud with containerfile env secret priority" 208 209 skip_if_remote "--signature-policy does not work with podman-remote" \ 210 "buildah-bud-policy" 211 212 skip_if_remote "--build-context option not implemented in podman-remote" \ 213 "build-with-additional-build-context and COPY, additional context from host" \ 214 "build-with-additional-build-context and RUN --mount=from=, additional-context not image and also test conflict with stagename" \ 215 216 skip_if_remote "env-variable for Containerfile.in pre-processing is not propagated on remote" \ 217 "bud with Containerfile.in, via envariable" \ 218 219 # Requires a local file outside context dir 220 skip_if_remote "local keyfile not sent to podman-remote" \ 221 "bud with encrypted FROM image" 222 223 # See podman #9890 for discussion 224 skip_if_remote "--stdin option will not be implemented in podman-remote" \ 225 "bud test no --stdin" 226 227 # https://github.com/containers/buildah/pull/3823 228 # If this is possible with podman-remote, it'll take way more Go skills 229 # to implement than what Ed can do. 230 skip_if_remote "--output option not implemented in podman-remote" \ 231 "build with custom build output and output rootfs to directory" \ 232 "build with custom build output and output rootfs to tar" \ 233 "build with custom build output and output rootfs to tar by pipe" \ 234 "build with custom build output must fail for bad input" \ 235 "build with custom build output and output rootfs to tar with no additional step" \ 236 "build with custom build output for single-stage-cached and output rootfs to directory" \ 237 "build with custom build output for multi-stage-cached and output rootfs to directory" \ 238 "build with custom build output for multi-stage and output rootfs to directory" 239 240 # https://github.com/containers/podman/issues/14544 241 skip_if_remote "logfile not implemented on remote" "bud-logfile-with-split-logfile-by-platform" 242 243 skip_if_remote "envariables do not automatically work with -remote." \ 244 "build proxy" 245 246 # 2022-07-04 this is a new test in buildah; it's failing in treadmill 247 skip_if_remote "FIXME FIXME FIXME: does this test make sense in remote?" \ 248 "build-test with OCI prestart hook" 249 250 # 2022-08-17 buildah PR 4190 251 skip_if_remote "Explicit request in buildah PR 4190 to skip this on remote" \ 252 "build: test race in updating image name while performing parallel commits" 253 # 2023-04-20 flakes on rootless, too. 254 skip_if_rootless "Flakes when run rootless, too. See Buildah PR 4190" \ 255 "build: test race in updating image name while performing parallel commits" 256 257 skip_if_remote "--events-backend does not work with podman-remote" \ 258 "build test default ulimits" 259 260 ############################################################################### 261 # BEGIN tests which are skipped due to actual podman or podman-remote bugs. 262 263 skip_if_remote "different error messages between podman & podman-remote" \ 264 "bud with .dockerignore #2" \ 265 "bud with .dockerignore #4" 266 267 # END tests which are skipped due to actual podman or podman-remote bugs. 268 ############################################################################### 269 # BEGIN temporary workarounds that must be reevaluated periodically 270 271 # 2023-06-27 confirmed this is still broken, main @ 3794d067e 272 skip_if_remote "FIXME: can this test be made to work under podman-remote?" \ 273 "bud-with-mount-cache-like-buildkit-verify-default-selinux-option" 274 275 # 2023-06-27 confirmed these are still broken, main @ 3794d067e 276 skip_if_rootless_remote "FIXME: #17788 tar + namespaces over http" \ 277 "bud-http-context-with-Dockerfile" \ 278 "bud-http-context-dir-with-Dockerfile" \ 279 "bud-http-context-with-Containerfile" 280 281 # 2023-06-27 confirmed these are still broken, main @ 3794d067e 282 skip_if_rootless_remote "FIXME: not sure if 17788 or some other bug" \ 283 "bud-github-context" \ 284 "bud with Dockerfile from stdin tar" \ 285 "build-with-network-test" 286 287 # 2023-06-27 confirmed this is still broken, main @ 3794d067e 288 # 2023-06-13 buildah 4746 changed exit code & expected error message 289 skip "FIXME: 2023-06-13 buildah PR 4746 broke this test" \ 290 "bud with encrypted FROM image" 291 292 # 2024-04-16 test needs to be fixed in buildah repo, to use another registry 293 skip "FIXME: 2024-04-16 nixery is down" \ 294 "bud-implicit-no-history" 295 296 # END temporary workarounds that must be reevaluated periodically 297 ############################################################################### 298 299 exit $RC