Fix run_android_tests.go with shared library builds. In particular, the FIPS builds use shared libraries. Change-Id: I4ca3a289ad3af8ab24c4bf1aecd5de67f9496f15 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38147 Commit-Queue: David Benjamin <davidben@google.com> Commit-Queue: Adam Langley <agl@google.com> Reviewed-by: Adam Langley <agl@google.com>
diff --git a/util/run_android_tests.go b/util/run_android_tests.go index 115c3da..c5abdcb 100644 --- a/util/run_android_tests.go +++ b/util/run_android_tests.go
@@ -268,6 +268,19 @@ } } + var libraries []string + if _, err := os.Stat(filepath.Join(*buildDir, "crypto/libcrypto.so")); err == nil { + libraries = []string{ + "libboringssl_gtest.so", + "crypto/libcrypto.so", + "decrepit/libdecrepit.so", + "ssl/libssl.so", + } + } else if !os.IsNotExist(err) { + fmt.Printf("Failed to stat crypto/libcrypto.so: %s\n", err) + os.Exit(1) + } + fmt.Printf("Copying test binaries...\n") for _, binary := range binaries { if err := copyFile(filepath.Join(tmpDir, "build", binary), filepath.Join(*buildDir, binary)); err != nil { @@ -276,6 +289,20 @@ } } + var envPrefix string + if len(libraries) > 0 { + fmt.Printf("Copying libraries...\n") + for _, library := range libraries { + // Place all the libraries in a common directory so they + // can be passed to LD_LIBRARY_PATH once. + if err := copyFile(filepath.Join(tmpDir, "build", "lib", filepath.Base(library)), filepath.Join(*buildDir, library)); err != nil { + fmt.Printf("Failed to copy %s: %s\n", library, err) + os.Exit(1) + } + } + envPrefix = "env LD_LIBRARY_PATH=/data/local/tmp/boringssl-tmp/build/lib " + } + fmt.Printf("Copying data files...\n") for _, file := range files { if err := copyFile(filepath.Join(tmpDir, file), file); err != nil { @@ -293,7 +320,7 @@ var unitTestExit int if enableUnitTests() { fmt.Printf("Running unit tests...\n") - unitTestExit, err = adbShell(fmt.Sprintf("cd /data/local/tmp/boringssl-tmp && ./util/all_tests -json-output results.json %s", *allTestsArgs)) + unitTestExit, err = adbShell(fmt.Sprintf("cd /data/local/tmp/boringssl-tmp && %s./util/all_tests -json-output results.json %s", envPrefix, *allTestsArgs)) if err != nil { fmt.Printf("Failed to run unit tests: %s\n", err) os.Exit(1) @@ -303,7 +330,7 @@ var sslTestExit int if enableSSLTests() { fmt.Printf("Running SSL tests...\n") - sslTestExit, err = adbShell(fmt.Sprintf("cd /data/local/tmp/boringssl-tmp/ssl/test/runner && ./runner -json-output ../../../results.json %s", *runnerArgs)) + sslTestExit, err = adbShell(fmt.Sprintf("cd /data/local/tmp/boringssl-tmp/ssl/test/runner && %s./runner -json-output ../../../results.json %s", envPrefix, *runnerArgs)) if err != nil { fmt.Printf("Failed to run SSL tests: %s\n", err) os.Exit(1)