Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Running 0 tests from 0 test suites. #29

Open
luhaiyong opened this issue Dec 1, 2021 · 1 comment
Open

Running 0 tests from 0 test suites. #29

luhaiyong opened this issue Dec 1, 2021 · 1 comment

Comments

@luhaiyong
Copy link

luhaiyong commented Dec 1, 2021

first .i do it from the guide https://blogs.oracle.com/linux/post/writing-kernel-tests-with-the-new-kernel-test-framework-ktf
has some errors:
/home/luhy/build/3.10.0-1160.36.2.el7.x86_64/kernel/ktf_nl.c:70:8: error: ‘GENL_ID_GENERATE’ undeclared here (not in a function)
.id = GENL_ID_GENERATE,
^
/home/luhy/build/3.10.0-1160.36.2.el7.x86_64/kernel/ktf_nl.c: In function ‘ktf_nl_register’:
/home/luhy/build/3.10.0-1160.36.2.el7.x86_64/kernel/ktf_nl.c:525:2: error: implicit declaration of function ‘genl_register_family_with_ops’ [-Werror=implicit-function-declaration]
int stat = genl_register_family_with_ops(&ktf_gnl_family, ktf_ops,

then i fixed it as bellow
int ktf_nl_register(void)
{
#if 0
//#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 7))
int stat = genl_register_family_with_ops(&ktf_gnl_family, ktf_ops,
ARRAY_SIZE(ktf_ops));
#else
int stat = genl_register_family(&ktf_gnl_family);
#endif
return stat;
}

static struct genl_family ktf_gnl_family = {
#if 0//(KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE)
.id = GENL_ID_GENERATE,
#else
.module = THIS_MODULE,
#endif

then fix the erros and build out the ktf.ko
next , i run the examples .
the follow as bellow

[luhy@localhost 3.10.0-1160.36.2.el7.x86_64]$ sudo insmod examples/hello.ko
[luhy@localhost 3.10.0-1160.36.2.el7.x86_64]$ sudo insmod examples/h2.ko
[luhy@localhost 3.10.0-1160.36.2.el7.x86_64]$ sudo insmod examples/h3.ko
[luhy@localhost 3.10.0-1160.36.2.el7.x86_64]$ sudo insmod skbtest/kernel/skbtest.ko
[luhy@localhost 3.10.0-1160.36.2.el7.x86_64]$ lsmod |grep ktf
ktf 41039 4 h2,h3,hello,skbtest
[luhy@localhost 3.10.0-1160.36.2.el7.x86_64]$ ktfrun
[==========] Running 0 tests from 0 test suites.
[==========] 0 tests from 0 test suites ran. (0 ms total)
[ PASSED ] 0 tests.

dmesg log:
[16784.205329] ktf pid [9281] hello_init: hello: loaded

what's wrong

@knuto
Copy link
Contributor

knuto commented Dec 10, 2021

Hmm - to the compiler issues you experience - for heavily patched kernels that deviates a lot from the upstream kernels with the same numbering, there's no really good solution other than possibly more #if - #else cases that captures what sort of changes that have been incorporated. The autoconf way - to compile a program and capture the output to see what happens could possibly have been applied but it will require quite some work to do this reliably on kernel files, and it is likely also error prone.

Wrt that you see no tests registered, the first thing to try would be to run ktfrun --gtest_list_tests to see if the tests got registered and that communication with KTF from user space is working.

You could also try to enable more KTF test debug flags (set them all) and see if the log gives you some more clues. It could be that features we rely upon is not available to us or behave differently in this kernel.
Turning on logs should tell you more, for instance whether the netlink messages to execute tests actually reaches KTF.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants