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)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
```
This commit is contained in:
Susant Sahani 2018-06-21 20:07:54 +05:30
parent b589e5d5fd
commit f85d022c8b
6 changed files with 167 additions and 5 deletions

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);
}

View File

@ -76,6 +76,4 @@ $(METADATA): Makefile
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "RhtsRequires: kernel-kernel-general-include" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -28,7 +28,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
. lib.sh
@ -133,4 +132,3 @@ rlJournalStart
rlJournalPrintText
rlJournalEnd

View File

@ -5,9 +5,14 @@
- role: standard-test-beakerlib
tests:
- sanity
- libkmod
required_packages:
- kernel
- perf
- sysstat
- trace-cmd
- kmod
- kmod-devel
- gcc
- libcmocka
- libcmocka-devel