summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
authorlzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 18:07:38 +0000
committerlzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 18:07:38 +0000
commit874efe04847a9bd965f4d51e4ca16ae1c63bfb98 (patch)
tree453d261b1339f1279190ea6ca35a6b83fae1a547 /net/test
parent303a11ca6b91aa50b08d257c81f6f195ff9ba98c (diff)
downloadchromium_src-874efe04847a9bd965f4d51e4ca16ae1c63bfb98.zip
chromium_src-874efe04847a9bd965f4d51e4ca16ae1c63bfb98.tar.gz
chromium_src-874efe04847a9bd965f4d51e4ca16ae1c63bfb98.tar.bz2
Use python run time to launch python and make sure it works.
TEST=this BUG=none Review URL: http://codereview.chromium.org/3441030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r--net/test/python_utils_unittest.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/net/test/python_utils_unittest.cc b/net/test/python_utils_unittest.cc
index f0060fe..d0e568d 100644
--- a/net/test/python_utils_unittest.cc
+++ b/net/test/python_utils_unittest.cc
@@ -2,9 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
+#include "base/command_line.h"
#include "base/environment.h"
#include "base/file_path.h"
+#include "base/process_util.h"
#include "base/scoped_ptr.h"
+#include "base/stringprintf.h"
+#include "base/string_util.h"
#include "net/test/python_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -41,11 +47,16 @@ TEST(PythonUtils, Append) {
TEST(PythonUtils, PythonRunTime) {
FilePath dir;
EXPECT_TRUE(GetPythonRunTime(&dir));
-#if defined(OS_WIN)
- EXPECT_NE(std::wstring::npos,
- dir.value().find(L"\\third_party\\python_24\\python.exe"));
-#elif defined(OS_POSIX)
- EXPECT_NE(std::string::npos, dir.value().find("python"));
-#endif
-}
+ // Run a python command to print a string and make sure the output is what
+ // we want.
+ CommandLine cmd_line(dir);
+ cmd_line.AppendArg("-c");
+ std::string input("PythonUtilsTest");
+ std::string python_cmd = StringPrintf("print '%s';", input.c_str());
+ cmd_line.AppendArg(python_cmd);
+ std::string output;
+ EXPECT_TRUE(base::GetAppOutput(cmd_line, &output));
+ TrimWhitespace(output, TRIM_TRAILING, &output);
+ EXPECT_EQ(input, output);
+}