Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ cd "$(dirname -- "$0")"
KERNEL_VER="${KERNEL_VER:-$(uname -r)}"
echo "Using kernel ${KERNEL_VER}"

case "$(uname -s)" in
Linux) KCONFIG="/lib/modules/${KERNEL_VER}/build/.config" ;;
GNU/kFreeBSD) KCONFIG="/usr/src/kfreebsd-headers-${KERNEL_VER}/sys/.config" ;;
esac

# Override PATH to use the local dkms binary
PATH="$(pwd):$PATH"
export PATH
Expand Down Expand Up @@ -159,6 +164,9 @@ genericize_expected_output() {
if [[ $# -ge 2 && "$2" =~ uninstall|unbuild|remove ]] ; then
sed -i '/^depmod\.\.\.$/d' ${output_log}
fi
# Remove "CC=... LD=..." part from the "make ..." line. They have different values on different platforms
sed -i '/^make /s/ CC=[0-9A-Za-z_\.\-]*[0-9A-Za-z]//' ${output_log}
sed -i '/^make /s/ LD=[0-9A-Za-z_\.\-]*[0-9A-Za-z]//' ${output_log}
# Signing related output. Drop it from the output, to be more generic
sed -i '/^Sign command:/d' ${output_log}
sed -i '/^Signing key:/d' ${output_log}
Expand Down Expand Up @@ -374,7 +382,16 @@ EOF
else
ALTER_HASH="sha512"
fi
echo "CONFIG_MODULE_SIG_HASH=\"${ALTER_HASH}\"" > /tmp/dkms_test_kconfig
if [[ -f "$KCONFIG" ]]; then
cp "$KCONFIG" /tmp/dkms_test_kconfig
if grep -q '^CONFIG_MODULE_SIG_HASH=' /tmp/dkms_test_kconfig; then
sed -i "s/^CONFIG_MODULE_SIG_HASH=.*$/CONFIG_MODULE_SIG_HASH=\"${ALTER_HASH}\"/" /tmp/dkms_test_kconfig
else
echo "CONFIG_MODULE_SIG_HASH=\"${ALTER_HASH}\"" >> /tmp/dkms_test_kconfig
fi
else
echo "CONFIG_MODULE_SIG_HASH=\"${ALTER_HASH}\"" > /tmp/dkms_test_kconfig
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my MR in mind #312, I think we can split this (+ KCONFIG above) into it's own patch and simplify:

  • assume KCONFIG is always present - error otherwise
  • change, do not set CONFIG_MODULE_SIG_HASH

run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --config /tmp/dkms_test_kconfig --force << EOF

Building module:
Expand Down Expand Up @@ -463,11 +480,11 @@ dkms_test/1.0, ${KERNEL_VER}, $(uname -m): installed
EOF

echo 'Checking modinfo'
run_with_expected_output sh -c "modinfo /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext} | head -n 4" << EOF
filename: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
version: 1.0
run_with_expected_output sh -c "modinfo /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext} | head -n 4 | sort" << EOF
Copy link
Collaborator

@evelikov evelikov Mar 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On which platforms (distro, version, kmod version) do we need the sort? I can send a fix to kmod, if I know a bit more.

But realistically: if we need the sort, it should happen before the headm and ideally it'll be applied to all modinfo invocations.

Edit: please split it into it's own MR (alongside the other suggestions coming shortly), so we can land that ASAP.

description: A Simple dkms test module
filename: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
license: GPL
version: 1.0
EOF

if [[ "${NO_SIGNING_TOOL}" = 0 ]]; then
Expand Down Expand Up @@ -585,11 +602,11 @@ if ! [[ -f "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_co
fi

echo 'Checking modinfo'
run_with_expected_output sh -c "modinfo /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext} | head -n 4" << EOF
filename: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
version: 1.0
run_with_expected_output sh -c "modinfo /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext} | head -n 4 | sort" << EOF
description: A Simple dkms test module
filename: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
license: GPL
version: 1.0
EOF

if [[ "${NO_SIGNING_TOOL}" = 0 ]]; then
Expand Down