Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictorien Le Couviour--Tuffet <victorien@videolan.org>2022-08-29 16:09:55 +0300
committerVictorien Le Couviour--Tuffet <victorien@videolan.org>2022-09-02 18:15:18 +0300
commitd5d37926b675e3d282fd7ee31a2db4c2f16a2b33 (patch)
tree1095d16418da6835d76135c58bbe8ee74bda685a
parenta3a55b18494f5dd1e34f289298f78ffa4f32a25d (diff)
checkasm: Add a --function option
Allows to run checkasm only for functions matching a given pattern.
-rw-r--r--tests/checkasm/checkasm.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 20245c7..af8ead1 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -129,6 +129,7 @@ static struct {
unsigned cpu_flag;
const char *cpu_flag_name;
const char *test_name;
+ const char *function_pattern;
unsigned seed;
int bench_c;
int verbose;
@@ -489,6 +490,21 @@ static void signal_handler(const int s) {
}
#endif
+/* Compares a string with a wildcard pattern. */
+static int wildstrcmp(const char *str, const char *pattern) {
+ const char *wild = strchr(pattern, '*');
+ if (wild) {
+ const size_t len = wild - pattern;
+ if (strncmp(str, pattern, len)) return 1;
+ while (*++wild == '*');
+ if (!*wild) return 0;
+ str += len;
+ while (*str && wildstrcmp(str, wild)) str++;
+ return !*str;
+ }
+ return strcmp(str, pattern);
+}
+
/* Perform tests and benchmarks for the specified
* cpu flag if supported by the host */
static void check_cpu_flag(const char *const name, unsigned flag) {
@@ -539,14 +555,15 @@ int main(int argc, char *argv[]) {
if (!strncmp(argv[1], "--help", 6)) {
fprintf(stderr,
"checkasm [options] <random seed>\n"
- " <random seed> Numeric value to seed the rng\n"
+ " <random seed> Numeric value to seed the rng\n"
"Options:\n"
- " --test=<test_name> Test only <test_name>\n"
- " --bench=<pattern> Test and benchmark the functions matching <pattern>\n"
- " --list-functions List available functions\n"
- " --list-tests List available tests\n"
- " --bench-c Benchmark the C-only functions\n"
- " --verbose -v Print failures verbosely\n");
+ " --test=<test_name> Test only <test_name>\n"
+ " --function=<pattern> Test only the functions matching <pattern>\n"
+ " --bench=<pattern> Test and benchmark the functions matching <pattern>\n"
+ " --list-functions List available functions\n"
+ " --list-tests List available tests\n"
+ " --bench-c Benchmark the C-only functions\n"
+ " --verbose -v Print failures verbosely\n");
return 0;
} else if (!strncmp(argv[1], "--bench-c", 9)) {
state.bench_c = 1;
@@ -563,6 +580,8 @@ int main(int argc, char *argv[]) {
state.bench_pattern = "";
} else if (!strncmp(argv[1], "--test=", 7)) {
state.test_name = argv[1] + 7;
+ } else if (!strncmp(argv[1], "--function=", 11)) {
+ state.function_pattern = argv[1] + 11;
} else if (!strcmp(argv[1], "--list-functions")) {
state.function_listing = 1;
} else if (!strcmp(argv[1], "--list-tests")) {
@@ -682,8 +701,11 @@ void *checkasm_check_func(void *const func, const char *const name, ...) {
const int name_length = vsnprintf(name_buf, sizeof(name_buf), name, arg);
va_end(arg);
- if (!func || name_length <= 0 || (size_t)name_length >= sizeof(name_buf))
+ if (!func || name_length <= 0 || (size_t)name_length >= sizeof(name_buf) ||
+ (state.function_pattern && wildstrcmp(name_buf, state.function_pattern)))
+ {
return NULL;
+ }
state.current_func = get_func(&state.funcs, name_buf);