github.com/AbhinandanKurakure/podman/v3@v3.4.10/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 errmsg "non-directory/Dockerfile: not a directory" \ 116 "Error: context must be a directory:" \ 117 "bud with a path to a Dockerfile (-f) containing a non-directory entry" 118 119 errmsg "no such file or directory" \ 120 "Error: context must be a directory:" \ 121 "bud with dir for file but no Dockerfile in dir" \ 122 "bud with bad dir Dockerfile" 123 124 errmsg "no such file or directory" \ 125 "Error: no context directory and no Containerfile specified" \ 126 "bud without any arguments should fail when no Dockerfile exist" 127 128 errmsg "is not a file" \ 129 "Error: open .*: no such file or directory" \ 130 "bud with specified context should fail if assumed Dockerfile is a directory" 131 132 errmsg "no such file or directory" \ 133 "context must be a directory" \ 134 "bud with specified context should fail if context contains not-existing Dockerfile" 135 136 ############################################################################### 137 # BEGIN tests that don't make sense under podman due to fundamental differences 138 139 skip "N/A under podman" \ 140 "bud-flags-order-verification" 141 142 skip "does not work under podman" \ 143 "bud without any arguments should succeed" 144 145 skip "podman requires a directory, not a Dockerfile" \ 146 "bud with specified context should succeed if context contains existing Dockerfile" 147 148 # ...or due to Ed's laziness 149 skip "Too much effort to spin up a local registry" \ 150 "bud with encrypted FROM image" \ 151 "bud --authfile" 152 153 # ...or due to a fundamental arg-parsing difference between buildah and podman 154 # which we could and perhaps should fix in the buildah repo via: 155 # - ... ${TESTSDIR}/bud/layers-squash/Dockerfile.hardlinks 156 # + ... -f Dockerfile.hardlinks ${TESTSDIR}/bud/layers-squash 157 skip "FIXME FIXME FIXME: argument-order incompatible with podman" \ 158 "bud-squash-hardlinks" 159 160 skip "FIXME FIXME FIXME: this passes on Ed's laptop, fails in CI??" \ 161 "bud-multi-stage-nocache-nocommit" 162 163 # This will probably never work: buildah and podman have incompatible defaults 164 # Documented in https://github.com/containers/podman/issues/10412 165 skip "buildah runs with --cgroup-manager=cgroupfs, podman with systemd" \ 166 "bud with --cgroup-parent" 167 168 ############################################################################### 169 # BEGIN tests which are skipped because they make no sense under podman-remote 170 171 skip_if_remote "--target does not work with podman-remote" \ 172 "bud-target" 173 174 skip_if_remote "--runtime not meaningful under podman-remote" \ 175 "bud with --runtime and --runtime-flag" 176 177 skip_if_remote "secret files not implemented under podman-remote" \ 178 "bud with containerfile secret" \ 179 "bud with containerfile secret accessed on second RUN" \ 180 "bud with containerfile secret options" 181 182 skip_if_remote "volumes don't work with podman-remote" \ 183 "buildah bud --volume" \ 184 "buildah-bud-policy" 185 186 # See podman #9890 for discussion 187 skip_if_remote "--stdin option will not be implemented in podman-remote" \ 188 "bud test no --stdin" 189 190 ############################################################################### 191 # BEGIN tests which are skipped due to actual podman-remote bugs. 192 193 ############################################################################### 194 # BEGIN emergency handling of github git-protocol shutdown 195 # 196 # Please remove this as soon as we vendor buildah with #3701 197 198 skip "emergency workaround until buildah #3701 gets vendored in" \ 199 "bud-git-context" \ 200 "bud using gitrepo and branch" 201 202 # END emergency handling of github git-protocol shutdown 203 ############################################################################### 204 # Done. 205 206 exit $RC