xref: /openbmc/linux/include/kunit/attributes.h (revision 7f1005dd)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * KUnit API to save and access test attributes
4  *
5  * Copyright (C) 2023, Google LLC.
6  * Author: Rae Moar <rmoar@google.com>
7  */
8 
9 #ifndef _KUNIT_ATTRIBUTES_H
10 #define _KUNIT_ATTRIBUTES_H
11 
12 /*
13  * struct kunit_attr_filter - representation of attributes filter with the
14  * attribute object and string input
15  */
16 struct kunit_attr_filter {
17 	struct kunit_attr *attr;
18 	char *input;
19 };
20 
21 /*
22  * Returns the name of the filter's attribute.
23  */
24 const char *kunit_attr_filter_name(struct kunit_attr_filter filter);
25 
26 /*
27  * Print all test attributes for a test case or suite.
28  * Output format for test cases: "# <test_name>.<attribute>: <value>"
29  * Output format for test suites: "# <attribute>: <value>"
30  */
31 void kunit_print_attr(void *test_or_suite, bool is_test, unsigned int test_level);
32 
33 /*
34  * Returns the number of fitlers in input.
35  */
36 int kunit_get_filter_count(char *input);
37 
38 /*
39  * Parse attributes filter input and return an objects containing the
40  * attribute object and the string input of the next filter.
41  */
42 struct kunit_attr_filter kunit_next_attr_filter(char **filters, int *err);
43 
44 /*
45  * Returns a copy of the suite containing only tests that pass the filter.
46  */
47 struct kunit_suite *kunit_filter_attr_tests(const struct kunit_suite *const suite,
48 		struct kunit_attr_filter filter, char *action, int *err);
49 
50 #endif /* _KUNIT_ATTRIBUTES_H */
51