From 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Tue, 22 Oct 2024 10:36:11 +0000 Subject: [PATCH] 修改4g拨号为QMI,需要在系统里后台执行quectel-CM --- kernel/tools/perf/tests/builtin-test.c | 139 +++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 124 insertions(+), 15 deletions(-) diff --git a/kernel/tools/perf/tests/builtin-test.c b/kernel/tools/perf/tests/builtin-test.c index d7a5e1b..73c911d 100644 --- a/kernel/tools/perf/tests/builtin-test.c +++ b/kernel/tools/perf/tests/builtin-test.c @@ -8,6 +8,7 @@ #include <errno.h> #include <unistd.h> #include <string.h> +#include <stdlib.h> #include <sys/types.h> #include <dirent.h> #include <sys/wait.h> @@ -21,7 +22,9 @@ #include <subcmd/parse-options.h> #include "string2.h" #include "symbol.h" +#include "util/rlimit.h" #include <linux/kernel.h> +#include <linux/string.h> #include <subcmd/exec-cmd.h> static bool dont_fork; @@ -68,6 +71,17 @@ { .desc = "Parse perf pmu format", .func = test__pmu, + }, + { + .desc = "PMU events", + .func = test__pmu_events, + .subtest = { + .skip_if_fail = false, + .get_nr = test__pmu_events_subtest_get_nr, + .get_desc = test__pmu_events_subtest_get_desc, + .skip_reason = test__pmu_events_subtest_skip_reason, + }, + }, { .desc = "DSO data read", @@ -118,7 +132,17 @@ { .desc = "Breakpoint accounting", .func = test__bp_accounting, - .is_supported = test__bp_signal_is_supported, + .is_supported = test__bp_account_is_supported, + }, + { + .desc = "Watchpoint", + .func = test__wp, + .is_supported = test__wp_is_supported, + .subtest = { + .skip_if_fail = false, + .get_nr = test__wp_subtest_get_nr, + .get_desc = test__wp_subtest_get_desc, + }, }, { .desc = "Number of exit events of a simple workload", @@ -153,8 +177,8 @@ .func = test__mmap_thread_lookup, }, { - .desc = "Share thread mg", - .func = test__thread_mg_share, + .desc = "Share thread maps", + .func = test__thread_maps_share, }, { .desc = "Sort output of hist entries", @@ -247,6 +271,11 @@ .func = test__cpu_map_print, }, { + .desc = "Merge cpu map", + .func = test__cpu_map_merge, + }, + + { .desc = "Probe SDT events", .func = test__sdt_event, }, @@ -280,6 +309,47 @@ .func = test__mem2node, }, { + .desc = "time utils", + .func = test__time_utils, + }, + { + .desc = "Test jit_write_elf", + .func = test__jit_write_elf, + }, + { + .desc = "Test libpfm4 support", + .func = test__pfm, + .subtest = { + .skip_if_fail = true, + .get_nr = test__pfm_subtest_get_nr, + .get_desc = test__pfm_subtest_get_desc, + } + }, + { + .desc = "Test api io", + .func = test__api_io, + }, + { + .desc = "maps__merge_in", + .func = test__maps__merge_in, + }, + { + .desc = "Demangle Java", + .func = test__demangle_java, + }, + { + .desc = "Parse and process metrics", + .func = test__parse_metric, + }, + { + .desc = "PE file support", + .func = test__pe_file_parsing, + }, + { + .desc = "Event expansion for cgroups", + .func = test__expand_cgroup_events, + }, + { .func = NULL, }, }; @@ -289,7 +359,7 @@ arch_tests, }; -static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[]) +static bool perf_test__matches(const char *desc, int curr, int argc, const char *argv[]) { int i; @@ -306,7 +376,7 @@ continue; } - if (strcasestr(test->desc, argv[i])) + if (strcasestr(desc, argv[i])) return true; } @@ -391,8 +461,15 @@ case TEST_OK: pr_info(" Ok\n"); break; - case TEST_SKIP: - color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n"); + 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); + else + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n"); + } break; case TEST_FAIL: default: @@ -414,10 +491,13 @@ if (!fp) return NULL; + /* Skip shebang */ + while (fgetc(fp) != '\n'); + description = fgets(description, size, fp); fclose(fp); - return description ? trim(description + 1) : NULL; + return description ? strim(description + 1) : NULL; } #define for_each_shell_test(dir, base, ent) \ @@ -510,8 +590,11 @@ return -1; dir = opendir(st.dir); - if (!dir) + if (!dir) { + pr_err("failed to open shell test directory: %s\n", + st.dir); return -1; + } for_each_shell_test(dir, st.dir, ent) { int curr = i++; @@ -522,7 +605,7 @@ .priv = &st, }; - if (!perf_test__matches(&test, curr, argc, argv)) + if (!perf_test__matches(test.desc, curr, argc, argv)) continue; st.file = ent->d_name; @@ -550,9 +633,25 @@ for_each_test(j, t) { int curr = i++, err; + int subi; - if (!perf_test__matches(t, curr, argc, argv)) - continue; + if (!perf_test__matches(t->desc, curr, argc, argv)) { + bool skip = true; + int subn; + + if (!t->subtest.get_nr) + continue; + + subn = t->subtest.get_nr(); + + for (subi = 0; subi < subn; subi++) { + if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv)) + skip = false; + } + + if (skip) + continue; + } if (t->is_supported && !t->is_supported()) { pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc); @@ -580,7 +679,6 @@ */ int subw = width > 2 ? width - 2 : width; bool skip = false; - int subi; if (subn <= 0) { color_fprintf(stderr, PERF_COLOR_YELLOW, @@ -597,6 +695,9 @@ } for (subi = 0; subi < subn; subi++) { + if (!perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv)) + continue; + pr_info("%2d.%1d: %-*s:", i, subi + 1, subw, t->subtest.get_desc(subi)); err = test_and_print(t, skip, subi); @@ -630,7 +731,7 @@ .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name), }; - if (!perf_test__matches(&t, curr, argc, argv)) + if (!perf_test__matches(t.desc, curr, argc, argv)) continue; pr_info("%2d: %s\n", i, t.desc); @@ -649,7 +750,7 @@ for_each_test(j, t) { int curr = i++; - if (!perf_test__matches(t, curr, argc, argv) || + if (!perf_test__matches(t->desc, curr, argc, argv) || (t->is_supported && !t->is_supported())) continue; @@ -692,6 +793,9 @@ if (ret < 0) return ret; + /* Unbuffered output */ + setvbuf(stdout, NULL, _IONBF, 0); + argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0); if (argc >= 1 && !strcmp(argv[0], "list")) return perf_test__list(argc - 1, argv + 1); @@ -705,6 +809,11 @@ if (skip != NULL) skiplist = intlist__new(skip); + /* + * Tests that create BPF maps, for instance, need more than the 64K + * default: + */ + rlimit__bump_memlock(); return __cmd_test(argc, argv, skiplist); } -- Gitblit v1.6.2