kmod/tests/sanity/Makefile
Susant Sahani f85d022c8b CI: Add libkmod to tests.
1. Fix sanity tests.

2. Add libkmod to test
```
gcc   -o test-libkmod test-libkmod.c -lkmod -lcmocka
./runtest.sh

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   TEST PROTOCOL
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    Package       : kmod-devel
    Installed     : kmod-devel-25-2.fc28.x86_64
    beakerlib RPM : beakerlib-1.17-13.fc28.noarch
    Test version  : 1.0
    Test started  : 2018-06-21 20:07:27 IST
    Test finished :
    Test duration :
    Test name     : /CoreOS/libkmod
    Distro        : Fedora release 28 (Twenty Eight)
    Hostname      : Zeus
    Architecture  : x86_64
    CPUs          : 8 x Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
    RAM size      : 31542 MB
    HDD size      : 452.94 GB

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Setup
::   Setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [ 20:07:27 ] :: [   PASS   ] :: File /usr/lib/modules/4.16.15-300.fc28.x86_64/kernel/net/ipv4/ipip.ko.xz should exist
:: [ 20:07:27 ] :: [  BEGIN   ] :: Running 'cp test-libkmod /usr/bin/'
:: [ 20:07:27 ] :: [   PASS   ] :: Command 'cp test-libkmod /usr/bin/' (Expected 0, got 0)
:: [ 20:07:27 ] :: [   PASS   ] :: Command 'cp test-libkmod /usr/bin/' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 3 good, 0 bad
::   Assertions: 3 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Test
::   Test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:27 ] :: [   LOG    ] :: Starting libkmod tests ...
:: [ 20:07:27 ] :: [   LOG    ] :: Starting libkmod tests ...
:: [ 20:07:27 ] :: [  BEGIN   ] :: Running '/usr/bin/test-libkmod'
[==========] Running 2 test(s).
[ RUN      ] test_load_module
[       OK ] test_load_module
[ RUN      ] test_remove_module
[       OK ] test_remove_module
[==========] 2 test(s) run.
[  PASSED  ] 2 test(s).
:: [ 20:07:27 ] :: [   PASS   ] :: Command '/usr/bin/test-libkmod' (Expected 0, got 0)
:: [ 20:07:27 ] :: [   PASS   ] :: Command '/usr/bin/test-libkmod' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 1 good, 0 bad

```

SANITY:
```
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   kmod_load_insmod
::   kmod_load_insmod
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/ipv4/udp_tunnel.ko.xz'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/ipv4/udp_tunnel.ko.xz' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/ipv4/udp_tunnel.ko.xz' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'lsmod | grep udp_tunnel'
udp_tunnel             16384  0
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'rmmod udp_tunnel'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'lsmod | grep udp_tunnel'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep udp_tunnel' (Expected 1-255, got 1)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep udp_tunnel' (Expected 1-255, got 1)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/wireless/lib80211.ko.xz'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/wireless/lib80211.ko.xz' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/wireless/lib80211.ko.xz' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'lsmod | grep lib80211'
lib80211               16384  0
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'rmmod lib80211'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'lsmod | grep lib80211'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep lib80211' (Expected 1-255, got 1)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep lib80211' (Expected 1-255, got 1)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 8 good, 0 bad
::   Assertions: 8 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   kmod_load_modprobe
::   kmod_load_modprobe
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'modprobe tun'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe tun' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe tun' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'modprobe -r tun'
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe -r tun' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe -r tun' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 2 good, 0 bad
::   Assertions: 2 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   kmod_modinfo
::   kmod_modinfo
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'modinfo -l udp_tunnel'
GPL
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modinfo -l udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modinfo -l udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'modinfo -l lib80211'
GPL
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modinfo -l lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modinfo -l lib80211' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 2 good, 0 bad
::   Assertions: 2 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 12 good, 0 bad
::   Assertions: 12 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

gre                    16384  0
uwb                    90112  0

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Modprobe with wrong parameter
::   Modprobe with wrong parameter
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'modprobe atm BADPARAM=this_should_fail'
:: [ 20:07:26 ] :: [   LOG    ] :: Output of 'modprobe atm BADPARAM=this_should_fail':
:: [ 20:07:26 ] :: [   LOG    ] :: Output of 'modprobe atm BADPARAM=this_should_fail':
:: [ 20:07:26 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe atm BADPARAM=this_should_fail' (Expected 0-1, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe atm BADPARAM=this_should_fail' (Expected 0-1, got 0)
:: [ 20:07:26 ] :: [  BEGIN   ] :: Running 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm''
[17881.492103] atm: unknown parameter 'BADPARAM' ignored
:: [ 20:07:26 ] :: [   LOG    ] :: Output of 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm'':
:: [ 20:07:26 ] :: [   LOG    ] :: Output of 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm'':
:: [ 20:07:26 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: [17881.492103] atm: unknown parameter 'BADPARAM' ignored
:: [ 20:07:26 ] :: [   LOG    ] :: [17881.492103] atm: unknown parameter 'BADPARAM' ignored
:: [ 20:07:26 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm'' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm'' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Duration: 0s
::   Assertions: 2 good, 0 bad
::   Assertions: 2 good, 0 bad
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   kmod_load_insmod
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [   PASS   ] :: Command 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/ipv4/udp_tunnel.ko.xz' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep udp_tunnel' (Expected 1-255, got 1)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'insmod /usr/lib/modules/4.16.15-300.fc28.x86_64///kernel/net/wireless/lib80211.ko.xz' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'rmmod lib80211' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'lsmod | grep lib80211' (Expected 1-255, got 1)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Assertions: 8 good, 0 bad
::   RESULT: PASS

:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe tun' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe -r tun' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Assertions: 2 good, 0 bad
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   kmod_modinfo
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modinfo -l udp_tunnel' (Expected 0, got 0)
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modinfo -l lib80211' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Assertions: 2 good, 0 bad
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Assertions: 12 good, 0 bad
::   RESULT: PASS

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Modprobe with wrong parameter
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 20:07:26 ] :: [   LOG    ] :: Output of 'modprobe atm BADPARAM=this_should_fail':
:: [ 20:07:26 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'modprobe atm BADPARAM=this_should_fail' (Expected 0-1, got 0)
:: [ 20:07:26 ] :: [   LOG    ] :: Output of 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm'':
:: [ 20:07:26 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:07:26 ] :: [   LOG    ] :: [17881.492103] atm: unknown parameter 'BADPARAM' ignored
:: [ 20:07:26 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:07:26 ] :: [   PASS   ] :: Command 'dmesg | grep -i 'Unknown parameter' | grep 'BADPARAM' | grep 'atm'' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
```
2018-06-21 20:30:24 +05:30

80 lines
2.7 KiB
Makefile

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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)