avocado
avocado copied to clipboard
linux_modules.py: Improve kernel config check
a) Make check_kernel_config supports both host and guest b) Add kconfig_is_{builtin, module, not_set}
Signed-off-by: Liu Yiding [email protected]
Hi, @clebergnu
Thanks for your review and detailed explanatin.
Hi @liuyd96 , thanks for this contribution!
Please take a look at the comments I made, and let's work through the currently identified issues to get this in.
Cheers.
@clebergnu Gently ping ~
Hi, @clebergnu @Naresh-ibm
Really appreciate your comments and detailed explanations. I benefited a lot from it. : )
I did a simple test to verify these changes i made.
(1/7) test_linux_modules.py:Lsmod.test_parse_lsmod: STARTED
(1/7) test_linux_modules.py:Lsmod.test_parse_lsmod: PASS (0.05 s)
(2/7) test_linux_modules.py:Lsmod.test_parse_lsmod_is_empty: STARTED
(2/7) test_linux_modules.py:Lsmod.test_parse_lsmod_is_empty: PASS (0.04 s)
(3/7) test_linux_modules.py:Lsmod.test_parse_lsmod_no_submodules: STARTED
(3/7) test_linux_modules.py:Lsmod.test_parse_lsmod_no_submodules: PASS (0.04 s)
(4/7) test_linux_modules.py:Lsmod.test_parse_lsmod_single_submodules: STARTED
(4/7) test_linux_modules.py:Lsmod.test_parse_lsmod_single_submodules: PASS (0.04 s)
(5/7) test_linux_modules.py:Modules.test_is_module_loaded: STARTED
(5/7) test_linux_modules.py:Modules.test_is_module_loaded: PASS (0.05 s)
(6/7) test_linux_modules.py:Configs.test_local_config_check: STARTED
(6/7) test_linux_modules.py:Configs.test_local_config_check: PASS (0.06 s)
(7/7) test_linux_modules.py:Configs.test_session_config_check: STARTED
(7/7) test_linux_modules.py:Configs.test_session_config_check: PASS (3.95 s)
Test codes like
diff --git a/selftests/unit/utils/test_linux_modules.py b/selftests/unit/utils/test_linux_modules.py
index 4c227236..d39cb167 100644
--- a/selftests/unit/utils/test_linux_modules.py
+++ b/selftests/unit/utils/test_linux_modules.py
@@ -3,6 +3,7 @@ import unittest.mock
from avocado import Test
from avocado.utils import linux_modules
+from avocado.utils import ssh
class Lsmod(Test):
@@ -59,5 +60,26 @@ class Modules(Test):
self.assertFalse(linux_modules.module_is_loaded("unknown_module"))
+class Configs(Test):
+
+ def test_local_config_check(self):
+ self.assertTrue(linux_modules.kconfig_is_builtin('CONFIG_CC_IS_GCC'))
+ self.assertTrue(linux_modules.kconfig_is_module('CONFIG_TIME_KUNIT_TEST'))
+ self.assertTrue(linux_modules.kconfig_is_not_set('CONFIG_AAAAAAAA'))
+ self.assertFalse(linux_modules.kconfig_is_builtin('CONFIG_TIME_KUNIT_TEST'))
+ self.assertFalse(linux_modules.kconfig_is_module('CONFIG_CC_IS_GCC'))
+ self.assertFalse(linux_modules.kconfig_is_not_set('CONFIG_CC_IS_GCC'))
+
+
+ def test_session_config_check(self):
+ with ssh.Session('127.0.0.1', user='root', password='XXX', port=22) as session:
+ self.assertTrue(linux_modules.kconfig_is_builtin('CONFIG_CC_IS_GCC', session))
+ self.assertTrue(linux_modules.kconfig_is_module('CONFIG_TIME_KUNIT_TEST', session))
+ self.assertTrue(linux_modules.kconfig_is_not_set('CONFIG_AAAAAAAA', session))
+ self.assertFalse(linux_modules.kconfig_is_builtin('CONFIG_TIME_KUNIT_TEST', session))
+ self.assertFalse(linux_modules.kconfig_is_module('CONFIG_CC_IS_GCC', session))
+ self.assertFalse(linux_modules.kconfig_is_not_set('CONFIG_CC_IS_GCC', session))
+
+
LGTM @liuyd96 please take care of Travis failures.
LGTM @liuyd96 please take care of Travis failures.
It's a timeout error of CI.
The job exceeded the maximum time limit for jobs, and has been terminated.
@liuyd96 can you please rebase this request so we are good to go
@liuyd96 can you please rebase this request so we are good to go
@PraveenPenguin Thanks for your info. I have rebased this request, please have a try. Thanks.
Hi, @Naresh-ibm @PraveenPenguin @clebergnu Thank you for your carefule review. I made some minor changes related to code formatting to pass the recently changed CI. :) Please review it. Thanks.
Close this PR since I have fulfilled it in avocado-vt.