From nobody Sun Feb 8 06:40:27 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9420A19DF53 for ; Tue, 7 Jan 2025 22:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287320; cv=none; b=a/aOtJ9x1PXjwyxLcMFEOuvjggpkwykq5awjoGTlYIVRYGkUu86PgG85OH+nbdw9SrKgK8pU24Z9BL8wUBgPvi3vUd5f0sE1NmKKDmWsStNHQK94z6ls75R4bR+63RX6ushe6j2oD4C6/pSTXOhP9MdYN6T2ZTtQ1WSzR2HNhOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287320; c=relaxed/simple; bh=oe8jug5TfATH6UqI+SDmWJVfhN4/Z1/tSDQisOCdIus=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=KFukDobsXLPYOJr7foNy1XBWT/xeLNB/PgPQSGUkdy1P2ZTuwqbpGOa1Uu1gP4UwBNZ6xupevMe5XX9IPC3vE66oxT0lVtqYqY5YxD0WtgzkoBLIujRsR9+sWRdl/JGZuOaxdqav8kRRyRGwfqlRqMfD+71jXQ3AvLkxwI9dVUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TrnhdXlO; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TrnhdXlO" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e4bed6c9151so33318664276.0 for ; Tue, 07 Jan 2025 14:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736287317; x=1736892117; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=rt3FANMhbwUxwhbrCeMm//1cFuRBbV1k6BaJKVQj2ZQ=; b=TrnhdXlOiYdQAQvhHfHNvJX6aygRQh2Mb3cW4fgq5hsrh+3x5EXP8hAGJKF5gJtUr6 ngdv6Uu7BDd3G95KumyA62Q4TVVSAOxqW7zuJ5PO/j0c8Ahr533tdjeJEhBUgifSmior BXplMWaddThQtwzQNXlHPowdXS6f8Wdpj0bOO6mT5I8YQE8eW3+ivzexjm6cK8Gh6efo qzOyltXeWVL71AmvDxv3njiqS7GH5Q8P8LzAWMiLy/dWZSCyOu/3ytfZ95jpS9jBGe0D EEkmEMvQ4zTc3J9Dq6iYExd5+T2mnpoY5ZwWiJREI0/NKTngVcMOB3KAfyohkmXD0bwb YB6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736287317; x=1736892117; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rt3FANMhbwUxwhbrCeMm//1cFuRBbV1k6BaJKVQj2ZQ=; b=n1uj7jrjeuJEEEMePrTbKcvcI2O53ebD/3373JyoMo9Uh2+g57wlgVQ7jiZMYepwCz udJyHc7xsQZUHMIaq4/jmECEgVfRuPhuSir/rOf97vGRVNb95tS6C0XcwHq9EBdcKQI+ sbbVj0T4UIET8Cc7I4LROgG/v9NtzUXdwsmPe23i6w/yTBrWfqOfqeFVjl+6eIYmJdu7 /f6F60/4zDYO1iqPLtO04+PUkoJzHGokTDu3QMbKaAMEZD3ejcxmfsJdI24fAPmuX6aq +N00Dr37BlGNGRQNXy98zTl2meUtefPO54caQ6l+8Cw/zJgLyCWjhqRof9twCwNr8Fz3 03vw== X-Forwarded-Encrypted: i=1; AJvYcCVeCRfXS95gYtU/67hpqI2BIdSAVwN4eEDbywwMtuVX6Y2UVzqgYDMjjNBCbljPyxw1wKjYAMQUVau3Bes=@vger.kernel.org X-Gm-Message-State: AOJu0Yyf8QQbBs1/i+G6+utubYLVUzQBIJd+V0Ns1KGZjJa6ob/vJZXk ShxTYzvJqQlAt9X/GRtsoRha7MEtBxrRpxJpStvQQ6Gh/rOFDyEsUAULgsQXs+GVZqn7N8PS5T2 2kiNWKA== X-Google-Smtp-Source: AGHT+IFsdGsWszeaH2lo56RdgKwjyEciPXbixsTmDkJMCQHpqooQogMJfc+S6jjCfXmtpY/dcBdzyWB+wUYr X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:7ae:a887:5504:e3ca]) (user=irogers job=sendgmr) by 2002:a25:ae44:0:b0:e4b:7d0c:7c63 with SMTP id 3f1490d57ef6-e54eff2f037mr465276.4.1736287317674; Tue, 07 Jan 2025 14:01:57 -0800 (PST) Date: Tue, 7 Jan 2025 14:01:50 -0800 In-Reply-To: <20250107220152.1213959-1-irogers@google.com> Message-Id: <20250107220152.1213959-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250107220152.1213959-1-irogers@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v2 1/3] perf test: Rename functions and variables for better clarity From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The relationship between subtests and test cases is somewhat confusing, so let's do away with the notion of sub-tests and switch to just working with some number of test cases. Add a test_suite__for_each_test_case as in many cases, except the special one test case situation, the iteration can just be on all test cases. Switch variable names to be more intention revealing of what their value is. This work was motivated by discussion with Kan where it was noted the code is becoming overly indented: https://lore.kernel.org/lkml/20241109160219.49976-1-irogers@google.com/ Unifying more of the sub-test/no-sub-tests avoids one level of indentation in a number of places. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 201 +++++++++++++++----------------- 1 file changed, 93 insertions(+), 108 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index a5b9ccd0033a..c3e082efb7f4 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -149,58 +149,51 @@ static struct test_workload *workloads[] =3D { #define workloads__for_each(workload) \ for (unsigned i =3D 0; i < ARRAY_SIZE(workloads) && ({ workload =3D workl= oads[i]; 1; }); i++) =20 -static int num_subtests(const struct test_suite *t) +#define test_suite__for_each_test_case(suite, idx) \ + for (idx =3D 0; (suite)->test_cases && (suite)->test_cases[idx].name !=3D= NULL; idx++) + +static int test_suite__num_test_cases(const struct test_suite *t) { int num; =20 - if (!t->test_cases) - return 0; - - num =3D 0; - while (t->test_cases[num].name) - num++; + test_suite__for_each_test_case(t, num); =20 return num; } =20 -static bool has_subtests(const struct test_suite *t) -{ - return num_subtests(t) > 1; -} - -static const char *skip_reason(const struct test_suite *t, int subtest) +static const char *skip_reason(const struct test_suite *t, int test_case) { if (!t->test_cases) return NULL; =20 - return t->test_cases[subtest >=3D 0 ? subtest : 0].skip_reason; + return t->test_cases[test_case >=3D 0 ? test_case : 0].skip_reason; } =20 -static const char *test_description(const struct test_suite *t, int subtes= t) +static const char *test_description(const struct test_suite *t, int test_c= ase) { - if (t->test_cases && subtest >=3D 0) - return t->test_cases[subtest].desc; + if (t->test_cases && test_case >=3D 0) + return t->test_cases[test_case].desc; =20 return t->desc; } =20 -static test_fnptr test_function(const struct test_suite *t, int subtest) +static test_fnptr test_function(const struct test_suite *t, int test_case) { - if (subtest <=3D 0) + if (test_case <=3D 0) return t->test_cases[0].run_case; =20 - return t->test_cases[subtest].run_case; + return t->test_cases[test_case].run_case; } =20 -static bool test_exclusive(const struct test_suite *t, int subtest) +static bool test_exclusive(const struct test_suite *t, int test_case) { - if (subtest <=3D 0) + if (test_case <=3D 0) return t->test_cases[0].exclusive; =20 - return t->test_cases[subtest].exclusive; + return t->test_cases[test_case].exclusive; } =20 -static bool perf_test__matches(const char *desc, int curr, int argc, const= char *argv[]) +static bool perf_test__matches(const char *desc, int suite_num, int argc, = const char *argv[]) { int i; =20 @@ -212,7 +205,7 @@ static bool perf_test__matches(const char *desc, int cu= rr, int argc, const char long nr =3D strtoul(argv[i], &end, 10); =20 if (*end =3D=3D '\0') { - if (nr =3D=3D curr + 1) + if (nr =3D=3D suite_num + 1) return true; continue; } @@ -227,8 +220,8 @@ static bool perf_test__matches(const char *desc, int cu= rr, int argc, const char struct child_test { struct child_process process; struct test_suite *test; - int test_num; - int subtest; + int suite_num; + int test_case_num; }; =20 static jmp_buf run_test_jmp_buf; @@ -258,7 +251,7 @@ static int run_test_child(struct child_process *process) =20 pr_debug("--- start ---\n"); pr_debug("test child forked, pid %d\n", getpid()); - err =3D test_function(child->test, child->subtest)(child->test, child->su= btest); + err =3D test_function(child->test, child->test_case_num)(child->test, chi= ld->test_case_num); pr_debug("---- end(%d) ----\n", err); =20 err_out: @@ -270,15 +263,16 @@ static int run_test_child(struct child_process *proce= ss) =20 #define TEST_RUNNING -3 =20 -static int print_test_result(struct test_suite *t, int i, int subtest, int= result, int width, - int running) +static int print_test_result(struct test_suite *t, int curr_suite, int cur= r_test_case, + int result, int width, int running) { - if (has_subtests(t)) { + if (test_suite__num_test_cases(t) > 1) { int subw =3D width > 2 ? width - 2 : width; =20 - pr_info("%3d.%1d: %-*s:", i + 1, subtest + 1, subw, test_description(t, = subtest)); + pr_info("%3d.%1d: %-*s:", curr_suite + 1, curr_test_case + 1, subw, + test_description(t, curr_test_case)); } else - pr_info("%3d: %-*s:", i + 1, width, test_description(t, subtest)); + pr_info("%3d: %-*s:", curr_suite + 1, width, test_description(t, curr_te= st_case)); =20 switch (result) { case TEST_RUNNING: @@ -288,7 +282,7 @@ static int print_test_result(struct test_suite *t, int = i, int subtest, int resul pr_info(" Ok\n"); break; case TEST_SKIP: { - const char *reason =3D skip_reason(t, subtest); + const char *reason =3D skip_reason(t, curr_test_case); =20 if (reason) color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", reason); @@ -310,7 +304,7 @@ static void finish_test(struct child_test **child_tests= , int running_test, int c { struct child_test *child_test =3D child_tests[running_test]; struct test_suite *t; - int i, subi, err; + int curr_suite, curr_test_case, err; bool err_done =3D false; struct strbuf err_output =3D STRBUF_INIT; int last_running =3D -1; @@ -321,15 +315,15 @@ static void finish_test(struct child_test **child_tes= ts, int running_test, int c return; } t =3D child_test->test; - i =3D child_test->test_num; - subi =3D child_test->subtest; + curr_suite =3D child_test->suite_num; + curr_test_case =3D child_test->test_case_num; err =3D child_test->process.err; /* * For test suites with subtests, display the suite name ahead of the * sub test names. */ - if (has_subtests(t) && subi =3D=3D 0) - pr_info("%3d: %-*s:\n", i + 1, width, test_description(t, -1)); + if (test_suite__num_test_cases(t) > 1 && curr_test_case =3D=3D 0) + pr_info("%3d: %-*s:\n", curr_suite + 1, width, test_description(t, -1)); =20 /* * Busy loop reading from the child's stdout/stderr that are set to be @@ -338,10 +332,11 @@ static void finish_test(struct child_test **child_tes= ts, int running_test, int c if (err > 0) fcntl(err, F_SETFL, O_NONBLOCK); if (verbose > 1) { - if (has_subtests(t)) - pr_info("%3d.%1d: %s:\n", i + 1, subi + 1, test_description(t, subi)); + if (test_suite__num_test_cases(t) > 1) + pr_info("%3d.%1d: %s:\n", curr_suite + 1, curr_test_case + 1, + test_description(t, curr_test_case)); else - pr_info("%3d: %s:\n", i + 1, test_description(t, -1)); + pr_info("%3d: %s:\n", curr_suite + 1, test_description(t, -1)); } while (!err_done) { struct pollfd pfds[1] =3D { @@ -366,7 +361,8 @@ static void finish_test(struct child_test **child_tests= , int running_test, int c */ fprintf(debug_file(), PERF_COLOR_DELETE_LINE); } - print_test_result(t, i, subi, TEST_RUNNING, width, running); + print_test_result(t, curr_suite, curr_test_case, TEST_RUNNING, + width, running); last_running =3D running; } } @@ -404,14 +400,14 @@ static void finish_test(struct child_test **child_tes= ts, int running_test, int c fprintf(stderr, "%s", err_output.buf); =20 strbuf_release(&err_output); - print_test_result(t, i, subi, ret, width, /*running=3D*/0); + print_test_result(t, curr_suite, curr_test_case, ret, width, /*running=3D= */0); if (err > 0) close(err); zfree(&child_tests[running_test]); } =20 -static int start_test(struct test_suite *test, int i, int subi, struct chi= ld_test **child, - int width, int pass) +static int start_test(struct test_suite *test, int curr_suite, int curr_te= st_case, + struct child_test **child, int width, int pass) { int err; =20 @@ -419,17 +415,18 @@ static int start_test(struct test_suite *test, int i,= int subi, struct child_tes if (dont_fork) { if (pass =3D=3D 1) { pr_debug("--- start ---\n"); - err =3D test_function(test, subi)(test, subi); + err =3D test_function(test, curr_suite)(test, curr_test_case); pr_debug("---- end ----\n"); - print_test_result(test, i, subi, err, width, /*running=3D*/0); + print_test_result(test, curr_suite, curr_test_case, err, width, + /*running=3D*/0); } return 0; } - if (pass =3D=3D 1 && !sequential && test_exclusive(test, subi)) { + if (pass =3D=3D 1 && !sequential && test_exclusive(test, curr_test_case))= { /* When parallel, skip exclusive tests on the first pass. */ return 0; } - if (pass !=3D 1 && (sequential || !test_exclusive(test, subi))) { + if (pass !=3D 1 && (sequential || !test_exclusive(test, curr_test_case)))= { /* Sequential and non-exclusive tests were run on the first pass. */ return 0; } @@ -438,8 +435,8 @@ static int start_test(struct test_suite *test, int i, i= nt subi, struct child_tes return -ENOMEM; =20 (*child)->test =3D test; - (*child)->test_num =3D i; - (*child)->subtest =3D subi; + (*child)->suite_num =3D curr_suite; + (*child)->test_case_num =3D curr_test_case; (*child)->process.pid =3D -1; (*child)->process.no_stdin =3D 1; if (verbose <=3D 0) { @@ -479,19 +476,15 @@ static int __cmd_test(struct test_suite **suites, int= argc, const char *argv[], int err =3D 0; =20 for (struct test_suite **t =3D suites; *t; t++) { - int len =3D strlen(test_description(*t, -1)); + int i, len =3D strlen(test_description(*t, -1)); =20 if (width < len) width =3D len; =20 - if (has_subtests(*t)) { - for (int subi =3D 0, subn =3D num_subtests(*t); subi < subn; subi++) { - len =3D strlen(test_description(*t, subi)); - if (width < len) - width =3D len; - num_tests++; - } - } else { + test_suite__for_each_test_case(*t, i) { + len =3D strlen(test_description(*t, i)); + if (width < len) + width =3D len; num_tests++; } } @@ -510,7 +503,7 @@ static int __cmd_test(struct test_suite **suites, int a= rgc, const char *argv[], continue; =20 pr_debug3("Killing %d pid %d\n", - child_test->test_num + 1, + child_test->suite_num + 1, child_test->process.pid); kill(child_test->process.pid, err); } @@ -526,47 +519,43 @@ static int __cmd_test(struct test_suite **suites, int= argc, const char *argv[], */ for (int pass =3D 1; pass <=3D 2; pass++) { int child_test_num =3D 0; - int i =3D 0; + int curr_suite =3D 0; =20 - for (struct test_suite **t =3D suites; *t; t++) { - int curr =3D i++; + for (struct test_suite **t =3D suites; *t; t++, curr_suite++) { + int curr_test_case; =20 - if (!perf_test__matches(test_description(*t, -1), curr, argc, argv)) { + if (!perf_test__matches(test_description(*t, -1), curr_suite, argc, arg= v)) { /* * Test suite shouldn't be run based on - * description. See if subtest should. + * description. See if any test case should. */ bool skip =3D true; =20 - for (int subi =3D 0, subn =3D num_subtests(*t); subi < subn; subi++) { - if (perf_test__matches(test_description(*t, subi), - curr, argc, argv)) + test_suite__for_each_test_case(*t, curr_test_case) { + if (perf_test__matches(test_description(*t, curr_test_case), + curr_suite, argc, argv)) { skip =3D false; + break; + } } - if (skip) continue; } =20 - if (intlist__find(skiplist, i)) { - pr_info("%3d: %-*s:", curr + 1, width, test_description(*t, -1)); + if (intlist__find(skiplist, curr_suite + 1)) { + pr_info("%3d: %-*s:", curr_suite + 1, width, + test_description(*t, -1)); color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); continue; } =20 - if (!has_subtests(*t)) { - err =3D start_test(*t, curr, -1, &child_tests[child_test_num++], - width, pass); - if (err) - goto err_out; - continue; - } - for (int subi =3D 0, subn =3D num_subtests(*t); subi < subn; subi++) { - if (!perf_test__matches(test_description(*t, subi), - curr, argc, argv)) + test_suite__for_each_test_case(*t, curr_test_case) { + if (!perf_test__matches(test_description(*t, curr_test_case), + curr_suite, argc, argv)) continue; =20 - err =3D start_test(*t, curr, subi, &child_tests[child_test_num++], + err =3D start_test(*t, curr_suite, curr_test_case, + &child_tests[child_test_num++], width, pass); if (err) goto err_out; @@ -592,23 +581,22 @@ static int __cmd_test(struct test_suite **suites, int= argc, const char *argv[], =20 static int perf_test__list(struct test_suite **suites, int argc, const cha= r **argv) { - int i =3D 0; + int curr_suite =3D 0; =20 - for (struct test_suite **t =3D suites; *t; t++) { - int curr =3D i++; + for (struct test_suite **t =3D suites; *t; t++, curr_suite++) { + int curr_test_case; =20 - if (!perf_test__matches(test_description(*t, -1), curr, argc, argv)) + if (!perf_test__matches(test_description(*t, -1), curr_suite, argc, argv= )) continue; =20 - pr_info("%3d: %s\n", i, test_description(*t, -1)); + pr_info("%3d: %s\n", curr_suite + 1, test_description(*t, -1)); =20 - if (has_subtests(*t)) { - int subn =3D num_subtests(*t); - int subi; + if (test_suite__num_test_cases(*t) <=3D 1) + continue; =20 - for (subi =3D 0; subi < subn; subi++) - pr_info("%3d:%1d: %s\n", i, subi + 1, - test_description(*t, subi)); + test_suite__for_each_test_case(*t, curr_test_case) { + pr_info("%3d:%1d: %s\n", curr_suite + 1, curr_test_case + 1, + test_description(*t, curr_test_case)); } } return 0; @@ -665,27 +653,24 @@ static struct test_suite **build_suites(void) if (suites[2] =3D=3D NULL) suites[2] =3D create_script_test_suites(); =20 -#define for_each_test(t) \ +#define for_each_suite(suite) \ for (size_t i =3D 0, j =3D 0; i < ARRAY_SIZE(suites); i++, j =3D 0) \ - while ((t =3D suites[i][j++]) !=3D NULL) + while ((suite =3D suites[i][j++]) !=3D NULL) =20 - for_each_test(t) + for_each_suite(t) num_suites++; =20 result =3D calloc(num_suites + 1, sizeof(struct test_suite *)); =20 for (int pass =3D 1; pass <=3D 2; pass++) { - for_each_test(t) { + for_each_suite(t) { bool exclusive =3D false; + int curr_test_case; =20 - if (!has_subtests(t)) { - exclusive =3D test_exclusive(t, -1); - } else { - for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - if (test_exclusive(t, subi)) { - exclusive =3D true; - break; - } + test_suite__for_each_test_case(t, curr_test_case) { + if (test_exclusive(t, curr_test_case)) { + exclusive =3D true; + break; } } if ((!exclusive && pass =3D=3D 1) || (exclusive && pass =3D=3D 2)) @@ -693,7 +678,7 @@ static struct test_suite **build_suites(void) } } return result; -#undef for_each_test +#undef for_each_suite } =20 int cmd_test(int argc, const char **argv) --=20 2.47.1.613.gc27f4b7a9f-goog From nobody Sun Feb 8 06:40:27 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 181451A8F8F for ; Tue, 7 Jan 2025 22:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287322; cv=none; b=EyV46qfUPWKSAi4anQx/lsmENFMnk5BA6kgzBbVRtMiJrcKfuTaGnMFXC+/IO8IHmC1iKTNVOM7+rctTKvsqBsa/b7Fsvbz5towBx6bv09IZMjyspmosXfaKoouL0RKU0oUj7mjQJgy3a54rQlyUfy+0m9E1LiLt1S9pDj12xQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287322; c=relaxed/simple; bh=SN+I17RDaZh8oc6X/iRBk7GMORcptVGS1eILZ2DUaL4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=KfqkcfT65pyTXE2Gv1er2TMazd2srzPMe0e+NzDIlxs1I+7Br8JhBp9z0GD9Hory0riG25v6kErjPYf3TLbEV8pcvo7Gs/PUuOR3EubADtdHGHtumycCevP8t8v21i+OBrDOgQJYQt4fio9emHqERf5YAgrdIfrVqsYcNrSIgmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=1p7xzz2s; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1p7xzz2s" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e54da6701d2so2950710276.0 for ; Tue, 07 Jan 2025 14:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736287320; x=1736892120; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ELN3tE1PcOELRVYFu0oyotf1UYI5umGCfo/xf2c5iT4=; b=1p7xzz2sOcQR1yuOUNrcprw/ytTwuMTmRLOJg0DKjkTKnm9GMZjsjUJHkJJfMNodWG MIezmnhFbGCUzl1o1eTy1N2ees6JrUuCKtz54GGqc+4tZOPgyfJyKDFEhgcYnwzPlpXd swCHL4SK0xDI7IRUprINzgHi4HEjDdtuwpbQwyzFCUFFXaFGhS5fNeTcl+cxJylt0R2e r0Ab2+yOXNkjEO3L/A6m8xJ90sZGJOEivmX6ZYT1veyag6HjL+nCzZdPI3R+mMo006zH 3Y5TvDUfgoAy7bYsnqbbf/e4dbrDrB6FkjL94usCQh4+zvrIf7bUM0L22E8A5Gio/LSO F34Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736287320; x=1736892120; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ELN3tE1PcOELRVYFu0oyotf1UYI5umGCfo/xf2c5iT4=; b=IcaQ4AGW4X1Q1Ti3iYx8pYCMruV53Kq0pRKlCRp9nmExnunv+XvBI0HfDe84cNH/mz s5gVfYQNhz6lymhowTeuJgXltMnHcOWdfzBJ1PW31CSYWsvCaRibf45p3i3ZoDvNEJBQ +ABIMXvT1IPIeehv0WmthS2lxA0NjH4X/qE0C/QK6bOBV3HZlU6p3IdlS1gsZkm2w+FL 2BIRlTYUpjmaqUaPNe7T9GwaIn0ffbLQ9UU/yr0jk/yIFXBaRmwfAIRapWzVX0YDQ+HF GJv3B1Ik8Smrj6IZrsw/Xp8q5NnaG7Y3FM3Igw6NlZKcNHZKLzYSCqEohQ85XbeEQ1dR GskA== X-Forwarded-Encrypted: i=1; AJvYcCUhJJJ08/KozH4yj8QyBMx4g1jdkN+kdjBdwt/LnoQPtM4C3WFVLkM+why/PMz0vsI3SoyhVENGN7dZY0s=@vger.kernel.org X-Gm-Message-State: AOJu0YyYcP4iBtBXO6BAA0OcBc+XnoNyCi18I4uEkuDKSrPj2bbr7PIQ WkTiqwR4QdTYt/6dASmcR4eP+qFus78sWw/IAdt9RaUpCgJR0tfdZrO+E9NzwHvS8CdWH08k4CN JLycA8g== X-Google-Smtp-Source: AGHT+IE8P6bmaO8doUvT/6uD/b37PBCLCmV+KIT5XSAnBrwgk7A1oi/pS5ozt8t21Hsv6kaldx29z/38qyXq X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:7ae:a887:5504:e3ca]) (user=irogers job=sendgmr) by 2002:a81:b104:0:b0:6e3:8562:fbf with SMTP id 00721157ae682-6f5312ed968mr16727b3.3.1736287320178; Tue, 07 Jan 2025 14:02:00 -0800 (PST) Date: Tue, 7 Jan 2025 14:01:51 -0800 In-Reply-To: <20250107220152.1213959-1-irogers@google.com> Message-Id: <20250107220152.1213959-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250107220152.1213959-1-irogers@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v2 2/3] perf test: Send list output to stdout rather than stderr From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Follow the workload listing in using stdout rather than stderr. Correct the numbering of sub-tests to be 1.1 rather than 1:1. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index c3e082efb7f4..887f735da900 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -579,7 +579,7 @@ static int __cmd_test(struct test_suite **suites, int a= rgc, const char *argv[], return err; } =20 -static int perf_test__list(struct test_suite **suites, int argc, const cha= r **argv) +static int perf_test__list(FILE *fp, struct test_suite **suites, int argc,= const char **argv) { int curr_suite =3D 0; =20 @@ -589,13 +589,13 @@ static int perf_test__list(struct test_suite **suites= , int argc, const char **ar if (!perf_test__matches(test_description(*t, -1), curr_suite, argc, argv= )) continue; =20 - pr_info("%3d: %s\n", curr_suite + 1, test_description(*t, -1)); + fprintf(fp, "%3d: %s\n", curr_suite + 1, test_description(*t, -1)); =20 if (test_suite__num_test_cases(*t) <=3D 1) continue; =20 test_suite__for_each_test_case(*t, curr_test_case) { - pr_info("%3d:%1d: %s\n", curr_suite + 1, curr_test_case + 1, + fprintf(fp, "%3d.%1d: %s\n", curr_suite + 1, curr_test_case + 1, test_description(*t, curr_test_case)); } } @@ -721,7 +721,7 @@ int cmd_test(int argc, const char **argv) argc =3D parse_options_subcommand(argc, argv, test_options, test_subcomma= nds, test_usage, 0); if (argc >=3D 1 && !strcmp(argv[0], "list")) { suites =3D build_suites(); - ret =3D perf_test__list(suites, argc - 1, argv + 1); + ret =3D perf_test__list(stdout, suites, argc - 1, argv + 1); free(suites); return ret; } --=20 2.47.1.613.gc27f4b7a9f-goog From nobody Sun Feb 8 06:40:27 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32A711D5170 for ; Tue, 7 Jan 2025 22:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287325; cv=none; b=SkSxPZVlQTHFelV0UusOD0Xsa9wAVLHCbA8Egt9bcEkNMVCDQ1ry/TdfIaYVNVhWIF+r/UsHxA4guvWpE4GafT4qL0WHLHJ+R3REYoLQREndh7M9apaWa6fTDX/VbV4E4n4g1Q+wNypaIR7/Z6OLh3z63WpfX/C9BeOrEfxhFVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287325; c=relaxed/simple; bh=yE+k+5yIhBHbG/OX936XoHFBUk0gkIqhen59eUL3Ets=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=EuhJEC+vhhpvhUMbuWaXdj9a5L9IYwEPDKwKtBlOW2uHiCETLg4mafsVlKQxFLenFNekeohmstnqEGnhn06K7BRqG4BUMSeXhVahFbz2PUWgWf+/AQw2Jy8w1iEhSDe/AYNjaGgNE4FfNijTXImjbcRXq23JroL3b1tawod9bzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ctmxSfUy; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ctmxSfUy" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e549eac4ae6so7359716276.1 for ; Tue, 07 Jan 2025 14:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736287322; x=1736892122; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=oHU2qNqeidstEjTgX/H4wyzqiStAgyte6VQxWp6nfVA=; b=ctmxSfUyVoEWi6OdylfyIku5sJOi8nyszTKL0AJ+H0v3ZTIdBg6jeKg0WaEvtnbrsQ WPqd+AclIsLyyyJXBDLIgOo3VVt28oyHXcsKvQyiEMPgJZkbzPJvj2EA6fQtHpMCeM/h o+XdLdXbm2FdAKlksepR1Gdokgfa4YaHizrZXDk0a1T5bP7MCbrdl6XdERNYixh81kMA fqYszGQFI0B2++LaU8buJwsuleUq9mZ+7NMjLV30kFkBzjKUcX1zS3hLMf2CAjp2vqxd jXS4GIAlaO3l8We3t/vZL4na85vQ8hZkVI1eKqGb/PUtqr315AoGFBbRwW7f0J2hKLWd fXxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736287322; x=1736892122; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oHU2qNqeidstEjTgX/H4wyzqiStAgyte6VQxWp6nfVA=; b=CL6ePvhf+REvhQb8RwBCSZrEwbv08HfYTjNXNDj3D+rzbQKJ2ZvRW4t/gUzMZKjsTJ P0NDVfmXrLql6n9mUHQez8pjr8udyoC3tr8unkR0ohyCVozSNz391jEk0K3mzL00ZhHf JsFBeAQcY8ZljTLLGW8TVo7sC7VVwAmleDigf04LAbE8TOjCxsJJosNj1XzGMDuXSt1t gAP0o3uW9+Of9kdr6biyXKayTTrwxKei64tijZVZSgyk3AA3ohtznWJVWoe+YtSUXqRT c37w3/HIWrO5whi7k74UjBHfoFI0DZLxwleOHDVufN1nj3bDuLN/jej+ce6f7a1XfGBy ffdQ== X-Forwarded-Encrypted: i=1; AJvYcCUDzc+WMtCtqLbMQ1N6+ywJPcOXgR8O14zYiNTIy6Y4H8rUZtY8GE9BYjTs27kn2rLuS5YCwom6X2BOjq0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4BfNGU9DnaT3LqvBePQeBdu97d3Mtc2clY3FdbTvD+RPAIvRx JVldBVraekHZeqDag1hkdDpZuMJhv/IQsfS6ATAi7eEpdNGobm13Ug9wqGyFQeRR3w5VkhlTCmD 2C7+T4w== X-Google-Smtp-Source: AGHT+IH3H7Da2sw+0ZheqyYKo8QWiPE//y8aMnfRz56LLXcwKiusIn7qXkdmZ2MQaqbJotRYnsEogmWOmNTG X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:7ae:a887:5504:e3ca]) (user=irogers job=sendgmr) by 2002:a25:cecf:0:b0:e4c:35c4:cf05 with SMTP id 3f1490d57ef6-e54ee1e51a6mr1183276.5.1736287322339; Tue, 07 Jan 2025 14:02:02 -0800 (PST) Date: Tue, 7 Jan 2025 14:01:52 -0800 In-Reply-To: <20250107220152.1213959-1-irogers@google.com> Message-Id: <20250107220152.1213959-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250107220152.1213959-1-irogers@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v2 3/3] perf test: Add a runs-per-test flag From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To detect flakes it is useful to run tests more than once. Add a runs-per-test flag that will run each test multiple times. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 887f735da900..729740c1e5e5 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -42,6 +42,8 @@ static bool dont_fork; /* Fork the tests in parallel and wait for their completion. */ static bool sequential; +/* Number of times each test is run. */ +static unsigned int runs_per_test =3D 1; const char *dso_to_test; const char *test_objdump_path =3D "objdump"; =20 @@ -485,7 +487,7 @@ static int __cmd_test(struct test_suite **suites, int a= rgc, const char *argv[], len =3D strlen(test_description(*t, i)); if (width < len) width =3D len; - num_tests++; + num_tests +=3D runs_per_test; } } child_tests =3D calloc(num_tests, sizeof(*child_tests)); @@ -549,16 +551,18 @@ static int __cmd_test(struct test_suite **suites, int= argc, const char *argv[], continue; } =20 - test_suite__for_each_test_case(*t, curr_test_case) { - if (!perf_test__matches(test_description(*t, curr_test_case), - curr_suite, argc, argv)) - continue; - - err =3D start_test(*t, curr_suite, curr_test_case, - &child_tests[child_test_num++], - width, pass); - if (err) - goto err_out; + for (unsigned int run =3D 0; run < runs_per_test; run++) { + test_suite__for_each_test_case(*t, curr_test_case) { + if (!perf_test__matches(test_description(*t, curr_test_case), + curr_suite, argc, argv)) + continue; + + err =3D start_test(*t, curr_suite, curr_test_case, + &child_tests[child_test_num++], + width, pass); + if (err) + goto err_out; + } } } if (!sequential) { @@ -698,6 +702,8 @@ int cmd_test(int argc, const char **argv) "Do not fork for testcase"), OPT_BOOLEAN('S', "sequential", &sequential, "Run the tests one after another rather than in parallel"), + OPT_UINTEGER('r', "runs-per-test", &runs_per_test, + "Run each test the given number of times, default 1"), OPT_STRING('w', "workload", &workload, "work", "workload to run for testi= ng, use '--list-workloads' to list the available ones."), OPT_BOOLEAN(0, "list-workloads", &list_workloads, "List the available bui= ltin workloads to use with -w/--workload"), OPT_STRING(0, "dso", &dso_to_test, "dso", "dso to test"), --=20 2.47.1.613.gc27f4b7a9f-goog