pan/bi: Stub out scheduler unit test
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 21 Dec 2020 20:20:37 +0000 (15:20 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 Jan 2021 16:55:44 +0000 (16:55 +0000)
Someone who understands meson and gtest could do something much nicer,
but for now let's just stuff some assertions into debug builds of the
standalone compiler and call it a day...

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723>

src/panfrost/bifrost/bi_schedule.c
src/panfrost/bifrost/cmdline.c
src/panfrost/bifrost/compiler.h

index 56bca63..7b1f2f9 100644 (file)
@@ -187,3 +187,10 @@ bi_schedule(bi_context *ctx)
                 bblock->scheduled = true;
         }
 }
+
+#ifndef NDEBUG
+int bi_test_scheduler(void)
+{
+        return 0;
+}
+#endif
index c022374..bb37c16 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "disassemble.h"
+#include "compiler.h"
 
 #include "main/mtypes.h"
 #include "compiler/glsl/standalone.h"
@@ -117,6 +118,19 @@ disassemble(const char *filename, bool verbose)
         free(code);
 }
 
+static int
+bi_tests()
+{
+#ifndef NDEBUG
+        bi_test_scheduler();
+        printf("Pass.\n");
+        return 0;
+#else
+        printf("Tests omitted in release mode.");
+        return 1;
+#endif
+}
+
 int
 main(int argc, char **argv)
 {
@@ -131,6 +145,8 @@ main(int argc, char **argv)
                 disassemble(argv[2], false);
         else if (strcmp(argv[1], "disasm-verbose") == 0)
                 disassemble(argv[2], true);
+        else if (strcmp(argv[1], "test") == 0)
+                bi_tests();
         else
                 unreachable("Unknown command. Valid: compile/disasm");
 
index 41e57de..94d4ee3 100644 (file)
@@ -728,6 +728,9 @@ bool bi_opt_dead_code_eliminate(bi_context *ctx, bi_block *block, bool soft);
 void bi_schedule(bi_context *ctx);
 void bi_register_allocate(bi_context *ctx);
 
+/* Test suite */
+int bi_test_scheduler(void);
+
 bi_clause *
 bi_singleton(void *memctx, bi_instr *ins,
                 bi_block *block,