Compare commits

..

No commits in common. "rawhide" and "f24" have entirely different histories.

18 changed files with 282 additions and 1888 deletions

View file

@ -1 +0,0 @@
1

18
.gitignore vendored
View file

@ -1 +1,17 @@
/kmod-*.tar.xz
/kmod-7.tar.xz
/kmod-8.tar.xz
/kmod-9.tar.xz
/kmod-10.tar.xz
/kmod-11.tar.xz
/kmod-12.tar.xz
/kmod-13.tar.xz
/kmod-14.tar.xz
/kmod-15.tar.xz
/kmod-16.tar.xz
/kmod-17.tar.xz
/kmod-18.tar.xz
/kmod-19.tar.xz
/kmod-20.tar.xz
/kmod-21.tar.xz
/kmod-22.tar.xz
/kmod-23.tar.xz

View file

@ -1,6 +0,0 @@
#
# depmod.conf
#
# override default search ordering for kmod packaging
search updates extra built-in weak-updates

318
kmod.spec
View file

@ -1,105 +1,26 @@
# Fedora does not support CONFIG_MODVERSIONS. Without kabi support
# weak-modules is useless at best, and can be actively harmful.
# Since RHEL *does* support this and offers kabi support,
# turn it on there by default.
%if 0%{?rhel}
%bcond_without weak_modules
%bcond_without dist_conf
%else
%bcond_with weak_modules
%bcond_with dist_conf
%endif
%bcond_without zlib
%bcond_without xz
%bcond_without zstd
Name: kmod
Version: 34.2
Release: 3%{?dist}
Version: 23
Release: 2%{?dist}
Summary: Linux kernel module management utilities
# https://docs.fedoraproject.org/en-US/legal/license-field/#_no_effective_license_analysis
# GPL-2.0-or-later:
# build-aux/compile
# build-aux/depcomp
# build-aux/ltmain.sh
# build-aux/ltmain.sh
# build-aux/missing
# build-aux/py-compile
# build-aux/test-driver
# m4/attributes.m4
# m4/features.m4
# tools
# GPL-3.0-or-later:
# build-aux/config.guess
# build-aux/config.sub
# build-aux/git-version-gen
# libkmod/docs/gtk-doc.make
# m4/gtk-doc.m4
# FSFUL:
# configure
# FSFULLRWD:
# aclocal.m4
# libkmod/docs/Makefile.in
# m4/libtool.m4
# m4/lt~obsolete.m4
# m4/ltoptions.m4
# m4/ltsugar.m4
# m4/ltversion.m4
# Makefile.in
# LGPL-2.1-only:
# libkmod/python/kmod/error.py
# libkmod/python/kmod/__init__.py
# libkmod/python/kmod/version.py
# libkmod/python/kmod/version.py.in
# LGPL-2.1-or-later:
# config.h.in (no explicit license, the one in COPYING is assumed)
# libkmod
# man (no explicit license, the one in COPYING is assumed)
# shared
# shell-completion/bash/kmod
# testsuite
# X11:
# build-aux/install-sh
License: GPL-2.0-or-later AND GPL-3.0-or-later AND FSFUL AND FSFULLRWD AND LGPL-2.1-only AND LGPL-2.1-or-later AND X11
URL: https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
Source0: https://www.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.tar.xz
Group: System Environment/Kernel
License: GPLv2+
URL: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary
Source0: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.tar.xz
Source1: weak-modules
Source2: depmod.conf.dist
# http://patchwork.ozlabs.org/patch/581441/
Exclusiveos: Linux
BuildRequires: gcc
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: chrpath
%if %{with zlib}
BuildRequires: zlib-devel
%endif
%if %{with xz}
BuildRequires: xz-devel
%endif
BuildRequires: scdoc gtk-doc
BuildRequires: openssl-devel
BuildRequires: make automake libtool
%if %{with zstd}
BuildRequires: libzstd-devel
%endif
BuildRequires: libxslt
Provides: module-init-tools = 4.0-1
Obsoletes: module-init-tools < 4.0-1
Provides: /sbin/modprobe
%if "%{_sbindir}" == "%{_bindir}"
# Compat symlinks for Requires in other packages.
# We rely on filesystem to create the symlinks for us.
Requires: filesystem(unmerged-sbin-symlinks)
Provides: /usr/sbin/modprobe
Provides: /usr/sbin/modinfo
Provides: /usr/sbin/insmod
Provides: /usr/sbin/rmmod
Provides: /usr/sbin/lsmod
Provides: /usr/sbin/depmod
%endif
%description
The kmod package provides various programs needed for automatic
loading and unloading of modules under 2.6, 3.x, and later kernels, as well
@ -108,6 +29,8 @@ examples of loaded and unloaded modules.
%package libs
Summary: Libraries to handle kernel module loading and unloading
License: LGPLv2+
Group: System Environment/Libraries
%description libs
The kmod-libs package provides runtime libraries for any application that
@ -115,6 +38,7 @@ wishes to load or unload Linux kernel modules from the running system.
%package devel
Summary: Header files for kmod development
Group: Development/Libraries
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%description devel
@ -122,47 +46,43 @@ The kmod-devel package provides header files used for development of
applications that wish to load or unload Linux kernel modules.
%prep
%autosetup -p1
%setup -q
%build
autoreconf --install
export V=1
%configure \
--with-openssl \
%if %{with zlib}
--with-zlib \
%endif
%if %{with xz}
--with-xz \
%endif
%if %{with zstd}
--with-zstd \
%endif
--enable-debug
%{make_build} V=1
--with-xz
make %{?_smp_mflags}
%install
%{make_install}
pushd $RPM_BUILD_ROOT%{_mandir}/man5
make install DESTDIR=$RPM_BUILD_ROOT
pushd $RPM_BUILD_ROOT/%{_mandir}/man5
ln -s modprobe.d.5.gz modprobe.conf.5.gz
popd
find %{buildroot} -type f -name "*.la" -delete
rm -rf $RPM_BUILD_ROOT%{_libdir}/*.la
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
ln -sf ../bin/kmod $RPM_BUILD_ROOT%{_sbindir}/modprobe
ln -sf ../bin/kmod $RPM_BUILD_ROOT%{_sbindir}/modinfo
ln -sf ../bin/kmod $RPM_BUILD_ROOT%{_sbindir}/insmod
ln -sf ../bin/kmod $RPM_BUILD_ROOT%{_sbindir}/rmmod
ln -sf ../bin/kmod $RPM_BUILD_ROOT%{_sbindir}/depmod
ln -sf ../bin/kmod $RPM_BUILD_ROOT%{_sbindir}/lsmod
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/modprobe.d
%if %{with weak_modules}
install -pm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules
%endif
mkdir -p $RPM_BUILD_ROOT/sbin
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules
%if %{with dist_conf}
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%endif
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%dir %{_sysconfdir}/depmod.d
%dir %{_sysconfdir}/modprobe.d
%dir %{_prefix}/lib/modprobe.d
@ -173,23 +93,14 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%{_sbindir}/rmmod
%{_sbindir}/lsmod
%{_sbindir}/depmod
%if %{with weak_modules}
%{_sbindir}/weak-modules
%endif
%{_datadir}/bash-completion/
%{_datadir}/fish/vendor_functions.d/*
%{_datadir}/zsh/site-functions/*
%if %{with dist_conf}
%{_sysconfdir}/depmod.d/dist.conf
%endif
%{_datadir}/pkgconfig/kmod.pc
%attr(0644,root,root) %{_mandir}/man5/mod*.d*.5*
%attr(0644,root,root) %{_mandir}/man5/depmod.d.5*
%{_mandir}/man5/modprobe.conf.5*
%attr(0644,root,root) %{_mandir}/man5/*.5*
%attr(0644,root,root) %{_mandir}/man8/*.8*
%doc NEWS README.md
%doc NEWS README TODO
%files libs
%{!?_licensedir:%global license %%doc}
%license COPYING
%{_libdir}/libkmod.so.*
@ -199,165 +110,6 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%{_libdir}/libkmod.so
%changelog
* Wed Aug 13 2025 Zamir SUN <zsun@fedoraproject.org> - 34.2-3
- Rebuild to switch gating to TMT.
- Resolves: rhbz#2382934
* Thu Jul 24 2025 Fedora Release Engineering <releng@fedoraproject.org> - 34.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Mon Mar 31 2025 Josh Boyer <jwboyer@fedoraproject.org> - 34.2-1
- New upstream v34.2
- Resolves: rhbz#2355680
* Sat Mar 08 2025 Josh Boyer <jwboyer@fedoraproject.org> - 34.1-1
- New upstream v34.1
- Resolves: rhbz#2350269
* Mon Feb 24 2025 Josh Boyer <jwboyer@fedoraproject.org>
- New upstream v34
- Resolves: rhbz#2347049
* Fri Jan 17 2025 Fedora Release Engineering <releng@fedoraproject.org> - 33-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Sun Jan 12 2025 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 33-2
- Rebuilt for the bin-sbin merge (2nd attempt)
* Thu Aug 15 2024 Eugene Syromiatnikov <esyr@redhat.com> - 33-1
- New upstream v33
- Resolves: rhbz#2268030
* Mon Aug 12 2024 Eugene Syromiatnikov <esyr@redhat.com> - 31-8
- weak-modules: use either zcat or xzcat based on symvers file extension
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 31-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Thu Apr 11 2024 Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl> - 31-6
- Prepare for %%_bindir==%%_sbindir
* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 31-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 31-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Fri Dec 01 2023 Eugene Syromiatnikov <esyr@redhat.com> - 31-3
- migrated to SPDX license
* Thu Nov 09 2023 Josh Boyer <jwboyer@fedoraproject.org> - 31-2
- Add upstream patches to enable SHA3 support
- New upstream v31
- Resolves: rhbz#2241394
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 30-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Tue May 09 2023 Eugene Syromiatnikov <esyr@redhat.com> - 30-5
- Add symvers.xz support to weak-modules
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 30-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Sat Dec 17 2022 Florian Weimer <fweimer@redhat.com> - 30-3
- Port configure script to C99
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 30-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Mon Jul 4 2022 Yauheni Kaliuta <ykaliuta@redhat.com> - 30-1
- New upstream v30
- Resolves: rhbz#2102796
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 29-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Tue Sep 14 2021 Sahana Prasad <sahana@redhat.com> - 29-6
- Rebuilt with OpenSSL 3.0.0
* Tue Aug 10 2021 Yauheni Kaliuta <ykaliuta@redhat.com> - 29-5
- kmod.spec: enable debug
- weak-modules: compare_initramfs_modules: exit on pushd/popd failures
- weak-modules: split modules into array with read -a
- Add default config file, /etc/depmod.d/dist.conf
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 29-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Jun 08 2021 Neal Gompa <ngompa13@gmail.com> - 29-3
- Fix conditional to only install weak-modules for RHEL
* Tue May 25 2021 Justin M. Forbes <jforbes@fedoraproject.org> - 29-2
- Rebuild for weak-modules drop in Fedora
* Mon May 24 2021 Justin M. Forbes <jforbes@fedoraproject.org>
- Remove weak-modules for Fedora as it causes problems.
* Fri May 14 2021 Josh Boyer <jwboyer@fedoraproject.org> - 29-1
- New upstream v29
- Resolves: rhbz#1962980
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 28-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Thu Jan 07 2021 Josh Boyer <jwboyer@fedoraproject.org> - 28-1
- New upstream v28
- Enable zstd support
- Resolves: rhbz#1913949
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 27-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Mar 25 2020 Yauheni Kaliuta <ykaliuta@fedoraproject.org> - 27-2
- add 0001-depmod-do-not-output-.bin-to-stdout.patch
Resolves: rhbz#1808430
* Thu Feb 20 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 27-1
- New upstream v27
* Mon Jan 20 2020 Yauheni Kaliuta <ykaliuta@fedoraproject.org> - 26-5
- weak-modules: sync with RHEL
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 26-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Mon Feb 25 2019 Yauheni Kaliuta <yauheni.kaliuta@redhat.com> - 26-3
- weak-modules: sync with RHEL
* Sun Feb 24 2019 Yauheni Kaliuta <ykaliuta@fedoraproject.org> - 26-2
- add PKCS7/openssl support (rhbz 1320921)
* Sun Feb 24 2019 Yauheni Kaliuta <ykaliuta@fedoraproject.org> - 26-1
- Update to version 26 (rhbz 1673749)
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 25-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Oct 29 2018 James Antill <james.antill@redhat.com> - 25-4
- Remove ldconfig scriptlet, now done via. transfiletrigger in glibc (rhbz 1644063)
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 25-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 25-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Tue Jan 09 2018 Josh Boyer <jwboyer@fedoraproject.org> - 25-1
- Update to version 25 (rhbz 1532597)
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 24-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 24-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Fri Feb 24 2017 Josh Boyer <jwboyer@fedoraproject.org> - 24-1
- Update to version 24 (rhbz 1426589)
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 23-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Fri Jul 22 2016 Josh Boyer <jwboyer@fedoraproject.org> - 23-1
- Update to version 23

View file

@ -1 +1 @@
SHA512 (kmod-34.2.tar.xz) = 0e095c45ad61a6c61ce1ad61b9aa10cf5040e688b749f9a933b0e7d12de493c58027a5068b459cbbce05576fc564a22b83a3dbef1e6511b2a3e27034c88afd33
3cf469f40ec2ed51f56ba45ea03793e7 kmod-23.tar.xz

View file

@ -1,3 +0,0 @@
test: bash ./runtest.sh
framework: beakerlib
duration: 15m

View file

@ -1,14 +0,0 @@
[General]
name=libkmod gating test
owner=Susant Sahani <susant@redhat.com>
description=libkmod gating test
license=GPLv2
confidential=no
destructive=no
[restraint]
entry_point=./runtest.sh
max_time=15m
use_pty=false
dependencies=gcc,make,libcmocka-devel,kmod-devel

View file

@ -1,37 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of libkmod
# Description: Tests for libkmod.
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="kmod-devel"
IPIP="/usr/lib/modules/$(uname -r)/kernel/net/ipv4/ipip.ko.xz"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlAssertExists "$IPIP"
rlRun "gcc -o test-libkmod test-libkmod.c -lkmod -lcmocka"
rlRun "cp test-libkmod /usr/bin/"
rlPhaseEnd
rlPhaseStartTest
rlLog "Starting libkmod tests ..."
rlRun "/usr/bin/test-libkmod"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/test-libkmod"
rlLog "libkmod tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View file

@ -1,79 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1+
# ~~~
# Description: Tests libkmod
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libkmod.h>
#include <setjmp.h>
#include <inttypes.h>
#include <cmocka.h>
static int load_module(void **state) {
struct kmod_list *list = NULL;
struct kmod_ctx *ctx = NULL;
struct kmod_list *l;
int r;
assert_non_null((ctx = kmod_new(NULL, NULL)));
assert_return_code(kmod_module_new_from_lookup(ctx, "ipip", &list), 0);
kmod_list_foreach(l, list) {
struct kmod_module *mod = NULL;
mod = kmod_module_get_module(l);
assert_non_null(mod);
assert_return_code(kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL), 0);
}
free(ctx);
return 0;
}
static int remove_module(void **state) {
struct kmod_list *list = NULL;
struct kmod_ctx *ctx = NULL;
struct kmod_list *l;
int r;
assert_non_null((ctx = kmod_new(NULL, NULL)));
assert_return_code(kmod_module_new_from_lookup(ctx, "ipip", &list), 0);
kmod_list_foreach(l, list) {
struct kmod_module *mod = NULL;
mod = kmod_module_get_module(l);
assert_non_null(mod);
assert_return_code(kmod_module_remove_module(mod, 0), 0);
}
free(ctx);
return 0;
}
void test_load_module(void **state) {
load_module(NULL);
}
void test_remove_module(void **state) {
remove_module(NULL);
}
int main(int argc, char *argv[]) {
const struct CMUnitTest libmod_tests[] = {
cmocka_unit_test_teardown(test_load_module, remove_module),
cmocka_unit_test_setup(test_remove_module, load_module),
};
return cmocka_run_group_tests(libmod_tests, NULL, NULL);
}

View file

@ -1,10 +0,0 @@
prepare:
how: install
package:
- libcmocka-devel
- make
- gcc
discover:
how: fmf
execute:
how: tmt

View file

@ -1,4 +0,0 @@
Defaults to testing currently running kernel modules tools on all architectures.
The test runs on any architecture, check normal kernel modules and compressed kernel modules for sanity

View file

@ -1,8 +0,0 @@
#This file was generated automatically,do not manually change it.
export TOPLEVEL_NAMESPACE=kernel
export PKG_NAMESPACE=kernel/general
export RELATIVE_PATH=kmod/sanity
export PACKAGE=general
export PACKAGE_NAME=general
export PKG_LIST=
export TEST=/kernel/general/kmod/sanity

View file

@ -1,258 +0,0 @@
#!/bin/bash
dir_extra=/usr/lib/modules/$(uname -r)/extra
dir_updates=/usr/lib/modules/$(uname -r)/updates
dir_weak_updates=/usr/lib/modules/$(uname -r)/weak-updates
kmods=(base kmod_test_force kmod_test)
function kmod_log_warn()
{
echo "WARN: $*"
}
function kmod_log_pass()
{
echo "PASS: $*"
}
function kmod_log_fail()
{
echo "FAIL: $*"
}
function kmod_log_info()
{
echo "INFO: $*"
}
function kmod_log_err()
{
echo "ERR: $*"
}
function kmod_verify_exist()
{
local files=$*
local ret=0
local msg=0
local f=
for f in $files; do
if ! test -f $f; then
ret=$((ret + 1))
continue
fi
done
return $ret
}
function kmod_verify_loaded()
{
local kmods=$*
local ret=$?
for kmod in $kmods; do
lsmod | grep -w ${kmod/.ko/}
if [ $? -ne 0 ]; then
ret=$((ret+1))
continue
fi
done
return $ret
}
# tainted should be shown
function kmod_verify_dmesg()
{
local str="$1"
dmesg | grep -i "$str"
return $?
}
function kmod_verify_tainted()
{
local kmod=$1
shift
local taint_expect=$*
local ret=0
local checker=./parse_taint.sh
local tainted=$(cat /proc/sys/kernel/tainted)
kmod_log_info "Kernel taint value: $tainted"
local flag=
for flag in $taint_expect; do
$checker $tainted | grep -we $flag || ret=$((ret + 1))
done
return $ret
}
function kmod_verify_tainted_module()
{
local kmod=$1
shift
local taint_expect="$*"
local ret=0
if ! test -f /sys/module/$kmod/taint; then
kmod_log_info "Kmod taint value on module $kmod not supported"
kmod_log_info "$(ls /sys/module/$kmod/)"
return 0
fi
local kmod_tainted=$(cat /sys/module/$kmod/taint)
ret=$(( $ret + 1 ))
kmod_log_info "Kmod taint value: $kmod_tainted"
local flag=
local grep_exec="grep"
for flag in $*; do
grep_exec+=" -e $flag"
done
echo "$kmod_tainted" | $grep_exec
ret=$?
return $ret
}
function kmod_check_result()
{
local opt=$1
shift 1
local dir=$1
shift 1
local files=$*
case $opt in
compile)
for f in $files; do
if kmod_verify_exist $dir/$f; then
kmod_log_pass "File exist: $dir/$f"
else
kmod_log_fail "File does not exist: $dir/$f"
return 1
fi
done
;;
load)
for f in $files; do
if kmod_verify_loaded $f; then
kmod_log_fail $f not loaded
return 1
else
kmod_log_pass $f loaded
fi
done
;;
unload)
for f in $files; do
if ! kmod_verify_loaded $f; then
kmod_log_fail $f unloaded
return 1
else
kmod_log_pass $f not loaded
fi
done
;;
*)
;;
esac
return 0
}
# Locate the compiled kmods into several dirs for different
# tests.
function kmod_locate_extra()
{
local ret=0
if ! test -d $dir_extra; then
kmod_log_warn "$dir_extra does not exist."
return 1
fi
local f=
for f in $*; do
cp -f $f $dir_extra || ret=$((ret + 1))
done
depmod || ret=$((ret+1))
return $ret
}
function kmod_locate_updates()
{
local ret=0
if ! test -d $dir_updates; then
kmod_log_warn "$dir_updates does not exist."
return 1
fi
for f in $*; do
cp -f $f $dir_updates || ret=$((ret + 1))
done
depmod || ret=$((ret+1))
return $ret
}
function kmod_locate_weak_updates()
{
local ret=0
if ! test -d $dir_weak_updates; then
kmod_log_warn "$dir_weak_updates does not exist."
return 1
fi
for f in $*; do
cp -f $f $dir_weak_updates || ret=$((ret + 1))
done
depmod || ret=$((ret+1))
return $ret
}
function kmod_cleanup_all()
{
local ret=$?
for ko in ${kmod[*]}; do
test -f $dir_extra/${ko}.ko && rm -r $dir_extra/${ko}.ko
test -f $dir_weak_updates/${ko}.ko && rm -r $dir_weak_updates/${ko}.ko
test -f $dir_updates/${ko}.ko && rm -r $dir_extra/${ko}.ko
done
}
# The kmods should be loaded now.
function kmod_check_all_loaded()
{
local ret=$?
lsmod | grep base -w
ret=$(($ret + $?))
lsmod | grep -w kmod_test_dependency
ret=$(($ret + $?))
lsmod | grep -w kmod_test_force
ret=$(($ret + $?))
return $ret
}
function kmod_unload_all()
{
local ret=0
lsmod | grep -w kmod_test_force && rmmod kmod_test_force
lsmod | grep -w base && rmmod base
! lsmod | grep -w base
ret=$(($ret | $?))
! lsmod | grep -w kmod_test_force
ret=$(($ret | $?))
return $ret
}
function kmod_load_all()
{
local kmod=
kmod_unload_all || return $?
for kmod in $*; do
modprobe $kmod || return $?
done
}
function kmod_load_all_force()
{
local kmod=
kmod_unload_all || return $?
for kmod in $*; do
modprobe -f $kmod || return $?
dmesg | tail -n 10
done
}

View file

@ -1,12 +0,0 @@
[General]
name=kmod gating test
owner=Ziqian SUN <zsun@redhat.com>
description=kmod gating test
license=GPLv2
confidential=no
destructive=no
[restraint]
entry_point=./runtest.sh
max_time=15m
use_pty=false

View file

@ -1,70 +0,0 @@
# /bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright (c) 2015 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# Author: Chunyu Hu <chuhu@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
taint_mask=(
[0]="P (G=Gnu)TAINT_PROPRIETARY_MODULE"
[1]="F TAINT_FORCED_MODULE"
[2]="S TAINT_UNSAFE_SMP"
[3]="R TAINT_FORCED_RMMOD"
[4]="M TAINT_MACHINE_CHECK"
[5]="B TAINT_BAD_PAGE"
[6]="U TAINT_USER"
[7]="D TAINT_DIE"
[8]="A TAINT_OVERRIDDEN_ACPI_TABLE"
[9]="W TAINT_WARN"
[10]="C TAINT_CRAP"
[11]="I TAINT_FIRMWARE_WORKAROUND"
[12]="O TAINT_OOT_MODULE [RHEL7 ONLY]"
[13]="E TAINT_UNSIGNED_MODULE"
[14]="L TAINT_SOFTLOCKUP"
[15]="K TAINT_LIVEPATCH"
[16]="? TAINT_16"
[17]="? TAINT_17"
[18]="? TAINT_18"
[19]="? TAINT_19"
[20]="? TAINT_20"
[21]="? TAINT_21"
[22]="? TAINT_22"
[23]="? TAINT_23"
[24]="? TAINT_24"
[25]="? TAINT_25"
[26]="? TAINT_26"
[27]="? TAINT_BIT_BY_ZOMBIE"
[28]="H TAINT_HARDWARE_UNSUPPORTED"
[29]="T TAINT_TECH_PREVIEW"
[30]="? TAINT_RESERVED30"
[31]="? TAINT_RESERVED31"
)
function parse_taint(){
for mask in ${!taint_mask[*]};do
if (( ((1<<mask)) & taint_val )); then
echo "bit$mask: $((1<<mask)) ${taint_mask[$mask]}" |
awk '{printf "%-7s %-13s %-5s %s\n", $1 ,$2, $3, $4, $5, $6}'
fi
done
}
echo "Input: $taint_val"
taint_val=${1:-$(cat /proc/sys/kernel/tainted)}
parse_taint "$taint_val" | awk 'BEGIN{sum=0}{sum+=$2;print}END{printf "Sum: ";print sum}'

View file

@ -1,134 +0,0 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of kmod/sanity
# Description: Checking the basic function of kmod
# Author: Shaohui Deng <shdeng@redhat.com>
# Author: Chunyu Hu <chuhu@redhat.com>
# Update: Ziqian SUN <zsun@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
. lib.sh
PACKAGE="kmod"
if [ -z $TESTARGS ]; then
export TESTARGS=$(rpm -q --queryformat '%{version}-%{release}\n' -qf /boot/config-$(uname -r))
fi
name=kernel
version=$(echo $TESTARGS | awk 'BEGIN {FS="-"} {print $1 }')
release=$(echo $TESTARGS | awk 'BEGIN {FS="-"} {print $2 }')
DEBUG=0
result=FAIL
FAIL=0
PASS=0
arch=`uname -m`
export TESTS=${TESTS:-kmod_load_insmod kmod_load_modprobe kmod_modinfo}
# Functions
function kmod_load_insmod()
{
local m
for m in ${existed_unloaded}; do
#local m_name=$(basename ${m//.ko}) won't work for compressed kmod
local m_name=$(basename ${m} | sed "s/.ko//;s/.xz//;s/.gz//")
rlRun "insmod $mod_path/$m"
rlRun "lsmod | grep ${m_name}"
rlRun "rmmod ${m_name}"
rlRun "lsmod | grep ${m_name}" 1-255
done
}
function kmod_load_modprobe()
{
rlRun "modprobe tun"
rlRun "modprobe -r tun"
}
function kmod_modinfo()
{
for m in ${existed_unloaded}; do
local m_name=$(basename ${m} | sed "s/.ko//;s/.xz//;s/.gz//")
rlRun "modinfo -l $m_name"
done
}
RunKmod() {
local tests
for tests in $@; do
rlPhaseStartTest $tests
case $tests in
load_unload_kernel_modules)
load_unload_kernl_modules_func
;;
load_unload_compressed_kernel_modules)
load_unload_compressed_kernel_module_func
;;
*)
$tests
;;
esac
rlPhaseEnd
done
}
rlJournalStart
rlPhaseStartSetup
mod_list="/kernel/net/ipv4/udp_tunnel.ko /kernel/net/wireless/lib80211.ko /kernel/net/wireless/ath/ath9k/ath9k.ko /kernel/net/ipv4/udp_tunnel.ko.xz /kernel/net/wireless/lib80211.ko.xz /kernel/net/wireless/ath/ath9k/ath9k.ko.xz"
if [[ -L /lib && -d /lib ]]; then
mod_path=/usr/lib/modules/`uname -r`/
else
mod_path=/lib/modules/`uname -r`/
fi
existed_unloaded=""
local m
for m in ${mod_list}; do
test -f $mod_path/$m && existed_unloaded+="$m "
done
[ -z "$existed_unloaded" ] && rlDie "There is no right module path to use : $mod_list"
rlPhaseEnd
rlPhaseStartTest
RunKmod $TESTS
rlPhaseEnd
if ! (lsmod | grep gre)
then
wparam="gre"
elif ! (lsmod | grep uwb)
then
wparam="uwb"
else
wparam="atm"
fi
rlPhaseStartTest "Modprobe with wrong parameter"
rlRun -l "modprobe $wparam BADPARAM=this_should_fail" 0-1
rlRun -l "dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep '$wparam'"
rlPhaseEnd
rlPhaseStartCleanup
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -1,3 +0,0 @@
test: bash ./runtest.sh
framework: beakerlib
duration: 15m

File diff suppressed because it is too large Load diff