Index: content/common/sandbox_mac_system_access_unittest.mm |
diff --git a/content/common/sandbox_mac_system_access_unittest.mm b/content/common/sandbox_mac_system_access_unittest.mm |
index c527ea5be29b1f58c309482df3e19524df0d0e60..95503a5f6cb50d241b3d1a8bb429c7b28454628b 100644 |
--- a/content/common/sandbox_mac_system_access_unittest.mm |
+++ b/content/common/sandbox_mac_system_access_unittest.mm |
@@ -10,9 +10,15 @@ |
#include "base/strings/sys_string_conversions.h" |
#include "content/common/sandbox_mac.h" |
#include "content/common/sandbox_mac_unittest_helper.h" |
-#include "crypto/nss_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#if defined(USE_OPENSSL) |
+#include <openssl/rand.h> |
+#include "crypto/openssl_util.h" |
+#else |
+#include "crypto/nss_util.h" |
+#endif |
+ |
namespace content { |
//--------------------- Clipboard Sandboxing ---------------------- |
@@ -120,6 +126,31 @@ TEST_F(MacSandboxTest, UrandomAccess) { |
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedUrandomTestCase", NULL)); |
} |
+#if defined(USE_OPENSSL) |
+ |
+//--------------------- OpenSSL Sandboxing ---------------------- |
+// Test case for checking sandboxing of OpenSSL initialization. |
+class MacSandboxedOpenSSLTestCase : public MacSandboxTestCase { |
+ public: |
+ virtual bool SandboxedTest() OVERRIDE; |
+}; |
+ |
+REGISTER_SANDBOX_TEST_CASE(MacSandboxedOpenSSLTestCase); |
+ |
+bool MacSandboxedOpenSSLTestCase::SandboxedTest() { |
+ crypto::EnsureOpenSSLInit(); |
+ |
+ // Ensure that RAND_bytes is functional within the sandbox. |
+ uint8_t byte; |
+ return RAND_bytes(&byte, 1) == 1; |
+} |
+ |
+TEST_F(MacSandboxTest, OpenSSLAccess) { |
+ EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedOpenSSLTestCase", NULL)); |
+} |
+ |
+#else // !defined(USE_OPENSSL) |
+ |
//--------------------- NSS Sandboxing ---------------------- |
// Test case for checking sandboxing of NSS initialization. |
class MacSandboxedNSSTestCase : public MacSandboxTestCase { |
@@ -141,4 +172,6 @@ TEST_F(MacSandboxTest, NSSAccess) { |
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedNSSTestCase", NULL)); |
} |
+#endif // defined(USE_OPENSSL) |
+ |
} // namespace content |