139e92cb1SRae Moar /* SPDX-License-Identifier: GPL-2.0 */ 239e92cb1SRae Moar /* 339e92cb1SRae Moar * KUnit API to save and access test attributes 439e92cb1SRae Moar * 539e92cb1SRae Moar * Copyright (C) 2023, Google LLC. 639e92cb1SRae Moar * Author: Rae Moar <[email protected]> 739e92cb1SRae Moar */ 839e92cb1SRae Moar 939e92cb1SRae Moar #ifndef _KUNIT_ATTRIBUTES_H 1039e92cb1SRae Moar #define _KUNIT_ATTRIBUTES_H 1139e92cb1SRae Moar 1239e92cb1SRae Moar /* 13*529534e8SRae Moar * struct kunit_attr_filter - representation of attributes filter with the 14*529534e8SRae Moar * attribute object and string input 15*529534e8SRae Moar */ 16*529534e8SRae Moar struct kunit_attr_filter { 17*529534e8SRae Moar struct kunit_attr *attr; 18*529534e8SRae Moar char *input; 19*529534e8SRae Moar }; 20*529534e8SRae Moar 21*529534e8SRae Moar /* 22*529534e8SRae Moar * Returns the name of the filter's attribute. 23*529534e8SRae Moar */ 24*529534e8SRae Moar const char *kunit_attr_filter_name(struct kunit_attr_filter filter); 25*529534e8SRae Moar 26*529534e8SRae Moar /* 2739e92cb1SRae Moar * Print all test attributes for a test case or suite. 2839e92cb1SRae Moar * Output format for test cases: "# <test_name>.<attribute>: <value>" 2939e92cb1SRae Moar * Output format for test suites: "# <attribute>: <value>" 3039e92cb1SRae Moar */ 3139e92cb1SRae Moar void kunit_print_attr(void *test_or_suite, bool is_test, unsigned int test_level); 3239e92cb1SRae Moar 33*529534e8SRae Moar /* 34*529534e8SRae Moar * Returns the number of fitlers in input. 35*529534e8SRae Moar */ 36*529534e8SRae Moar int kunit_get_filter_count(char *input); 37*529534e8SRae Moar 38*529534e8SRae Moar /* 39*529534e8SRae Moar * Parse attributes filter input and return an objects containing the 40*529534e8SRae Moar * attribute object and the string input of the next filter. 41*529534e8SRae Moar */ 42*529534e8SRae Moar struct kunit_attr_filter kunit_next_attr_filter(char **filters, int *err); 43*529534e8SRae Moar 44*529534e8SRae Moar /* 45*529534e8SRae Moar * Returns a copy of the suite containing only tests that pass the filter. 46*529534e8SRae Moar */ 47*529534e8SRae Moar struct kunit_suite *kunit_filter_attr_tests(const struct kunit_suite *const suite, 48*529534e8SRae Moar struct kunit_attr_filter filter, char *action, int *err); 49*529534e8SRae Moar 5039e92cb1SRae Moar #endif /* _KUNIT_ATTRIBUTES_H */ 51