RHEL 9.0.0 Alpha bootstrap

The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/kmod#bddd48bb1f02b70118e3a0b652848567edac13b0
This commit is contained in:
Petr Šabata 2020-10-15 15:03:55 +02:00
parent 98c736cb8e
commit c62209c195
15 changed files with 2328 additions and 0 deletions

21
.gitignore vendored
View File

@ -0,0 +1,21 @@
/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
/kmod-24.tar.xz
/kmod-25.tar.xz
/kmod-26.tar.xz
/kmod-27.tar.xz

View File

@ -0,0 +1,53 @@
From 53b30aeba2dedae9f5558f560231d9462e063dfc Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Thu, 5 Mar 2020 13:33:10 -0800
Subject: [PATCH] depmod: do not output .bin to stdout
index_write() relies on fseek/ftell to manage the position to which we
are write and thus needs the file stream to support it.
Right now when trying to write the index to stdout we fail with:
depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed.
Aborted (core dumped)
We have no interest in outputting our index to stdout, so just skip it
like is done with other indexes.
While at it, add/remove some newlines to improve readability.
Reported-by: Yanko Kaneti <yaneti@declera.com>
Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
---
tools/depmod.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index fbbce10eb0db..875e31480818 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2408,8 +2408,10 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
struct index_node *idx;
struct kmod_list *l, *builtin = NULL;
- idx = index_create();
+ if (out == stdout)
+ return 0;
+ idx = index_create();
if (idx == NULL) {
ret = -ENOMEM;
goto fail;
@@ -2456,7 +2458,9 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (count)
index_write(idx, out);
+
index_destroy(idx);
+
fail:
if (builtin)
kmod_module_unref_list(builtin);
--
2.25.0

322
kmod.spec Normal file
View File

@ -0,0 +1,322 @@
Name: kmod
Version: 27
Release: 3%{?dist}
Summary: Linux kernel module management utilities
License: GPLv2+
URL: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary
Source0: https://www.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.tar.xz
Source1: weak-modules
Exclusiveos: Linux
Patch01: 0001-depmod-do-not-output-.bin-to-stdout.patch
BuildRequires: gcc
BuildRequires: chrpath
BuildRequires: zlib-devel
BuildRequires: xz-devel
BuildRequires: libxslt
BuildRequires: openssl-devel
Provides: module-init-tools = 4.0-1
Obsoletes: module-init-tools < 4.0-1
Provides: /sbin/modprobe
%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
as other module management programs. Device drivers and filesystems are two
examples of loaded and unloaded modules.
%package libs
Summary: Libraries to handle kernel module loading and unloading
License: LGPLv2+
%description libs
The kmod-libs package provides runtime libraries for any application that
wishes to load or unload Linux kernel modules from the running system.
%package devel
Summary: Header files for kmod development
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%description devel
The kmod-devel package provides header files used for development of
applications that wish to load or unload Linux kernel modules.
%prep
%autosetup -p1
%build
%configure \
--with-openssl \
--with-zlib \
--with-xz
%{make_build} V=1
%install
%{make_install}
pushd $RPM_BUILD_ROOT/%{_mandir}/man5
ln -s modprobe.d.5.gz modprobe.conf.5.gz
popd
find %{buildroot} -type f -name "*.la" -delete
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
mkdir -p $RPM_BUILD_ROOT/sbin
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules
%files
%dir %{_sysconfdir}/depmod.d
%dir %{_sysconfdir}/modprobe.d
%dir %{_prefix}/lib/modprobe.d
%{_bindir}/kmod
%{_sbindir}/modprobe
%{_sbindir}/modinfo
%{_sbindir}/insmod
%{_sbindir}/rmmod
%{_sbindir}/lsmod
%{_sbindir}/depmod
%{_sbindir}/weak-modules
%{_datadir}/bash-completion/
%attr(0644,root,root) %{_mandir}/man5/*.5*
%attr(0644,root,root) %{_mandir}/man8/*.8*
%doc NEWS README TODO
%files libs
%license COPYING
%{_libdir}/libkmod.so.*
%files devel
%{_includedir}/libkmod.h
%{_libdir}/pkgconfig/libkmod.pc
%{_libdir}/libkmod.so
%changelog
* 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
* Thu Feb 25 2016 Peter Robinson <pbrobinson@fedoraproject.org> 22-4
- Add powerpc patch to fix ToC on 4.5 ppc64le kernel
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 22-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Thu Jan 07 2016 Josh Boyer <jwboyer@fedoraproject.org> - 22-2
- Fix path to dracut in weak-modules (rhbz 1295038)
* Wed Nov 18 2015 Josh Boyer <jwboyer@fedoraproject.org> - 22-1
- Update to version 22
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 21-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Mon Jun 15 2015 Ville Skyttä <ville.skytta@iki.fi> - 21-2
- Own bash completion dirs not owned by anything in dep chain
* Tue Jun 09 2015 Josh Boyer <jwboyer@fedoraproject.org> - 21-1
- Update to verion 21
* Mon Mar 02 2015 Josh Boyer <jwboyer@fedoraproject.org> - 20.1
- Update to version 20
* Sat Feb 21 2015 Till Maas <opensource@till.name> - 19-2
- Rebuilt for Fedora 23 Change
https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code
* Sun Nov 16 2014 Josh Boyer <jwboyer@fedoraproject.org> - 19-1
- Update to version 19
* Wed Oct 29 2014 Josh Boyer <jwboyer@fedoraproject.org> - 18-4
- Backport patch to fix device node permissions (rhbz 1147248)
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 18-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sat Jul 12 2014 Tom Callaway <spot@fedoraproject.org> - 18-2
- fix license handling
* Tue Jun 24 2014 Josh Boyer <jwboyer@fedoraproject.org> - 18-1
- Update to version 18
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed Apr 09 2014 Josh Boyer <jwboyer@fedoraproject.org> - 17-1
- Update to version 17
* Thu Jan 02 2014 Václav Pavlín <vpavlin@redhat.com> - 16-1
- Update to version 16
* Thu Aug 22 2013 Josh Boyer <jwboyer@fedoraproject.org> - 15-1
- Update to version 15
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 14-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Fri Jul 05 2013 Josh Boyer <jwboyer@redhat.com> - 14-1
- Update to version 14
* Fri Apr 19 2013 Václav Pavlín <vpavlin@redhat.com> - 13-2
- Main package should require -libs
* Wed Apr 10 2013 Josh Boyer <jwboyer@redhat.com> - 13-1
- Update to version 13
* Wed Mar 20 2013 Weiping Pan <wpan@redhat.com> - 12-3
- Pull in weak-modules for kABI from Jon Masters <jcm@redhat.com>
* Mon Mar 18 2013 Josh Boyer <jwboyer@redhat.com>
- Add patch to make rmmod understand built-in modules (rhbz 922187)
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Thu Dec 06 2012 Josh Boyer <jwboyer@redhat.com>
- Update to version 12
* Thu Nov 08 2012 Josh Boyer <jwboyer@redhat.com>
- Update to version 11
* Fri Sep 07 2012 Josh Boyer <jwboyer@redaht.com>
- Update to version 10
* Mon Aug 27 2012 Josh Boyer <jwboyer@redhat.com>
- Update to version 9
* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Wed May 23 2012 Josh Boyer <jwboyer@redhat.com> - 8-2
- Provide modprobe.conf(5) (rhbz 824552)
* Tue May 08 2012 Josh Boyer <jwboyer@redhat.com> - 8-1
- Update to version 8
* Mon Mar 19 2012 Kay Sievers <kay@redhat.com> - 7-1
- update to version 7
- fix issue with --show-depends, where built-in
modules of the running kernel fail to include
loadable modules of the kernel specified
* Sun Mar 04 2012 Kay Sievers <kay@redhat.com> - 6-1
- update to version 6
- remove all patches, they are included in the release
* Fri Feb 24 2012 Kay Sievers <kay@redhat.com> - 5-8
- try to address brc#771285
* Sun Feb 12 2012 Kay Sievers <kay@redhat.com> - 5-7
- fix infinite loop with softdeps
* Thu Feb 09 2012 Harald Hoyer <harald@redhat.com> 5-6
- add upstream patch to fix "modprobe --ignore-install --show-depends"
otherwise dracut misses a lot of modules, which are already loaded
* Wed Feb 08 2012 Harald Hoyer <harald@redhat.com> 5-5
- add "lsmod"
* Tue Feb 7 2012 Kay Sievers <kay@redhat.com> - 5-4
- remove temporarily added fake-provides
* Tue Feb 7 2012 Kay Sievers <kay@redhat.com> - 5-3
- temporarily add fake-provides to be able to bootstrap
the new udev which pulls the old udev into the buildroot
* Tue Feb 7 2012 Kay Sievers <kay@redhat.com> - 5-1
- Update to version 5
- replace the module-init-tools package and provide all tools
as compatibility symlinks
* Mon Jan 16 2012 Kay Sievers <kay@redhat.com> - 4-1
- Update to version 4
- set --with-rootprefix=
- enable zlib and xz support
* Thu Jan 05 2012 Jon Masters <jcm@jonmasters.org> - 3-1
- Update to latest upstream (adds new depmod replacement utility)
- For the moment, use the "kmod" utility to test the various functions
* Fri Dec 23 2011 Jon Masters <jcm@jonmasters.org> - 2-6
- Update kmod-2-with-rootlibdir patch with rebuild automake files
* Fri Dec 23 2011 Jon Masters <jcm@jonmasters.org> - 2-5
- Initial build for Fedora following package import
* Thu Dec 22 2011 Jon Masters <jcm@jonmasters.org> - 2-4
- There is no generic macro for non-multilib "/lib", hardcode like others
* Thu Dec 22 2011 Jon Masters <jcm@jonmasters.org> - 2-3
- Update package incorporating fixes from initial review feedback
- Cleaups to SPEC, rpath, documentation, library and binary locations
* Thu Dec 22 2011 Jon Masters <jcm@jonmasters.org> - 2-2
- Update package for posting to wider test audience (initial review submitted)
* Thu Dec 22 2011 Jon Masters <jcm@jonmasters.org> - 2-1
- Initial Fedora package for module-init-tools replacement (kmod) library

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (kmod-27.tar.xz) = e0513094935333fca1fb4c3e3493b232507a579ab00a6457cc9ed3e928363d05aad80634fb65a8287a336bf9895194c7be8ddc41bb088a6c2cca44fc1bfbdb6c

46
tests/libkmod/Makefile Normal file
View File

@ -0,0 +1,46 @@
# SPDX-License-Identifier: LGPL-2.1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/libkmod
# Description: Test if libkmod working ok
# Author: Susant Sahani<susant@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/libkmod
export TESTVERSION=1.0
OBJS = test-libkmod.c
CFLAG = -Wall -g3
CC = gcc
LIBS = -lkmod -lcmocka
test-libkmod:${OBJ}
${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}
run: test-libkmod
./runtest.sh
clean:
-rm -f test-libkmod
.c.o:
${CC} ${CFLAGS} ${INCLUDES} -c $<
CC = gcc
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani<susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test libkmod works ok" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: libkmod" >> $(METADATA)
@echo "Requires: libkmod libkmod-devel" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -Fedora 29" >> $(METADATA)
rhts-lint $(METADATA)

36
tests/libkmod/runtest.sh Executable file
View File

@ -0,0 +1,36 @@
#!/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 "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

@ -0,0 +1,79 @@
/* 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);
}

79
tests/sanity/Makefile Normal file
View File

@ -0,0 +1,79 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of general/kmod/sanity
# Description: kmod test
#
# 2016-07-31
# Author: Chunyu Hu <chuhu@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TENV=_env
ifeq ($(PKG_TOP_DIR),)
export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
[ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
export _TOP_DIR := $(shell p=$$PWD; while :; do \
[ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
-include $(PKG_TOP_DIR)/env.mk
endif
include $(TENV)
ifeq ($(_TOP_DIR),)
_TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
endif
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(TENV) $(METADATA) _env runtest.sh Makefile PURPOSE lib.sh
.PHONY: all install download clean
run: $(FILES) build
( set +o posix; . /usr/bin/rhts_environment.sh; \
. /usr/share/beakerlib/beakerlib.sh; \
. runtest.sh )
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -fr *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Chunyu Hu <chuhu@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: kmod kernel module check from kernel modules tools">> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 1h" >> $(METADATA)
@echo "RunFor: kernel" >> $(METADATA)
@echo "Requires: kernel" >> $(METADATA)
@echo "Requires: sysstat perf trace-cmd" >> $(METADATA)
@echo "Requires: $(PACKAGE_NAME) python rpm wget" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

4
tests/sanity/PURPOSE Normal file
View File

@ -0,0 +1,4 @@
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

8
tests/sanity/_env Normal file
View File

@ -0,0 +1,8 @@
#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

258
tests/sanity/lib.sh Executable file
View File

@ -0,0 +1,258 @@
#!/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
}

70
tests/sanity/parse_taint.sh Executable file
View File

@ -0,0 +1,70 @@
# /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}'

134
tests/sanity/runtest.sh Executable file
View File

@ -0,0 +1,134 @@
#!/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

18
tests/tests.yml Normal file
View File

@ -0,0 +1,18 @@
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-beakerlib
tests:
- sanity
- libkmod
required_packages:
- kernel
- perf
- sysstat
- trace-cmd
- kmod
- kmod-devel
- gcc
- libcmocka
- libcmocka-devel

1199
weak-modules Normal file

File diff suppressed because it is too large Load Diff