Files
Gleb Chesnokov a7f1f95a70 scripts: Preserve kernel patch conditions across whitespace changes
In-tree CI builds report compatibility errors after whitespace cleanup:

  Linux 7.3:
    conflicting types for 'wr'; have 'struct ib_rdma_wr'
    'sgv_shrinker' is a pointer; did you mean to use '->'?

  Linux 6.18.57, dev_handlers/scst_vdisk_main.c:330:
    too many arguments to function 'blkdev_issue_flush'

Two assumptions in specialize-patch change branch selection when only
whitespace changes in otherwise equivalent preprocessor expressions.

The dispatch expression accepts only spaces before '#'. A tab-indented
opening directive is copied as ordinary text, while its closing directive
still changes the conditional nesting state. Accept all horizontal
whitespace as the expression evaluator already does, including when an
indented #elif becomes #if after discarding its original opening branch.

The evaluator also substitutes an empty string for absent RHEL_MAJOR,
RHEL_RELEASE_CODE and MOFED version macros. Thus 'RHEL_MAJOR - 0' becomes
'- 0', which its signed-number patterns cannot reduce correctly. This
leaves the two-argument blkdev_issue_flush() call in a modern upstream
patch. Substitute zero for these absent numeric macros, matching C
preprocessor semantics and the existing RHEL_MINOR handling. Keep their
defined() results false and preserve supplied vendor version values.

Add isolated regressions for spaces and tabs around '#', nested unknown
guards, promoted #elif branches and absent vendor versions. Cover all
three flush signatures at the upstream 5.8/5.12 and RHEL 8.4/8.6 boundaries,
plus EL7, RHEL 9, upstream 6.18.57 and 7.3, with both '-0' and '- 0'. Apply
each resulting patch in a temporary directory in removal and blank-
preserving modes, checking selected branches, surviving guards and hunk
lengths without compiling or loading SCST.

Install patch in the CI build stage used by these generator tests. Without
this dependency, all 98 specialization subcases abort before applying the
patches, with the following error in the minimal Fedora build image:

  FileNotFoundError: [Errno 2] No such file or directory: 'patch'
2026-10-22 14:30:26 +03:00

56 lines
2.6 KiB
Docker

# SPDX-License-Identifier: GPL-2.0-only
FROM fedora:44@sha256:43b29f65a41eb9c35e1cd5323e3bdf3b655c2357a9f4f1ff2f9c2798e5045d80 AS runtime
ARG SUITE
ARG KERNEL_BUILD
# The pinned kernel rpms, matching KERNEL_BUILD. The package split varies by
# release, so the checksum file also lists which rpms to install.
ARG KERNEL_SUMS=kernel.SHA256SUMS
ENV KVER=${KERNEL_BUILD}.x86_64
ENV CGO_ENABLED=0 GOTOOLCHAIN=local GOCACHE=/opt/go-cache GOMODCACHE=/opt/go-mod
COPY scripts/ci/${KERNEL_SUMS} /tmp/kernel.SHA256SUMS
RUN dnf install -y --setopt=install_weak_deps=False \
make kmod python3 perl perl-Config-General perl-Data-Dumper \
systemd systemd-udev dracut util-linux procps-ng iproute \
openssh-server openssh-clients iscsi-initiator-utils sg3_utils fio \
findutils diffutils tar gzip curl-minimal && \
if [ "$SUITE" = ginkgo ]; then dnf install -y golang; fi && \
mkdir /tmp/kernel && cd /tmp/kernel && \
for package in $(awk '{print $2}' /tmp/kernel.SHA256SUMS); do \
curl --fail --location --retry 3 \
"https://kojipkgs.fedoraproject.org/packages/kernel/${KERNEL_BUILD%-*}/${KERNEL_BUILD#*-}/x86_64/$package" \
--output "$package"; \
done && \
sha256sum --check /tmp/kernel.SHA256SUMS && \
dnf install -y --setopt=install_weak_deps=False \
$(find . -name 'kernel-*.rpm' ! -name 'kernel-devel-*' | sort) && \
depmod "$KVER" && \
dracut --force --no-hostonly --no-hostonly-cmdline --no-early-microcode \
--add-drivers 'virtio_pci virtio_blk virtio_net 9p 9pnet_virtio' \
--filesystems ext4 /boot/ci-initramfs "$KVER" && \
cp "/lib/modules/$KVER/vmlinuz" /boot/ci-vmlinuz && \
cp "/lib/modules/$KVER/config" "/boot/config-$KVER" && \
dnf clean all
FROM runtime AS build
ARG SUITE
ARG SOURCE_COMMIT
RUN dnf install -y --setopt=install_weak_deps=False \
gcc elfutils-libelf-devel openssl openssl-devel perl-ExtUtils-MakeMaker git patch \
/tmp/kernel/kernel-devel-*.rpm && dnf clean all
COPY . /scst
WORKDIR /scst
RUN bash scripts/ci/build-guest "$SUITE" "$SOURCE_COMMIT"
FROM runtime
COPY --from=build /scst /scst
COPY --from=build /opt/go-cache /opt/go-cache
COPY --from=build /opt/go-mod /opt/go-mod
COPY --from=build /opt/ci-build /opt/ci-build
COPY scripts/ci/scst-ci.service /etc/systemd/system/scst-ci.service
COPY scripts/ci/scst-ci.target /etc/systemd/system/scst-ci.target
RUN rm -rf /tmp/kernel /tmp/kernel.SHA256SUMS /var/cache/* && \
mkdir -p /ci/input /ci/reports /ci/backing /root/.ssh /run/sshd && \
chmod 700 /root/.ssh && \
sed -i 's/^root:[^:]*:/root::/' /etc/shadow
ENV GOPROXY=off