summaryrefslogtreecommitdiffstats
path: root/include/kunit/attributes.h
diff options
context:
space:
mode:
authorRae Moar <rmoar@google.com>2023-07-25 23:25:12 +0200
committerShuah Khan <skhan@linuxfoundation.org>2023-07-26 21:28:57 +0200
commit39e92cb1e4a1f6a12097ea2aa9e9ca6f2d2f8a83 (patch)
tree54c0b4863deb1e462fbf6a9a25775f7d3a222a2b /include/kunit/attributes.h
parentMAINTAINERS: add Rust KUnit files to the KUnit entry (diff)
downloadlinux-39e92cb1e4a1f6a12097ea2aa9e9ca6f2d2f8a83.tar.xz
linux-39e92cb1e4a1f6a12097ea2aa9e9ca6f2d2f8a83.zip
kunit: Add test attributes API structure
Add the basic structure of the test attribute API to KUnit, which can be used to save and access test associated data. Add attributes.c and attributes.h to hold associated structs and functions for the API. Create a struct that holds a variety of associated helper functions for each test attribute. These helper functions will be used to get the attribute value, convert the value to a string, and filter based on the value. This struct is flexible by design to allow for attributes of numerous types and contexts. Add a method to print test attributes in the format of "# [<test_name if not suite>.]<attribute_name>: <attribute_value>". Example for a suite: "# speed: slow" Example for a test case: "# test_case.speed: very_slow" Use this method to report attributes in the KTAP output (KTAP spec: https://docs.kernel.org/dev-tools/ktap.html) and _list_tests output when kernel's new kunit.action=list_attr option is used. Note this is derivative of the kunit.action=list option. In test.h, add fields and associated helper functions to test cases and suites to hold user-inputted test attributes. Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Rae Moar <rmoar@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'include/kunit/attributes.h')
-rw-r--r--include/kunit/attributes.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/kunit/attributes.h b/include/kunit/attributes.h
new file mode 100644
index 000000000000..9fcd184cce36
--- /dev/null
+++ b/include/kunit/attributes.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * KUnit API to save and access test attributes
+ *
+ * Copyright (C) 2023, Google LLC.
+ * Author: Rae Moar <rmoar@google.com>
+ */
+
+#ifndef _KUNIT_ATTRIBUTES_H
+#define _KUNIT_ATTRIBUTES_H
+
+/*
+ * Print all test attributes for a test case or suite.
+ * Output format for test cases: "# <test_name>.<attribute>: <value>"
+ * Output format for test suites: "# <attribute>: <value>"
+ */
+void kunit_print_attr(void *test_or_suite, bool is_test, unsigned int test_level);
+
+#endif /* _KUNIT_ATTRIBUTES_H */