Thread (33 messages) 33 messages, 3 authors, 2021-11-13

Re: [PATCH v2 06/22] perf test: Add helper functions for abstraction.

From: Ian Rogers <irogers@google.com>
Date: 2021-10-25 22:35:36
Also in: lkml

On Wed, Oct 20, 2021 at 5:34 AM Jiri Olsa [off-list ref] wrote:
On Wed, Oct 13, 2021 at 10:45:48AM -0700, Ian Rogers wrote:

SNIP
quoted
      else
              pr_debug("%s subtest %d:", t->desc, subtest + 1);
@@ -218,11 +257,10 @@ static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
              pr_info(" Ok\n");
              break;
      case TEST_SKIP: {
-             const char *skip_reason = NULL;
-             if (t->subtest.skip_reason)
-                     skip_reason = t->subtest.skip_reason(subtest);
-             if (skip_reason)
-                     color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", skip_reason);
+             const char *reason = skip_reason(t, subtest);
+
+             if (reason)
+                     color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", reason);
              else
                      color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
      }
@@ -397,7 +435,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
      int width = shell_tests__max_desc_width();

      for_each_test(j, k, t) {
-             int len = strlen(t->desc);
+             int len = strlen(test_description(t, -1));

              if (width < len)
                      width = len;
@@ -407,17 +445,15 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
              int curr = i++, err;
              int subi;

-             if (!perf_test__matches(t->desc, curr, argc, argv)) {
+             if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) {
                      bool skip = true;
                      int subn;

-                     if (!t->subtest.get_nr)
-                             continue;
-
-                     subn = t->subtest.get_nr();
+                     subn = num_subtests(t);
should you call continue on !subn ?
It's not necessary. When subn == 0 then the loop won't be taken and
skip == true, so the immediately after "if (skip) continue;" will
happen.

Thanks,
Ian
jirka
quoted
                      for (subi = 0; subi < subn; subi++) {
-                             if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
+                             if (perf_test__matches(test_description(t, subi),
+                                                     curr, argc, argv))
                                      skip = false;
                      }
@@ -425,22 +461,23 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
                              continue;
              }
SNIP
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help