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

Unified Diff: client/bin/unit_test.py

Issue 1597001: [Test Fixit] Code coverage test example. (Closed)
Patch Set: More cleanup - changed handling of perf dictionary. Created 10 years, 8 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 | « no previous file | client/deps/gtest/README » ('j') | client/site_tests/example_UnitTest/example_UnitTest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/bin/unit_test.py
diff --git a/client/bin/unit_test.py b/client/bin/unit_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..3a4a6182dcfb995c480c9de5c8d22fed9557efe0
--- /dev/null
+++ b/client/bin/unit_test.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2010 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.
+
+import logging, os
+
+from autotest_lib.client.bin import test
+from autotest_lib.client.common_lib import utils
+
+class unit_test(test.test):
+ """
+ Unit test should simply subclass this test which handles everything.
+ """
+ version = 1
+ preserve_srcdir = True
+
+
+ def setup(self):
+ os.chdir(self.srcdir)
+ utils.system('make clean')
+ utils.system('make all')
+
+ self.job.setup_dep(['gtest'])
+
+ def run_once(self):
+ dep ='gtest'
+ dep_dir = os.path.join(self.autodir, 'deps', dep)
+ self.job.install_pkg(dep, 'dep', dep_dir)
+
+ # Run the unit test, gather the results and place the gcda files for
+ # code coverage in the results directory.
+
+ os.chdir(self.srcdir)
+ result = utils.run('LD_LIBRARY_PATH=' + dep_dir +
+ ' GCOV_PREFIX=' + self.resultsdir +
+ ' GCOV_PREFIX_STRIP=9999 ./unit_test > ' +
+ self.resultsdir + '/unit_test_result.txt')
+ logging.debug(result.stderr)
petkov 2010/04/09 21:13:31 Shouldn't you be processing the generated result f
Sean Parent 2010/04/10 02:46:07 If one of the unit tests fails then the command wi
+ logging.info('result: ' + self.resultsdir + '/unit_test_result.txt')
petkov 2010/04/09 21:13:31 Now this is something you could write as a test_ke
Sean Parent 2010/04/10 02:46:07 Since this is client side - I didn't think it woul
+
+ def cleanup(self):
+ # This is a hack - we should only need to copy back the .gcda file but
+ # we don't know how to access the source on the server. So copy
+ # everything back.
+
+ os.chdir(self.srcdir)
+ utils.run('cp * ' + self.resultsdir)
« no previous file with comments | « no previous file | client/deps/gtest/README » ('j') | client/site_tests/example_UnitTest/example_UnitTest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698