162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * KUnit API to save and access test attributes 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2023, Google LLC. 662306a36Sopenharmony_ci * Author: Rae Moar <rmoar@google.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _KUNIT_ATTRIBUTES_H 1062306a36Sopenharmony_ci#define _KUNIT_ATTRIBUTES_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* 1362306a36Sopenharmony_ci * struct kunit_attr_filter - representation of attributes filter with the 1462306a36Sopenharmony_ci * attribute object and string input 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_cistruct kunit_attr_filter { 1762306a36Sopenharmony_ci struct kunit_attr *attr; 1862306a36Sopenharmony_ci char *input; 1962306a36Sopenharmony_ci}; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* 2262306a36Sopenharmony_ci * Returns the name of the filter's attribute. 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_ciconst char *kunit_attr_filter_name(struct kunit_attr_filter filter); 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * Print all test attributes for a test case or suite. 2862306a36Sopenharmony_ci * Output format for test cases: "# <test_name>.<attribute>: <value>" 2962306a36Sopenharmony_ci * Output format for test suites: "# <attribute>: <value>" 3062306a36Sopenharmony_ci */ 3162306a36Sopenharmony_civoid kunit_print_attr(void *test_or_suite, bool is_test, unsigned int test_level); 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* 3462306a36Sopenharmony_ci * Returns the number of fitlers in input. 3562306a36Sopenharmony_ci */ 3662306a36Sopenharmony_ciint kunit_get_filter_count(char *input); 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* 3962306a36Sopenharmony_ci * Parse attributes filter input and return an objects containing the 4062306a36Sopenharmony_ci * attribute object and the string input of the next filter. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_cistruct kunit_attr_filter kunit_next_attr_filter(char **filters, int *err); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* 4562306a36Sopenharmony_ci * Returns a copy of the suite containing only tests that pass the filter. 4662306a36Sopenharmony_ci */ 4762306a36Sopenharmony_cistruct kunit_suite *kunit_filter_attr_tests(const struct kunit_suite *const suite, 4862306a36Sopenharmony_ci struct kunit_attr_filter filter, char *action, int *err); 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#endif /* _KUNIT_ATTRIBUTES_H */ 51