Skip to content

Commit 525c821

Browse files
nick-armacmel
authored andcommitted
perf tests: Add test for the java demangler
Split from a larger patch that was also fixing a problem with the java demangler, so, before applying that patch we see: $ perf test java 65: Demangle Java : FAILED! $ perf test -v java 65: Demangle Java : --- start --- test child forked, pid 307264 FAILED: Ljava/lang/StringLatin1;equals([B[B)Z: bool class java.lang.StringLatin1.equals(byte[], byte[]) != boolean java.lang.StringLatin1.equals(byte[], byte[]) FAILED: Ljava/util/zip/ZipUtils;CENSIZ([BI)J: long class java.util.zip.ZipUtils.CENSIZ(byte[], int) != long java.util.zip.ZipUtils.CENSIZ(byte[], int) FAILED: Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z: bool class java.util.regex.Pattern$BmpCharProperty.match(class java.util.regex.Matcher., int, class java.lang., charhar, shortequence) != boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence) FAILED: Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V: void class java.lang.AbstractStringBuilder.appendChars(class java.lang., shorttring., int, int) != void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int) FAILED: Ljava/lang/Object;<init>()V: void class java.lang.Object<init>() != void java.lang.Object<init>() test child finished with -1 ---- end ---- Demangle Java: FAILED! $ Next patch should fix this. Signed-off-by: Nick Gasson <nick.gasson@arm.com> Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20200427061520.24905-4-nick.gasson@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 959f8ed commit 525c821

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎tools/perf/tests/Build‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ perf-y += maps.o
5757
perf-y += time-utils-test.o
5858
perf-y += genelf.o
5959
perf-y += api-io.o
60+
perf-y += demangle-java-test.o
6061

6162
$(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
6263
$(call rule_mkdir)

‎tools/perf/tests/builtin-test.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ static struct test generic_tests[] = {
324324
.desc = "maps__merge_in",
325325
.func = test__maps__merge_in,
326326
},
327+
{
328+
.desc = "Demangle Java",
329+
.func = test__demangle_java,
330+
},
327331
{
328332
.func = NULL,
329333
},
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <string.h>
3+
#include <stdlib.h>
4+
#include <stdio.h>
5+
#include "tests.h"
6+
#include "session.h"
7+
#include "debug.h"
8+
#include "demangle-java.h"
9+
10+
int test__demangle_java(struct test *test __maybe_unused, int subtest __maybe_unused)
11+
{
12+
int ret = TEST_OK;
13+
char *buf = NULL;
14+
size_t i;
15+
16+
struct {
17+
const char *mangled, *demangled;
18+
} test_cases[] = {
19+
{ "Ljava/lang/StringLatin1;equals([B[B)Z",
20+
"boolean java.lang.StringLatin1.equals(byte[], byte[])" },
21+
{ "Ljava/util/zip/ZipUtils;CENSIZ([BI)J",
22+
"long java.util.zip.ZipUtils.CENSIZ(byte[], int)" },
23+
{ "Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z",
24+
"boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence)" },
25+
{ "Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V",
26+
"void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int)" },
27+
{ "Ljava/lang/Object;<init>()V",
28+
"void java.lang.Object<init>()" },
29+
};
30+
31+
for (i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); i++) {
32+
buf = java_demangle_sym(test_cases[i].mangled, 0);
33+
if (strcmp(buf, test_cases[i].demangled)) {
34+
pr_debug("FAILED: %s: %s != %s\n", test_cases[i].mangled,
35+
buf, test_cases[i].demangled);
36+
ret = TEST_FAIL;
37+
}
38+
free(buf);
39+
}
40+
41+
return ret;
42+
}

‎tools/perf/tests/tests.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ int test__maps__merge_in(struct test *t, int subtest);
117117
int test__time_utils(struct test *t, int subtest);
118118
int test__jit_write_elf(struct test *test, int subtest);
119119
int test__api_io(struct test *test, int subtest);
120+
int test__demangle_java(struct test *test, int subtest);
120121

121122
bool test__bp_signal_is_supported(void);
122123
bool test__bp_account_is_supported(void);

0 commit comments

Comments
 (0)