forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'linux_kselftest-kunit-6.8-rc1' of git://git.kernel.org/pub…
…/scm/linux/kernel/git/shuah/linux-kselftest Pull KUnit updates from Shuah Khan: - a new feature that adds APIs for managing devices introducing a set of helper functions which allow devices (internally a struct kunit_device) to be created and managed by KUnit. These devices will be automatically unregistered on test exit. These helpers can either use a user-provided struct device_driver, or have one automatically created and managed by KUnit. In both cases, the device lives on a new kunit_bus. - changes to switch drm/tests to use kunit devices - several fixes and enhancements to attribute feature - changes to reorganize deferred action function introducing KUNIT_DEFINE_ACTION_WRAPPER - new feature adds ability to run tests after boot using debugfs - fixes and enhancements to string-stream-test: - parse ERR_PTR in string_stream_destroy() - unchecked dereference in bug fix in debugfs_print_results() - handling errors from alloc_string_stream() - NULL-dereference bug fix in kunit_init_suite() * tag 'linux_kselftest-kunit-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (27 commits) kunit: Fix some comments which were mistakenly kerneldoc kunit: Protect string comparisons against NULL kunit: Add example of kunit_activate_static_stub() with pointer-to-function kunit: Allow passing function pointer to kunit_activate_static_stub() kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL kunit: Reset test->priv after each param iteration kunit: Add example for using test->priv drm/tests: Switch to kunit devices ASoC: topology: Replace fake root_device with kunit_device in tests overflow: Replace fake root_device with kunit_device fortify: test: Use kunit_device kunit: Add APIs for managing devices Documentation: Add debugfs docs with run after boot kunit: add ability to run tests after boot using debugfs kunit: add is_init test attribute kunit: add example suite to test init suites kunit: add KUNIT_INIT_TABLE to init linker section kunit: move KUNIT_TABLE out of INIT_DATA kunit: tool: add test for parsing attributes kunit: tool: fix parsing of test attributes ...
- Loading branch information
Showing
30 changed files
with
978 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* KUnit basic device implementation | ||
* | ||
* Helpers for creating and managing fake devices for KUnit tests. | ||
* | ||
* Copyright (C) 2023, Google LLC. | ||
* Author: David Gow <[email protected]> | ||
*/ | ||
|
||
#ifndef _KUNIT_DEVICE_H | ||
#define _KUNIT_DEVICE_H | ||
|
||
#if IS_ENABLED(CONFIG_KUNIT) | ||
|
||
#include <kunit/test.h> | ||
|
||
struct device; | ||
struct device_driver; | ||
|
||
/** | ||
* kunit_driver_create() - Create a struct device_driver attached to the kunit_bus | ||
* @test: The test context object. | ||
* @name: The name to give the created driver. | ||
* | ||
* Creates a struct device_driver attached to the kunit_bus, with the name @name. | ||
* This driver will automatically be cleaned up on test exit. | ||
* | ||
* Return: a stub struct device_driver, managed by KUnit, with the name @name. | ||
*/ | ||
struct device_driver *kunit_driver_create(struct kunit *test, const char *name); | ||
|
||
/** | ||
* kunit_device_register() - Create a struct device for use in KUnit tests | ||
* @test: The test context object. | ||
* @name: The name to give the created device. | ||
* | ||
* Creates a struct kunit_device (which is a struct device) with the given name, | ||
* and a corresponding driver. The device and driver will be cleaned up on test | ||
* exit, or when kunit_device_unregister is called. See also | ||
* kunit_device_register_with_driver, if you wish to provide your own | ||
* struct device_driver. | ||
* | ||
* Return: a pointer to a struct device which will be cleaned up when the test | ||
* exits, or an error pointer if the device could not be allocated or registered. | ||
*/ | ||
struct device *kunit_device_register(struct kunit *test, const char *name); | ||
|
||
/** | ||
* kunit_device_register_with_driver() - Create a struct device for use in KUnit tests | ||
* @test: The test context object. | ||
* @name: The name to give the created device. | ||
* @drv: The struct device_driver to associate with the device. | ||
* | ||
* Creates a struct kunit_device (which is a struct device) with the given | ||
* name, and driver. The device will be cleaned up on test exit, or when | ||
* kunit_device_unregister is called. See also kunit_device_register, if you | ||
* wish KUnit to create and manage a driver for you. | ||
* | ||
* Return: a pointer to a struct device which will be cleaned up when the test | ||
* exits, or an error pointer if the device could not be allocated or registered. | ||
*/ | ||
struct device *kunit_device_register_with_driver(struct kunit *test, | ||
const char *name, | ||
const struct device_driver *drv); | ||
|
||
/** | ||
* kunit_device_unregister() - Unregister a KUnit-managed device | ||
* @test: The test context object which created the device | ||
* @dev: The device. | ||
* | ||
* Unregisters and destroys a struct device which was created with | ||
* kunit_device_register or kunit_device_register_with_driver. If KUnit created | ||
* a driver, cleans it up as well. | ||
*/ | ||
void kunit_device_unregister(struct kunit *test, struct device *dev); | ||
|
||
#endif | ||
|
||
#endif |
Oops, something went wrong.