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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdarg.h>
6
7 #include <string>
8
9 #include "base/base_paths.h"
10 #include "base/command_line.h"
11 #include "base/files/file_path.h"
12 #include "base/logging.h"
13 #include "base/path_service.h"
14 #include "base/process/launch.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace {
18
19 void TestProcess(const std::string& name,
20 const std::vector<base::CommandLine::StringType>& args) {
21 base::FilePath exe_dir;
22 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe_dir));
23 base::FilePath test_binary =
24 exe_dir.AppendASCII("boringssl_" + name);
25 base::CommandLine cmd(test_binary);
26
27 for (size_t i = 0; i < args.size(); ++i) {
28 cmd.AppendArgNative(args[i]);
29 }
30
31 std::string output;
32 EXPECT_TRUE(base::GetAppOutput(cmd, &output));
33
34 const bool ok = output.size() >= 5 &&
35 memcmp("PASS\n", &output[output.size() - 5], 5) == 0 &&
36 (output.size() == 5 || output[output.size() - 6] == '\n');
37
38 EXPECT_TRUE(ok) << output;
39 }
40
41 void TestSimple(const std::string& name) {
42 std::vector<base::CommandLine::StringType> empty;
43 TestProcess(name, empty);
44 }
45
46 bool BoringSSLPath(base::FilePath* result) {
47 if (!PathService::Get(base::DIR_SOURCE_ROOT, result))
48 return false;
49
50 *result = result->Append(FILE_PATH_LITERAL("third_party"));
51 *result = result->Append(FILE_PATH_LITERAL("boringssl"));
52 *result = result->Append(FILE_PATH_LITERAL("src"));
53 return true;
54 }
55
56 bool CryptoCipherPath(base::FilePath *result) {
57 if (!BoringSSLPath(result))
58 return false;
59
60 *result = result->Append(FILE_PATH_LITERAL("crypto"));
61 *result = result->Append(FILE_PATH_LITERAL("cipher"));
62 return true;
63 }
64
65 } // anonymous namespace
66
67 TEST(BoringSSL, AES128GCM) {
68 base::FilePath data_file;
69 ASSERT_TRUE(CryptoCipherPath(&data_file));
70 data_file = data_file.Append(FILE_PATH_LITERAL("aes_128_gcm_tests.txt"));
71
72 std::vector<base::CommandLine::StringType> args;
73 args.push_back(FILE_PATH_LITERAL("aes-128-gcm"));
74 args.push_back(data_file.value());
75
76 TestProcess("aead_test", args);
77 }
78
79 TEST(BoringSSL, AES256GCM) {
80 base::FilePath data_file;
81 ASSERT_TRUE(CryptoCipherPath(&data_file));
82 data_file = data_file.Append(FILE_PATH_LITERAL("aes_256_gcm_tests.txt"));
83
84 std::vector<base::CommandLine::StringType> args;
85 args.push_back(FILE_PATH_LITERAL("aes-256-gcm"));
86 args.push_back(data_file.value());
87
88 TestProcess("aead_test", args);
89 }
90
91 TEST(BoringSSL, ChaCha20Poly1305) {
92 base::FilePath data_file;
93 ASSERT_TRUE(CryptoCipherPath(&data_file));
94 data_file =
95 data_file.Append(FILE_PATH_LITERAL("chacha20_poly1305_tests.txt"));
96
97 std::vector<base::CommandLine::StringType> args;
98 args.push_back(FILE_PATH_LITERAL("chacha20-poly1305"));
99 args.push_back(data_file.value());
100
101 TestProcess("aead_test", args);
102 }
103
104 TEST(BoringSSL, RC4MD5) {
105 base::FilePath data_file;
106 ASSERT_TRUE(CryptoCipherPath(&data_file));
107 data_file = data_file.Append(FILE_PATH_LITERAL("rc4_md5_tests.txt"));
108
109 std::vector<base::CommandLine::StringType> args;
110 args.push_back(FILE_PATH_LITERAL("rc4-md5"));
111 args.push_back(data_file.value());
112
113 TestProcess("aead_test", args);
114 }
115
116 TEST(BoringSSL, BIO) {
117 TestSimple("bio_test");
118 }
119
120 TEST(BoringSSL, BN) {
121 TestSimple("bn_test");
122 }
123
124 TEST(BoringSSL, ByteString) {
125 TestSimple("bytestring_test");
126 }
127
128 TEST(BoringSSL, Cipher) {
129 base::FilePath data_file;
130 ASSERT_TRUE(CryptoCipherPath(&data_file));
131 data_file = data_file.Append(FILE_PATH_LITERAL("cipher_test.txt"));
132
133 std::vector<base::CommandLine::StringType> args;
134 args.push_back(data_file.value());
135
136 TestProcess("cipher_test", args);
137 }
138
139 TEST(BoringSSL, DH) {
140 TestSimple("dh_test");
141 }
142
143 TEST(BoringSSL, DSA) {
144 TestSimple("dsa_test");
145 }
146
147 TEST(BoringSSL, ECDSA) {
148 TestSimple("ecdsa_test");
149 }
150
151 TEST(BoringSSL, ERR) {
152 TestSimple("err_test");
153 }
154
155 TEST(BoringSSL, GCM) {
156 TestSimple("gcm_test");
157 }
158
159 TEST(BoringSSL, HMAC) {
160 TestSimple("hmac_test");
161 }
162
163 TEST(BoringSSL, LH) {
164 TestSimple("lhash_test");
165 }
166
167 TEST(BoringSSL, MD5) {
168 TestSimple("md5_test");
169 }
170
171 TEST(BoringSSL, RSA) {
172 TestSimple("rsa_test");
173 }
174
175 TEST(BoringSSL, SHA1) {
176 TestSimple("sha1_test");
177 }
178
179 TEST(BoringSSL, ExampleMul) {
180 TestSimple("example_mul");
181 }
182
183 TEST(BoringSSL, ExampleSign) {
184 TestSimple("example_sign");
185 }
OLDNEW
« 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