kmod/tests/libkmod
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
..
Makefile CI: Add libkmod to tests. 2018-06-21 20:30:24 +05:30
runtest.sh CI: Add libkmod to tests. 2018-06-21 20:30:24 +05:30
test-libkmod.c CI: Add libkmod to tests. 2018-06-21 20:30:24 +05:30