at for-next 1.4 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2#include <string.h> 3#include <stdlib.h> 4#include <stdio.h> 5#include <linux/kernel.h> 6#include "tests.h" 7#include "session.h" 8#include "debug.h" 9#include "demangle-java.h" 10 11static int test__demangle_java(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 12{ 13 int ret = TEST_OK; 14 char *buf = NULL; 15 size_t i; 16 17 struct { 18 const char *mangled, *demangled; 19 } test_cases[] = { 20 { "Ljava/lang/StringLatin1;equals([B[B)Z", 21 "boolean java.lang.StringLatin1.equals(byte[], byte[])" }, 22 { "Ljava/util/zip/ZipUtils;CENSIZ([BI)J", 23 "long java.util.zip.ZipUtils.CENSIZ(byte[], int)" }, 24 { "Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z", 25 "boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence)" }, 26 { "Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V", 27 "void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int)" }, 28 { "Ljava/lang/Object;<init>()V", 29 "void java.lang.Object<init>()" }, 30 }; 31 32 for (i = 0; i < ARRAY_SIZE(test_cases); i++) { 33 buf = java_demangle_sym(test_cases[i].mangled, 0); 34 if (strcmp(buf, test_cases[i].demangled)) { 35 pr_debug("FAILED: %s: %s != %s\n", test_cases[i].mangled, 36 buf, test_cases[i].demangled); 37 ret = TEST_FAIL; 38 } 39 free(buf); 40 } 41 42 return ret; 43} 44 45DEFINE_SUITE("Demangle Java", demangle_java);