attributes.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef _KUNIT_ATTRIBUTES_H
  9. #define _KUNIT_ATTRIBUTES_H
  10. /*
  11. * struct kunit_attr_filter - representation of attributes filter with the
  12. * attribute object and string input
  13. */
  14. struct kunit_attr_filter {
  15. struct kunit_attr *attr;
  16. char *input;
  17. };
  18. /*
  19. * Returns the name of the filter's attribute.
  20. */
  21. const char *kunit_attr_filter_name(struct kunit_attr_filter filter);
  22. /*
  23. * Print all test attributes for a test case or suite.
  24. * Output format for test cases: "# <test_name>.<attribute>: <value>"
  25. * Output format for test suites: "# <attribute>: <value>"
  26. */
  27. void kunit_print_attr(void *test_or_suite, bool is_test, unsigned int test_level);
  28. /*
  29. * Returns the number of fitlers in input.
  30. */
  31. int kunit_get_filter_count(char *input);
  32. /*
  33. * Parse attributes filter input and return an objects containing the
  34. * attribute object and the string input of the next filter.
  35. */
  36. struct kunit_attr_filter kunit_next_attr_filter(char **filters, int *err);
  37. /*
  38. * Returns a copy of the suite containing only tests that pass the filter.
  39. */
  40. struct kunit_suite *kunit_filter_attr_tests(const struct kunit_suite *const suite,
  41. struct kunit_attr_filter filter, char *action, int *err);
  42. #endif /* _KUNIT_ATTRIBUTES_H */