Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: third_party/boringssl/boringssl_unittest.cc

Issue 377783004: Add BoringSSL GYP files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final Python fix. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/boringssl/boringssl_tests.gypi ('k') | third_party/boringssl/linux-arm/crypto/aes/aes-armv4.S » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/boringssl/boringssl_unittest.cc
diff --git a/third_party/boringssl/boringssl_unittest.cc b/third_party/boringssl/boringssl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..287b9129c341f203951bb64da75d6cba082c41a8
--- /dev/null
+++ b/third_party/boringssl/boringssl_unittest.cc
@@ -0,0 +1,185 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdarg.h>
+
+#include <string>
+
+#include "base/base_paths.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/process/launch.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+void TestProcess(const std::string& name,
+ const std::vector<base::CommandLine::StringType>& args) {
+ base::FilePath exe_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe_dir));
+ base::FilePath test_binary =
+ exe_dir.AppendASCII("boringssl_" + name);
+ base::CommandLine cmd(test_binary);
+
+ for (size_t i = 0; i < args.size(); ++i) {
+ cmd.AppendArgNative(args[i]);
+ }
+
+ std::string output;
+ EXPECT_TRUE(base::GetAppOutput(cmd, &output));
+
+ const bool ok = output.size() >= 5 &&
+ memcmp("PASS\n", &output[output.size() - 5], 5) == 0 &&
+ (output.size() == 5 || output[output.size() - 6] == '\n');
+
+ EXPECT_TRUE(ok) << output;
+}
+
+void TestSimple(const std::string& name) {
+ std::vector<base::CommandLine::StringType> empty;
+ TestProcess(name, empty);
+}
+
+bool BoringSSLPath(base::FilePath* result) {
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, result))
+ return false;
+
+ *result = result->Append(FILE_PATH_LITERAL("third_party"));
+ *result = result->Append(FILE_PATH_LITERAL("boringssl"));
+ *result = result->Append(FILE_PATH_LITERAL("src"));
+ return true;
+}
+
+bool CryptoCipherPath(base::FilePath *result) {
+ if (!BoringSSLPath(result))
+ return false;
+
+ *result = result->Append(FILE_PATH_LITERAL("crypto"));
+ *result = result->Append(FILE_PATH_LITERAL("cipher"));
+ return true;
+}
+
+} // anonymous namespace
+
+TEST(BoringSSL, AES128GCM) {
+ base::FilePath data_file;
+ ASSERT_TRUE(CryptoCipherPath(&data_file));
+ data_file = data_file.Append(FILE_PATH_LITERAL("aes_128_gcm_tests.txt"));
+
+ std::vector<base::CommandLine::StringType> args;
+ args.push_back(FILE_PATH_LITERAL("aes-128-gcm"));
+ args.push_back(data_file.value());
+
+ TestProcess("aead_test", args);
+}
+
+TEST(BoringSSL, AES256GCM) {
+ base::FilePath data_file;
+ ASSERT_TRUE(CryptoCipherPath(&data_file));
+ data_file = data_file.Append(FILE_PATH_LITERAL("aes_256_gcm_tests.txt"));
+
+ std::vector<base::CommandLine::StringType> args;
+ args.push_back(FILE_PATH_LITERAL("aes-256-gcm"));
+ args.push_back(data_file.value());
+
+ TestProcess("aead_test", args);
+}
+
+TEST(BoringSSL, ChaCha20Poly1305) {
+ base::FilePath data_file;
+ ASSERT_TRUE(CryptoCipherPath(&data_file));
+ data_file =
+ data_file.Append(FILE_PATH_LITERAL("chacha20_poly1305_tests.txt"));
+
+ std::vector<base::CommandLine::StringType> args;
+ args.push_back(FILE_PATH_LITERAL("chacha20-poly1305"));
+ args.push_back(data_file.value());
+
+ TestProcess("aead_test", args);
+}
+
+TEST(BoringSSL, RC4MD5) {
+ base::FilePath data_file;
+ ASSERT_TRUE(CryptoCipherPath(&data_file));
+ data_file = data_file.Append(FILE_PATH_LITERAL("rc4_md5_tests.txt"));
+
+ std::vector<base::CommandLine::StringType> args;
+ args.push_back(FILE_PATH_LITERAL("rc4-md5"));
+ args.push_back(data_file.value());
+
+ TestProcess("aead_test", args);
+}
+
+TEST(BoringSSL, BIO) {
+ TestSimple("bio_test");
+}
+
+TEST(BoringSSL, BN) {
+ TestSimple("bn_test");
+}
+
+TEST(BoringSSL, ByteString) {
+ TestSimple("bytestring_test");
+}
+
+TEST(BoringSSL, Cipher) {
+ base::FilePath data_file;
+ ASSERT_TRUE(CryptoCipherPath(&data_file));
+ data_file = data_file.Append(FILE_PATH_LITERAL("cipher_test.txt"));
+
+ std::vector<base::CommandLine::StringType> args;
+ args.push_back(data_file.value());
+
+ TestProcess("cipher_test", args);
+}
+
+TEST(BoringSSL, DH) {
+ TestSimple("dh_test");
+}
+
+TEST(BoringSSL, DSA) {
+ TestSimple("dsa_test");
+}
+
+TEST(BoringSSL, ECDSA) {
+ TestSimple("ecdsa_test");
+}
+
+TEST(BoringSSL, ERR) {
+ TestSimple("err_test");
+}
+
+TEST(BoringSSL, GCM) {
+ TestSimple("gcm_test");
+}
+
+TEST(BoringSSL, HMAC) {
+ TestSimple("hmac_test");
+}
+
+TEST(BoringSSL, LH) {
+ TestSimple("lhash_test");
+}
+
+TEST(BoringSSL, MD5) {
+ TestSimple("md5_test");
+}
+
+TEST(BoringSSL, RSA) {
+ TestSimple("rsa_test");
+}
+
+TEST(BoringSSL, SHA1) {
+ TestSimple("sha1_test");
+}
+
+TEST(BoringSSL, ExampleMul) {
+ TestSimple("example_mul");
+}
+
+TEST(BoringSSL, ExampleSign) {
+ TestSimple("example_sign");
+}
« no previous file with comments | « third_party/boringssl/boringssl_tests.gypi ('k') | third_party/boringssl/linux-arm/crypto/aes/aes-armv4.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698