shithub: dav1d

Download patch

ref: 95a192549a448b70d9542e840c4e34b60d09b093
parent: 06f12a8995f00baef98f324f57bab3b95af05f7f
author: Martin Storsjö <martin@martin.st>
date: Wed Aug 5 08:36:33 EDT 2020

checkasm: Explicitly test whether the readtime() function works

This gives a clearer indication about what is wrong, instead of
running into illegal instruction errors in the individual tests.

On ARM and AArch64, access to the cycle counter register is forbidden
in user mode code by default on Linux and Darwin.

--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -520,7 +520,6 @@
 int main(int argc, char *argv[]) {
     (void)func_new, (void)func_ref;
     state.seed = get_seed();
-    int ret = 0;
 
     while (argc > 1) {
         if (!strncmp(argv[1], "--help", 6)) {
@@ -568,6 +567,22 @@
 
     dav1d_init_cpu();
 
+    if (state.bench_pattern) {
+        static int testing = 0;
+        checkasm_save_context();
+        if (!testing) {
+            checkasm_set_signal_handler_state(1);
+            testing = 1;
+            readtime();
+            checkasm_set_signal_handler_state(0);
+        } else {
+            fprintf(stderr, "checkasm: unable to access cycle counter\n");
+            return 1;
+        }
+    }
+
+    int ret = 0;
+
     if (!state.function_listing) {
         fprintf(stderr, "checkasm: using random seed %u\n", state.seed);
 #if ARCH_X86_64
@@ -672,7 +687,9 @@
 /* Indicate that the current test has failed, return whether verbose printing
  * is requested. */
 int checkasm_fail_func(const char *const msg, ...) {
-    if (state.current_func_ver->cpu && state.current_func_ver->ok) {
+    if (state.current_func_ver && state.current_func_ver->cpu &&
+        state.current_func_ver->ok)
+    {
         va_list arg;
 
         print_cpu_name();