lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Sep 2021 23:10:38 +0800
From:   "Longpeng(Mike)" <longpeng2@...wei.com>
To:     <andraprs@...zon.com>, <lexnv@...zon.com>, <alcioa@...zon.com>
CC:     <linux-kernel@...r.kernel.org>, <arei.gonglei@...wei.com>,
        <gregkh@...uxfoundation.org>, <kamal@...onical.com>,
        <pbonzini@...hat.com>, <sgarzare@...hat.com>,
        <stefanha@...hat.com>, <vkuznets@...hat.com>,
        <ne-devel-upstream@...zon.com>,
        "Longpeng(Mike)" <longpeng2@...wei.com>
Subject: [PATCH v2 3/4] nitro_enclaves: add test framework for the misc functionality

Add test framework for the misc functionality.

Signed-off-by: Longpeng(Mike) <longpeng2@...wei.com>
---
 drivers/virt/nitro_enclaves/Kconfig        |  8 ++++++++
 drivers/virt/nitro_enclaves/ne_misc_dev.c  | 27 +++++++++++++++++++++++++++
 drivers/virt/nitro_enclaves/ne_misc_test.c | 17 +++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 drivers/virt/nitro_enclaves/ne_misc_test.c

diff --git a/drivers/virt/nitro_enclaves/Kconfig b/drivers/virt/nitro_enclaves/Kconfig
index 8c9387a..24c54da 100644
--- a/drivers/virt/nitro_enclaves/Kconfig
+++ b/drivers/virt/nitro_enclaves/Kconfig
@@ -18,3 +18,11 @@ config NITRO_ENCLAVES
 
 	  To compile this driver as a module, choose M here.
 	  The module will be called nitro_enclaves.
+
+config NITRO_ENCLAVES_MISC_TEST
+	bool "Tests for the misc functionality of Nitro enclaves"
+	depends on NITRO_ENCLAVES && KUNIT=y
+	help
+	  Enable KUnit tests for the misc functionality of Nitro Enclaves. Select
+	  this option only if you will boot the kernel for the purpose of running
+	  unit tests (e.g. under UML or qemu). If unsure, say N.
diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c
index d551b88..0131e1b 100644
--- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
+++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
@@ -1735,8 +1735,33 @@ static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
+#if defined(CONFIG_NITRO_ENCLAVES_MISC_TEST)
+#include "ne_misc_test.c"
+
+static inline int ne_misc_test_init(void)
+{
+	return __kunit_test_suites_init(ne_misc_test_suites);
+}
+
+static inline void ne_misc_test_exit(void)
+{
+	__kunit_test_suites_exit(ne_misc_test_suites);
+}
+#else
+static inline int ne_misc_test_init(void)
+{
+	return 0;
+}
+
+static inline void ne_misc_test_exit(void)
+{
+}
+#endif
+
 static int __init ne_init(void)
 {
+	ne_misc_test_init();
+
 	mutex_init(&ne_cpu_pool.mutex);
 
 	return pci_register_driver(&ne_pci_driver);
@@ -1747,6 +1772,8 @@ static void __exit ne_exit(void)
 	pci_unregister_driver(&ne_pci_driver);
 
 	ne_teardown_cpu_pool();
+
+	ne_misc_test_exit();
 }
 
 module_init(ne_init);
diff --git a/drivers/virt/nitro_enclaves/ne_misc_test.c b/drivers/virt/nitro_enclaves/ne_misc_test.c
new file mode 100644
index 0000000..3426c35
--- /dev/null
+++ b/drivers/virt/nitro_enclaves/ne_misc_test.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <kunit/test.h>
+
+static struct kunit_case ne_misc_test_cases[] = {
+	{}
+};
+
+static struct kunit_suite ne_misc_test_suite = {
+	.name = "ne_misc_test",
+	.test_cases = ne_misc_test_cases,
+};
+
+static struct kunit_suite *ne_misc_test_suites[] = {
+	&ne_misc_test_suite,
+	NULL
+};
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ