Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nitro_enclaves: Add KUnit tests setup for the misc device functionality

Add the initial setup for the KUnit tests that will target the Nitro
Enclaves misc device functionality.

Reviewed-by: Andra Paraschiv <andraprs@amazon.com>
Signed-off-by: Longpeng <longpeng2@huawei.com>
Link: https://lore.kernel.org/r/20211107140918.2106-4-longpeng2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Longpeng and committed by
Greg Kroah-Hartman
07503b3c 090ce783

+57
+9
drivers/virt/nitro_enclaves/Kconfig
··· 14 14 15 15 To compile this driver as a module, choose M here. 16 16 The module will be called nitro_enclaves. 17 + 18 + config NITRO_ENCLAVES_MISC_DEV_TEST 19 + bool "Tests for the misc device functionality of the Nitro Enclaves" 20 + depends on NITRO_ENCLAVES && KUNIT=y 21 + help 22 + Enable KUnit tests for the misc device functionality of the Nitro 23 + Enclaves. Select this option only if you will boot the kernel for 24 + the purpose of running unit tests (e.g. under UML or qemu). If 25 + unsure, say N.
+31
drivers/virt/nitro_enclaves/ne_misc_dev.c
··· 1756 1756 return 0; 1757 1757 } 1758 1758 1759 + #if defined(CONFIG_NITRO_ENCLAVES_MISC_DEV_TEST) 1760 + #include "ne_misc_dev_test.c" 1761 + 1762 + static inline int ne_misc_dev_test_init(void) 1763 + { 1764 + return __kunit_test_suites_init(ne_misc_dev_test_suites); 1765 + } 1766 + 1767 + static inline void ne_misc_dev_test_exit(void) 1768 + { 1769 + __kunit_test_suites_exit(ne_misc_dev_test_suites); 1770 + } 1771 + #else 1772 + static inline int ne_misc_dev_test_init(void) 1773 + { 1774 + return 0; 1775 + } 1776 + 1777 + static inline void ne_misc_dev_test_exit(void) 1778 + { 1779 + } 1780 + #endif 1781 + 1759 1782 static int __init ne_init(void) 1760 1783 { 1784 + int rc = 0; 1785 + 1786 + rc = ne_misc_dev_test_init(); 1787 + if (rc < 0) 1788 + return rc; 1789 + 1761 1790 mutex_init(&ne_cpu_pool.mutex); 1762 1791 1763 1792 return pci_register_driver(&ne_pci_driver); ··· 1797 1768 pci_unregister_driver(&ne_pci_driver); 1798 1769 1799 1770 ne_teardown_cpu_pool(); 1771 + 1772 + ne_misc_dev_test_exit(); 1800 1773 } 1801 1774 1802 1775 module_init(ne_init);
+17
drivers/virt/nitro_enclaves/ne_misc_dev_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <kunit/test.h> 4 + 5 + static struct kunit_case ne_misc_dev_test_cases[] = { 6 + {} 7 + }; 8 + 9 + static struct kunit_suite ne_misc_dev_test_suite = { 10 + .name = "ne_misc_dev_test", 11 + .test_cases = ne_misc_dev_test_cases, 12 + }; 13 + 14 + static struct kunit_suite *ne_misc_dev_test_suites[] = { 15 + &ne_misc_dev_test_suite, 16 + NULL 17 + };