@@ -452,9 +452,9 @@ static int test__name_cmp(struct test_suite *test __maybe_unused, int subtest __
452452}
453453
454454/**
455- * Test perf_pmu__match () that's used to search for a PMU given a name passed
455+ * Test perf_pmu__wildcard_match () that's used to search for a PMU given a name passed
456456 * on the command line. The name that's passed may also be a filename type glob
457- * match. If the name does not match, perf_pmu__match () attempts to match the
457+ * match. If the name does not match, perf_pmu__wildcard_match () attempts to match the
458458 * alias of the PMU, if provided.
459459 */
460460static int test__pmu_match (struct test_suite * test __maybe_unused , int subtest __maybe_unused )
@@ -463,69 +463,72 @@ static int test__pmu_match(struct test_suite *test __maybe_unused, int subtest _
463463 .name = "pmuname" ,
464464 };
465465
466- TEST_ASSERT_EQUAL ("Exact match" , perf_pmu__match (& test_pmu , "pmuname" ), true);
467- TEST_ASSERT_EQUAL ("Longer token" , perf_pmu__match (& test_pmu , "longertoken" ), false);
468- TEST_ASSERT_EQUAL ("Shorter token" , perf_pmu__match (& test_pmu , "pmu" ), false);
466+ #define TEST_PMU_MATCH (msg , to_match , expect ) \
467+ TEST_ASSERT_EQUAL(msg, perf_pmu__wildcard_match(&test_pmu, to_match), expect)
468+
469+ TEST_PMU_MATCH ("Exact match" , "pmuname" , true);
470+ TEST_PMU_MATCH ("Longer token" , "longertoken" , false);
471+ TEST_PMU_MATCH ("Shorter token" , "pmu" , false);
469472
470473 test_pmu .name = "pmuname_10" ;
471- TEST_ASSERT_EQUAL ("Diff suffix_" , perf_pmu__match ( & test_pmu , "pmuname_2" ), false);
472- TEST_ASSERT_EQUAL ("Sub suffix_" , perf_pmu__match ( & test_pmu , "pmuname_1" ), true);
473- TEST_ASSERT_EQUAL ("Same suffix_" , perf_pmu__match ( & test_pmu , "pmuname_10" ) , true);
474- TEST_ASSERT_EQUAL ("No suffix_" , perf_pmu__match ( & test_pmu , "pmuname" ), true);
475- TEST_ASSERT_EQUAL ("Underscore_" , perf_pmu__match ( & test_pmu , "pmuname_" ), true);
476- TEST_ASSERT_EQUAL ("Substring_" , perf_pmu__match ( & test_pmu , "pmuna" ), false);
474+ TEST_PMU_MATCH ("Diff suffix_" , "pmuname_2" , false);
475+ TEST_PMU_MATCH ("Sub suffix_" , "pmuname_1" , true);
476+ TEST_PMU_MATCH ("Same suffix_" , "pmuname_10" , true);
477+ TEST_PMU_MATCH ("No suffix_" , "pmuname" , true);
478+ TEST_PMU_MATCH ("Underscore_" , "pmuname_" , true);
479+ TEST_PMU_MATCH ("Substring_" , "pmuna" , false);
477480
478481 test_pmu .name = "pmuname_ab23" ;
479- TEST_ASSERT_EQUAL ("Diff suffix hex_" , perf_pmu__match ( & test_pmu , "pmuname_2" ), false);
480- TEST_ASSERT_EQUAL ("Sub suffix hex_" , perf_pmu__match ( & test_pmu , "pmuname_ab" ), true);
481- TEST_ASSERT_EQUAL ("Same suffix hex_" , perf_pmu__match ( & test_pmu , "pmuname_ab23" ) , true);
482- TEST_ASSERT_EQUAL ("No suffix hex_" , perf_pmu__match ( & test_pmu , "pmuname" ), true);
483- TEST_ASSERT_EQUAL ("Underscore hex_" , perf_pmu__match ( & test_pmu , "pmuname_" ), true);
484- TEST_ASSERT_EQUAL ("Substring hex_" , perf_pmu__match ( & test_pmu , "pmuna" ), false);
482+ TEST_PMU_MATCH ("Diff suffix hex_" , "pmuname_2" , false);
483+ TEST_PMU_MATCH ("Sub suffix hex_" , "pmuname_ab" , true);
484+ TEST_PMU_MATCH ("Same suffix hex_" , "pmuname_ab23" , true);
485+ TEST_PMU_MATCH ("No suffix hex_" , "pmuname" , true);
486+ TEST_PMU_MATCH ("Underscore hex_" , "pmuname_" , true);
487+ TEST_PMU_MATCH ("Substring hex_" , "pmuna" , false);
485488
486489 test_pmu .name = "pmuname10" ;
487- TEST_ASSERT_EQUAL ("Diff suffix" , perf_pmu__match ( & test_pmu , "pmuname2" ), false);
488- TEST_ASSERT_EQUAL ("Sub suffix" , perf_pmu__match ( & test_pmu , "pmuname1" ), true);
489- TEST_ASSERT_EQUAL ("Same suffix" , perf_pmu__match ( & test_pmu , "pmuname10" ) , true);
490- TEST_ASSERT_EQUAL ("No suffix" , perf_pmu__match ( & test_pmu , "pmuname" ), true);
491- TEST_ASSERT_EQUAL ("Underscore" , perf_pmu__match ( & test_pmu , "pmuname_" ), false);
492- TEST_ASSERT_EQUAL ("Substring" , perf_pmu__match ( & test_pmu , "pmuna" ), false);
490+ TEST_PMU_MATCH ("Diff suffix" , "pmuname2" , false);
491+ TEST_PMU_MATCH ("Sub suffix" , "pmuname1" , true);
492+ TEST_PMU_MATCH ("Same suffix" , "pmuname10" , true);
493+ TEST_PMU_MATCH ("No suffix" , "pmuname" , true);
494+ TEST_PMU_MATCH ("Underscore" , "pmuname_" , false);
495+ TEST_PMU_MATCH ("Substring" , "pmuna" , false);
493496
494497 test_pmu .name = "pmunameab23" ;
495- TEST_ASSERT_EQUAL ("Diff suffix hex" , perf_pmu__match ( & test_pmu , "pmuname2" ), false);
496- TEST_ASSERT_EQUAL ("Sub suffix hex" , perf_pmu__match ( & test_pmu , "pmunameab" ), true);
497- TEST_ASSERT_EQUAL ("Same suffix hex" , perf_pmu__match ( & test_pmu , "pmunameab23" ) , true);
498- TEST_ASSERT_EQUAL ("No suffix hex" , perf_pmu__match ( & test_pmu , "pmuname" ), true);
499- TEST_ASSERT_EQUAL ("Underscore hex" , perf_pmu__match ( & test_pmu , "pmuname_" ), false);
500- TEST_ASSERT_EQUAL ("Substring hex" , perf_pmu__match ( & test_pmu , "pmuna" ), false);
498+ TEST_PMU_MATCH ("Diff suffix hex" , "pmuname2" , false);
499+ TEST_PMU_MATCH ("Sub suffix hex" , "pmunameab" , true);
500+ TEST_PMU_MATCH ("Same suffix hex" , "pmunameab23" , true);
501+ TEST_PMU_MATCH ("No suffix hex" , "pmuname" , true);
502+ TEST_PMU_MATCH ("Underscore hex" , "pmuname_" , false);
503+ TEST_PMU_MATCH ("Substring hex" , "pmuna" , false);
501504
502505 /*
503506 * 2 hex chars or less are not considered suffixes so it shouldn't be
504507 * possible to wildcard by skipping the suffix. Therefore there are more
505508 * false results here than above.
506509 */
507510 test_pmu .name = "pmuname_a3" ;
508- TEST_ASSERT_EQUAL ("Diff suffix 2 hex_" , perf_pmu__match ( & test_pmu , "pmuname_2" ), false);
511+ TEST_PMU_MATCH ("Diff suffix 2 hex_" , "pmuname_2" , false);
509512 /*
510513 * This one should be false, but because pmuname_a3 ends in 3 which is
511514 * decimal, it's not possible to determine if it's a short hex suffix or
512515 * a normal decimal suffix following text. And we want to match on any
513516 * length of decimal suffix. Run the test anyway and expect the wrong
514517 * result. And slightly fuzzy matching shouldn't do too much harm.
515518 */
516- TEST_ASSERT_EQUAL ("Sub suffix 2 hex_" , perf_pmu__match ( & test_pmu , "pmuname_a" ), true);
517- TEST_ASSERT_EQUAL ("Same suffix 2 hex_" , perf_pmu__match ( & test_pmu , "pmuname_a3" ) , true);
518- TEST_ASSERT_EQUAL ("No suffix 2 hex_" , perf_pmu__match ( & test_pmu , "pmuname" ), false);
519- TEST_ASSERT_EQUAL ("Underscore 2 hex_" , perf_pmu__match ( & test_pmu , "pmuname_" ), false);
520- TEST_ASSERT_EQUAL ("Substring 2 hex_" , perf_pmu__match ( & test_pmu , "pmuna" ), false);
519+ TEST_PMU_MATCH ("Sub suffix 2 hex_" , "pmuname_a" , true);
520+ TEST_PMU_MATCH ("Same suffix 2 hex_" , "pmuname_a3" , true);
521+ TEST_PMU_MATCH ("No suffix 2 hex_" , "pmuname" , false);
522+ TEST_PMU_MATCH ("Underscore 2 hex_" , "pmuname_" , false);
523+ TEST_PMU_MATCH ("Substring 2 hex_" , "pmuna" , false);
521524
522525 test_pmu .name = "pmuname_5" ;
523- TEST_ASSERT_EQUAL ("Glob 1" , perf_pmu__match ( & test_pmu , "pmu*" ), true);
524- TEST_ASSERT_EQUAL ("Glob 2" , perf_pmu__match ( & test_pmu , "nomatch*" ), false);
525- TEST_ASSERT_EQUAL ("Seq 1" , perf_pmu__match ( & test_pmu , "pmuname_[12345]" ) , true);
526- TEST_ASSERT_EQUAL ("Seq 2" , perf_pmu__match ( & test_pmu , "pmuname_[67890]" ) , false);
527- TEST_ASSERT_EQUAL ("? 1" , perf_pmu__match ( & test_pmu , "pmuname_?" ), true);
528- TEST_ASSERT_EQUAL ("? 2" , perf_pmu__match ( & test_pmu , "pmuname_1?" ), false);
526+ TEST_PMU_MATCH ("Glob 1" , "pmu*" , true);
527+ TEST_PMU_MATCH ("Glob 2" , "nomatch*" , false);
528+ TEST_PMU_MATCH ("Seq 1" , "pmuname_[12345]" , true);
529+ TEST_PMU_MATCH ("Seq 2" , "pmuname_[67890]" , false);
530+ TEST_PMU_MATCH ("? 1" , "pmuname_?" , true);
531+ TEST_PMU_MATCH ("? 2" , "pmuname_1?" , false);
529532
530533 return TEST_OK ;
531534}
0 commit comments