Add urandom_test to all_tests.json
Change-Id: I4e30bc8b8c1bd1215f516a6c89735782cfbf8ef5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38284
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
diff --git a/crypto/fipsmodule/rand/urandom_test.cc b/crypto/fipsmodule/rand/urandom_test.cc
index 117c315..5935aaf 100644
--- a/crypto/fipsmodule/rand/urandom_test.cc
+++ b/crypto/fipsmodule/rand/urandom_test.cc
@@ -21,7 +21,8 @@
#if defined(OPENSSL_X86_64) && defined(OPENSSL_LINUX) && \
- !defined(BORINGSSL_SHARED_LIBRARY)
+ !defined(BORINGSSL_SHARED_LIBRARY) && \
+ !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
#include <linux/random.h>
#include <sys/ptrace.h>
@@ -466,6 +467,9 @@
#else
-int main(int argc, char **argv) { return 0; }
+int main(int argc, char **argv) {
+ printf("PASS\n");
+ return 0;
+}
-#endif // X86_64 && LINUX && !SHARED_LIBRARY
+#endif // X86_64 && LINUX && !SHARED_LIBRARY && !UNSAFE_DETERMINISTIC_MODE
diff --git a/util/all_tests.go b/util/all_tests.go
index fbff48c..4dd7f2c 100644
--- a/util/all_tests.go
+++ b/util/all_tests.go
@@ -55,6 +55,7 @@
}
type test struct {
+ env []string
args []string
shard, numShards int
// cpu, if not empty, contains a code to simulate. For SDE, run `sde64
@@ -148,7 +149,7 @@
prog := path.Join(*buildDir, test.args[0])
args := append([]string{}, test.args[1:]...)
if *simulateARMCPUs && test.cpu != "" {
- args = append(args, "--cpu=" + test.cpu)
+ args = append(args, "--cpu="+test.cpu)
}
if *useSDE {
// SDE is neither compatible with the unwind tester nor automatically
@@ -167,6 +168,11 @@
} else {
cmd = exec.Command(prog, args...)
}
+ if test.env != nil {
+ cmd.Env = make([]string, len(os.Environ()))
+ copy(cmd.Env, os.Environ())
+ cmd.Env = append(cmd.Env, test.env...)
+ }
var outBuf bytes.Buffer
cmd.Stdout = &outBuf
cmd.Stderr = &outBuf
@@ -258,7 +264,12 @@
var result []test
for _, args := range testArgs {
- result = append(result, test{args: args})
+ var env []string
+ for len(args) > 0 && strings.HasPrefix(args[0], "$") {
+ env = append(env, args[0][1:])
+ args = args[1:]
+ }
+ result = append(result, test{args: args, env: env})
}
return result, nil
}
@@ -272,11 +283,18 @@
}
func (t test) shortName() string {
- return t.args[0] + t.shardMsg() + t.cpuMsg()
+ return t.args[0] + t.shardMsg() + t.cpuMsg() + t.envMsg()
+}
+
+func SpaceIf(returnSpace bool) string {
+ if !returnSpace {
+ return ""
+ }
+ return " "
}
func (t test) longName() string {
- return strings.Join(t.args, " ") + t.cpuMsg()
+ return strings.Join(t.env, " ") + SpaceIf(len(t.env) != 0) + strings.Join(t.args, " ") + t.cpuMsg()
}
func (t test) shardMsg() string {
@@ -295,6 +313,14 @@
return fmt.Sprintf(" (for CPU %q)", t.cpu)
}
+func (t test) envMsg() string {
+ if len(t.env) == 0 {
+ return ""
+ }
+
+ return " (custom environment)"
+}
+
func (t test) getGTestShards() ([]test, error) {
if *numWorkers == 1 || len(t.args) != 1 {
return []test{t}, nil
diff --git a/util/all_tests.json b/util/all_tests.json
index 7152ec1..578b727 100644
--- a/util/all_tests.json
+++ b/util/all_tests.json
@@ -1,5 +1,7 @@
[
["crypto/crypto_test"],
+ ["crypto/urandom_test"],
+ ["$OPENSSL_ia32cap=~0x4000000000000000", "crypto/urandom_test"],
["crypto/crypto_test", "--fork_unsafe_buffering", "--gtest_filter=RandTest.*:-RandTest.Fork"],
["decrepit/decrepit_test"],
["ssl/ssl_test"]
diff --git a/util/run_android_tests.go b/util/run_android_tests.go
index c5abdcb..60009a1 100644
--- a/util/run_android_tests.go
+++ b/util/run_android_tests.go
@@ -135,7 +135,10 @@
panic("Couldn't find BUILDING.md in a parent directory!")
}
-type test []string
+type test struct {
+ args []string
+ env []string
+}
func parseTestConfig(filename string) ([]test, error) {
in, err := os.Open(filename)
@@ -145,11 +148,22 @@
defer in.Close()
decoder := json.NewDecoder(in)
- var result []test
+ var result [][]string
if err := decoder.Decode(&result); err != nil {
return nil, err
}
- return result, nil
+
+ tests := make([]test, 0, len(result))
+ for _, args := range result {
+ var env []string
+ for len(args) > 0 && strings.HasPrefix(args[0], "$") {
+ env = append(env, args[0][1:])
+ args = args[1:]
+ }
+ tests = append(tests, test{args: args, env: env})
+ }
+
+ return tests, nil
}
func copyFile(dst, src string) error {
@@ -219,11 +233,11 @@
seenBinary := make(map[string]struct{})
for _, test := range tests {
- if _, ok := seenBinary[test[0]]; !ok {
- binaries = append(binaries, test[0])
- seenBinary[test[0]] = struct{}{}
+ if _, ok := seenBinary[test.args[0]]; !ok {
+ binaries = append(binaries, test.args[0])
+ seenBinary[test.args[0]] = struct{}{}
}
- for _, arg := range test[1:] {
+ for _, arg := range test.args[1:] {
if strings.Contains(arg, "/") {
files = append(files, arg)
}