diff --git a/tests/integration/kubernetes/k8s-hostpath-volume.bats b/tests/integration/kubernetes/k8s-hostpath-volume.bats index 63c9b9c283..1a921575e4 100644 --- a/tests/integration/kubernetes/k8s-hostpath-volume.bats +++ b/tests/integration/kubernetes/k8s-hostpath-volume.bats @@ -34,7 +34,14 @@ setup() { # Check the mount info. mount_info="$(kubectl exec "${pod_name}" -- "${cmd_mountinfo[@]}")" - read root mountpoint fstype < <(awk '{print $4, $5, $9}' <<< "$mount_info") + # /proc/self/mountinfo has a variable number of optional fields before + # the "-" separator, so fstype is not always at $9. Find "-" and take + # the immediately following field, which is always the fstype. + read root mountpoint fstype < <(awk '{ + for (i = 1; i <= NF; i++) { + if ($i == "-") { print $4, $5, $(i+1); break } + } + }' <<< "$mount_info") [ "$root" == "/kmsg" ] # Would look like "/--kmsg" with virtio-fs. [ "$mountpoint" == "/dev/kmsg" ]