Index: lib/cros_build_lib_unittest.py |
diff --git a/lib/cros_build_lib_unittest.py b/lib/cros_build_lib_unittest.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..c25a677b7d4b0404f072cf987efc4863dd8830c4 |
--- /dev/null |
+++ b/lib/cros_build_lib_unittest.py |
@@ -0,0 +1,67 @@ |
+#!/usr/bin/python |
+# |
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Unit tests for ctest.""" |
sosa
2011/02/24 00:23:36
docstring
dgarrett
2011/02/24 01:06:46
Done.
|
+ |
+import unittest |
+ |
+import cros_build_lib |
+ |
+class CrosBuildLibTest(unittest.TestCase): |
+ """Test class for cros_build_lib.""" |
+ |
+ |
+#RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None, |
sosa
2011/02/24 00:23:36
left for reference?
dgarrett
2011/02/24 01:06:46
Yeah, I meant to pull it out though.
Done.
|
+# exit_code=False, redirect_stdout=False, redirect_stderr=False, |
+# cwd=None, input=None, enter_chroot=False, num_retries=0): |
+ |
+ def setUp(self): |
sosa
2011/02/24 00:23:36
Remove
dgarrett
2011/02/24 01:06:46
Done.
|
+ pass |
+ |
+ def testRunCommandSimple(self): |
+ result = cros_build_lib.RunCommand(['ls'], |
+ # Keep the test quiet options |
+ print_cmd=False, |
+ redirect_stdout=True, |
+ redirect_stderr=True, |
+ # Test specific options |
+ exit_code=True) |
+ self.assertTrue(result == 0) |
+ |
+ def testRunCommandError(self): |
+ result = cros_build_lib.RunCommand(['ls', '/nosuchdir'], |
+ # Keep the test quiet options |
+ print_cmd=False, |
+ redirect_stdout=True, |
+ redirect_stderr=True, |
+ # Test specific options |
+ error_ok=True, |
+ exit_code=True) |
+ self.assertTrue(result != 0) |
+ |
+ def testRunCommandErrorRetries(self): |
+ result = cros_build_lib.RunCommand(['ls', '/nosuchdir'], |
+ # Keep the test quiet options |
+ print_cmd=False, |
+ redirect_stdout=True, |
+ redirect_stderr=True, |
+ # Test specific options |
+ num_retries=2, |
+ error_ok=True, |
+ exit_code=True) |
+ self.assertTrue(result != 0) |
sosa
2011/02/24 00:23:36
Should prob add a test with error_ok=False and use
dgarrett
2011/02/24 01:06:46
Yep. Meant to look up the name of that assert test
|
+ |
+ def testRunCommandCaptureOutput(self): |
+ result = cros_build_lib.RunCommand(['echo', '-n', 'Hi'], |
+ # Keep the test quiet options |
+ print_cmd=False, |
+ redirect_stdout=True, |
+ redirect_stderr=True) |
+ self.assertTrue(result == 'Hi') |
+ |
+ |
+if __name__ == '__main__': |
+ unittest.main() |