Add QEMU user option for running tests.
The QEMU option is particularly useful for running RISC-V based tests,
for which there does not exist any RISC-V hardware for native execution.
This change was verified locally using the following command:
go run util/all_tests.go \
--qemu /usr/local/google/home/aknobloch/Downloads/qemu-build/usr/bin/qemu-riscv64 \
The tests took ~20 minutes to complete.
Change-Id: Ide9514d5d6a024d8c42a4a129d7e4a6582b5878a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68887
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: Aaron Knobloch <aknobloch@google.com>
diff --git a/util/all_tests.go b/util/all_tests.go
index 4090943..d80cd60 100644
--- a/util/all_tests.go
+++ b/util/all_tests.go
@@ -48,6 +48,7 @@
mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.")
mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask each test to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.")
simulateARMCPUs = flag.Bool("simulate-arm-cpus", simulateARMCPUsDefault(), "If true, runs tests simulating different ARM CPUs.")
+ qemuBinary = flag.String("qemu", "", "Optional, absolute path to a binary location for QEMU runtime.")
)
func simulateARMCPUsDefault() bool {
@@ -145,6 +146,13 @@
return exec.Command(*sdePath, sdeArgs...)
}
+func qemuOf(path string, args ...string) *exec.Cmd {
+ // The QEMU binary becomes the program to run, and the previous test program
+ // to run instead becomes an additional argument to the QEMU binary.
+ args = append([]string{path}, args...)
+ return exec.Command(*qemuBinary, args...)
+}
+
var (
errMoreMallocs = errors.New("child process did not exhaust all allocation calls")
errTestSkipped = errors.New("test was skipped")
@@ -161,6 +169,7 @@
// detected.
args = append(args, "--no_unwind_tests")
}
+
var cmd *exec.Cmd
if *useValgrind {
cmd = valgrindOf(false, prog, args...)
@@ -170,6 +179,8 @@
cmd = gdbOf(prog, args...)
} else if *useSDE {
cmd = sdeOf(test.cpu, prog, args...)
+ } else if *qemuBinary != "" {
+ cmd = qemuOf(prog, args...)
} else {
cmd = exec.Command(prog, args...)
}