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

Duplicate parameterized test name error #15

Open
pfourguet opened this issue Jul 11, 2019 · 3 comments
Open

Duplicate parameterized test name error #15

pfourguet opened this issue Jul 11, 2019 · 3 comments

Comments

@pfourguet
Copy link

Hi,
I'm having some issues executing a simple test with ktf.
I'm cross-compiling ktf for arm64 architecture.
I'm using the latests revisions of KTF and googletest on a 4.14.115 Linux kernel.
After inserting KTF and my test module (insmod ktf.ko; insmod test.ko), i'm trying to list the registered test using the command ktfrun --gtest_list_tests.
ktfrun creates a coredump and gives me the following error:

[ FATAL ] /usr/include/gtest/internal/gtest-param-util.h:562:: Condition test_param_names.count(param_name) == 0 failed. Duplicate parameterized test name 't1', in Aborted (core dumped)

I wasn't able to understand what is going on.
My test source code is the default one created using the ktfnew script.
Activating the debug messages gives me the following messages:

  • KTF userland
    root@tap-00010E5F:~# ktfrun --gtest_list_tests
    Thu Jul 11 13:17:10 2019 [281473665986688] parse_query: Kernel offers 1 test sets:
    Thu Jul 11 13:17:10 2019 [281473665986688] find_add_set: find_add_set(simple)
    Thu Jul 11 13:17:10 2019 [281473665986688] find_add_set: find_add_set(simple)
    Thu Jul 11 13:17:10 2019 [281473665986688] find_add_set: find_add_set(simple)
    Thu Jul 11 13:17:10 2019 [281473665986688] parse_query: Kernel offers 1 test sets:
    Thu Jul 11 13:17:10 2019 [281473665986688] find_add_set: find_add_set(simple)
    Thu Jul 11 13:17:10 2019 [281473665986688] find_add_set: find_add_set(simple)
    Thu Jul 11 13:17:10 2019 [281473665986688] find_add_set: find_add_set(simple)

[ FATAL ] /usr/include/gtest/internal/gtest-param-util.h:562:: Condition test_param_names.count(param_name) == 0 failed. Duplicate parameterized test name 't1', in Aborted (core dumped)

  • KTF kernel space
    [26543.319181] ktf pid [1012] ktf_map_elem_get: Increasing refcount for simple to 3
    [26543.319195] ktf pid [1012] ktf_map_elem_get: Increasing refcount for t1 to 3
    [26543.319202] ktf pid [1012] ktf_map_elem_put: Decreasing refcount for t1 to 2
    [26543.319222] ktf pid [1012] ktf_map_elem_put: Decreasing refcount for simple to 2
    [26543.321428] ktf pid [1012] ktf_map_elem_get: Increasing refcount for simple to 3
    [26543.321442] ktf pid [1012] ktf_map_elem_get: Increasing refcount for t1 to 3
    [26543.321450] ktf pid [1012] ktf_map_elem_put: Decreasing refcount for t1 to 2
    [26543.321455] ktf pid [1012] ktf_map_elem_put: Decreasing refcount for simple to 2

It seems that it acts like the same test was registered twice. But there is only one test in test source code. Here is the test source code as a reminder:
#include <linux/module.h>
#include "ktf.h"

MODULE_LICENSE("GPL");

KTF_INIT();

TEST(simple, t1)
{
EXPECT_TRUE(true);
}

static void add_tests(void)
{
ADD_TEST(t1);
}

static int __init tests_init(void)
{
add_tests();
return 0;
}
static void __exit tests_exit(void)
{
KTF_CLEANUP();
}

module_init(tests_init);
module_exit(tests_exit);

Have you already encountered this type of error ?
Thanks in advance for your help.
Pascal

@knuto
Copy link
Contributor

knuto commented Jul 14, 2019

This code looks fine to me, it also executes perfectly in my setup on x86. I even tried with the latest upstream googletest. Could it be that you already had managed to load another module with a test named "t1"? lsmod | grep ktf should give you the modules you have loaded that depends on ktf.

@pfourguet
Copy link
Author

Hi,
thank you for your answser.
I think i've found my error root cause.
It may be a link error as disabling the use of libktf as a shared library enables me to run ktfrun without error.
I could see in KTF source code that the registration of kernel test is done while initializing the gtest_registering_dummy_ variable. So if the shared ktf library is loaded twice (may be because of the use of preload on my target or to another link problem, still no sure ..), you can get this error (Duplicate parameterized test name).
Pascal

@knuto
Copy link
Contributor

knuto commented Jul 18, 2019

If you still see ktf initialized as a side effect of the gtest_registering_dummy_ variable, you are likely not running off the latest KTF. I had people observing issues with the shared library on Ubuntu, so after some struggles I decided to back out on the completely transparent initialization, and replaced the implicit initialization with a need for a call to ktf::setup(). See commits 20d9cf8 and a8e13f7. I realize the gtest_registering_dummy_ variable is still lingering, but it is no longer used anywhere so it should have been removed. I'll fix that.

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