OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdarg.h> | 5 #include <stdarg.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
| 15 #include "base/strings/string_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 void TestProcess(const std::string& name, | 20 void TestProcess(const std::string& name, |
20 const std::vector<base::CommandLine::StringType>& args) { | 21 const std::vector<base::CommandLine::StringType>& args) { |
21 base::FilePath exe_dir; | 22 base::FilePath exe_dir; |
22 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe_dir)); | 23 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe_dir)); |
23 base::FilePath test_binary = | 24 base::FilePath test_binary = |
24 exe_dir.AppendASCII("boringssl_" + name); | 25 exe_dir.AppendASCII("boringssl_" + name); |
25 base::CommandLine cmd(test_binary); | 26 base::CommandLine cmd(test_binary); |
26 | 27 |
27 for (size_t i = 0; i < args.size(); ++i) { | 28 for (size_t i = 0; i < args.size(); ++i) { |
28 cmd.AppendArgNative(args[i]); | 29 cmd.AppendArgNative(args[i]); |
29 } | 30 } |
30 | 31 |
31 std::string output; | 32 std::string output; |
32 EXPECT_TRUE(base::GetAppOutput(cmd, &output)); | 33 EXPECT_TRUE(base::GetAppOutput(cmd, &output)); |
| 34 // Account for Windows line endings. |
| 35 ReplaceSubstringsAfterOffset(&output, 0, "\r\n", "\n"); |
33 | 36 |
34 const bool ok = output.size() >= 5 && | 37 const bool ok = output.size() >= 5 && |
35 memcmp("PASS\n", &output[output.size() - 5], 5) == 0 && | 38 memcmp("PASS\n", &output[output.size() - 5], 5) == 0 && |
36 (output.size() == 5 || output[output.size() - 6] == '\n'); | 39 (output.size() == 5 || output[output.size() - 6] == '\n'); |
37 | 40 |
38 EXPECT_TRUE(ok) << output; | 41 EXPECT_TRUE(ok) << output; |
39 } | 42 } |
40 | 43 |
41 void TestSimple(const std::string& name) { | 44 void TestSimple(const std::string& name) { |
42 std::vector<base::CommandLine::StringType> empty; | 45 std::vector<base::CommandLine::StringType> empty; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 TestSimple("example_sign"); | 223 TestSimple("example_sign"); |
221 } | 224 } |
222 | 225 |
223 TEST(BoringSSL, SSL) { | 226 TEST(BoringSSL, SSL) { |
224 TestSimple("ssl_test"); | 227 TestSimple("ssl_test"); |
225 } | 228 } |
226 | 229 |
227 TEST(BoringSSL, PQueue) { | 230 TEST(BoringSSL, PQueue) { |
228 TestSimple("pqueue_test"); | 231 TestSimple("pqueue_test"); |
229 } | 232 } |
OLD | NEW |