cleanup: remove dead self-test code

BUG=None
TEST=None

Change-Id: I1ba3b319052e48d75f6279f3027308186e794315
Reviewed-on: https://chromium-review.googlesource.com/378376
Commit-Ready: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/server/self-test/alltests_suite.py b/server/self-test/alltests_suite.py
deleted file mode 100755
index 1d9a8b0..0000000
--- a/server/self-test/alltests_suite.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2007 Google Inc. Released under the GPL v2
-
-"""This module provides a means to run all the unittests for autoserv
-"""
-
-__author__ = """stutsman@google.com (Ryan Stutsman)"""
-
-import os, sys
-
-# Adjust the path so Python can find the autoserv modules
-src = os.path.abspath("%s/.." % (os.path.dirname(sys.argv[0]),))
-if src not in sys.path:
-    sys.path.insert(1, src)
-
-import unittest
-
-
-import autotest_test
-import utils_test
-
-
-def suite():
-    return unittest.TestSuite([autotest_test.suite(),
-                               utils_test.suite()])
-
-
-if __name__ == '__main__':
-    unittest.TextTestRunner(verbosity=2).run(suite())
diff --git a/server/self-test/autotest_test.py b/server/self-test/autotest_test.py
deleted file mode 100755
index 6e9df7b..0000000
--- a/server/self-test/autotest_test.py
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2007 Google Inc. Released under the GPL v2
-
-"""This module defines the unittests for the Autotest class
-"""
-
-__author__ = """stutsman@google.com (Ryan Stutsman)"""
-
-import os
-import sys
-import unittest
-
-import common
-
-from autotest_lib.server import utils
-from autotest_lib.server import autotest
-from autotest_lib.server import hosts
-
-
-class AutotestTestCase(unittest.TestCase):
-    def setUp(self):
-        self.autotest = autotest.Autotest()
-
-    def tearDown(self):
-        pass
-
-
-    def testGetAutoDir(self):
-        class MockInstallHost:
-            def __init__(self):
-                self.commands = []
-                self.result = "autodir='/stuff/autotest'\n"
-
-            def run(self, command):
-                if command == "grep autodir= /etc/autotest.conf":
-                    result = hosts.CmdResult()
-                    result.stdout = self.result
-                    return result
-                else:
-                    self.commands.append(command)
-
-        host = MockInstallHost()
-        self.assertEqual('/stuff/autotest',
-                         autotest.Autotest.get_installed_autodir(host))
-        host.result = "autodir=/stuff/autotest\n"
-        self.assertEqual('/stuff/autotest',
-                         autotest.Autotest.get_installed_autodir(host))
-        host.result = 'autodir="/stuff/auto test"\n'
-        self.assertEqual('/stuff/auto test',
-                         autotest.Autotest.get_installed_autodir(host))
-
-
-    def testInstallFromDir(self):
-        class MockInstallHost:
-            def __init__(self):
-                self.commands = []
-
-            def run(self, command):
-                if command == "grep autodir= /etc/autotest.conf":
-                    result= hosts.CmdResult()
-                    result.stdout = "autodir=/usr/local/autotest\n"
-                    return result
-                else:
-                    self.commands.append(command)
-
-            def send_file(self, src, dst):
-                self.commands.append("send_file: %s %s" % (src,
-                                                           dst))
-
-        host = MockInstallHost()
-        tmpdir = utils.get_tmp_dir()
-        self.autotest.get(tmpdir)
-        self.autotest.install(host)
-        self.assertEqual(host.commands[0],
-                         'mkdir -p /usr/local/autotest')
-        self.assertTrue(host.commands[1].startswith('send_file: /tmp/'))
-        self.assertTrue(host.commands[1].endswith(
-                '/ /usr/local/autotest'))
-
-
-
-
-    def testInstallFromSVN(self):
-        class MockInstallHost:
-            def __init__(self):
-                self.commands = []
-
-            def run(self, command):
-                if command == "grep autodir= /etc/autotest.conf":
-                    result= hosts.CmdResult()
-                    result.stdout = "autodir=/usr/local/autotest\n"
-                    return result
-                else:
-                    self.commands.append(command)
-
-        host = MockInstallHost()
-        self.autotest.install(host)
-        self.assertEqual(host.commands,
-                         ['svn checkout '
-                          + autotest.AUTOTEST_SVN + ' '
-                          + "/usr/local/autotest"])
-
-
-    def testFirstInstallFromSVNFails(self):
-        class MockFirstInstallFailsHost:
-            def __init__(self):
-                self.commands = []
-
-            def run(self, command):
-                if command == "grep autodir= /etc/autotest.conf":
-                    result= hosts.CmdResult()
-                    result.stdout = "autodir=/usr/local/autotest\n"
-                    return result
-                else:
-                    self.commands.append(command)
-                    first = ('svn checkout ' +
-                        autotest.AUTOTEST_SVN + ' ' +
-                        "/usr/local/autotest")
-                    if (command == first):
-                        raise autotest.AutoservRunError(
-                                "svn not found")
-
-        host = MockFirstInstallFailsHost()
-        self.autotest.install(host)
-        self.assertEqual(host.commands,
-                         ['svn checkout ' + autotest.AUTOTEST_SVN +
-                          ' ' + "/usr/local/autotest",
-                          'svn checkout ' + autotest.AUTOTEST_HTTP +
-                          ' ' + "/usr/local/autotest"])
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(AutotestTestCase)
-
-if __name__ == '__main__':
-    unittest.TextTestRunner(verbosity=2).run(suite())
diff --git a/server/self-test/common.py b/server/self-test/common.py
deleted file mode 100644
index 41607e1..0000000
--- a/server/self-test/common.py
+++ /dev/null
@@ -1,8 +0,0 @@
-import os, sys
-dirname = os.path.dirname(sys.modules[__name__].__file__)
-autotest_dir = os.path.abspath(os.path.join(dirname, "..", ".."))
-client_dir = os.path.join(autotest_dir, "client")
-sys.path.insert(0, client_dir)
-import setup_modules
-sys.path.pop(0)
-setup_modules.setup(base_path=autotest_dir, root_module_name="autotest_lib")
diff --git a/server/self-test/local_cmd b/server/self-test/local_cmd
deleted file mode 100644
index aff727d..0000000
--- a/server/self-test/local_cmd
+++ /dev/null
@@ -1,43 +0,0 @@
-import time
-import utils 
-
-print "Testing a simple ls command with no timeout"
-result = utils.run('ls -d /etc')
-output = result.stdout.rstrip()
-if output == '/etc':
-	print "Passed"
-else:
-	raise "Failed"
-
-print
-
-print "Testing system_output"
-output = utils.run("ls -d /etc").stdout.strip()
-if output == '/etc':
-	print "Passed"
-else:
-	raise "Failed"
-
-print
-
-print "Testing sleep 2 with timeout of 5"
-start = time.time()
-result = utils.run('sleep 2', timeout=5)
-print "time: %f" % (time.time() - start)
-if result.exit_status == 0:
-	print "Passed"
-else:
-	raise "Failed"
-
-print
-
-print "Testing sleep 10 with timeout of 5"
-start = time.time()
-result = utils.run('sleep 10', timeout=5)
-t = time.time() - start
-print "time: %f" % t
-if t < 10:
-	print "Passed"
-else:
-	raise "Failed"
-
diff --git a/server/self-test/machine b/server/self-test/machine
deleted file mode 100644
index e59d081..0000000
--- a/server/self-test/machine
+++ /dev/null
@@ -1,14 +0,0 @@
-import time
-
-print "Instantiating a machine object"
-m = hosts.create_host(machines[0])
-print "Passed"
-
-print
-
-print "Running is_up on remote machine"
-m.is_up()
-time.sleep(1)
-m.is_up()
-print "Passed"
-
diff --git a/server/self-test/remote_cmd b/server/self-test/remote_cmd
deleted file mode 100644
index 76e6044..0000000
--- a/server/self-test/remote_cmd
+++ /dev/null
@@ -1,45 +0,0 @@
-import utils
-
-print "Instantiating a machine object"
-m = hosts.create_host(machines[0])
-print "Passed"
-
-print
-
-print "Pinging"
-if m.is_up():
-	print "Passed"
-else:
-	raise "Failed"
-
-print
-
-print "Waiting for ssh"
-m.wait_up(5)
-print "Passed"
-
-print
-
-print "Running ls on remote machine via host.run"
-if m.run('ls -d /etc').stdout.strip() == '/etc':
-	print "Passed"
-else:
-	raise "Failed"
-
-utils.run('rm -f /tmp/motd')
-print "Removing temporary file from remote machine"
-m.run('rm -f /tmp/motd')
-print "Running send_file remote machine"
-m.send_file('/etc/motd', '/tmp/motd')
-print "Running get_file remote machine"
-m.get_file('/tmp/motd', '/tmp/motd')
-print "Verifying files match"
-if utils.run('diff -q /etc/motd /tmp/motd').exit_status:
-	raise "Failed"
-print "Removing temporary file from remote machine"
-m.run('rm -f /tmp/motd')
-print "Passed"
-utils.run('rm -f /tmp/motd')
-
-print
-
diff --git a/server/self-test/timed_test.srv b/server/self-test/timed_test.srv
deleted file mode 100644
index 235bae3..0000000
--- a/server/self-test/timed_test.srv
+++ /dev/null
@@ -1,12 +0,0 @@
-def run(machine):
-	host = hosts.create_host(machine)
-        at = autotest.Autotest(host)
-        at.run_timed_test('sleeptest', seconds=1, timeout=15) # no exception
-	try:
-		at.run_timed_test('sleeptest', seconds=30, timeout=5)
-                # should timeout
-		raise 'Test failed to timeout!'
-	except autotest.AutotestTimeoutError:
-		print 'Timeout test success!'
-
-job.parallel_simple(run, machines)
diff --git a/server/self-test/utils_test.py b/server/self-test/utils_test.py
deleted file mode 100755
index e1b2de3..0000000
--- a/server/self-test/utils_test.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2007 Google Inc. Released under the GPL v2
-
-"""This module defines the unittests for the utils
-"""
-
-__author__ = """stutsman@google.com (Ryan Stutsman)"""
-
-import os
-import sys
-import os.path
-import unittest
-
-import common
-
-from autotest_lib.server import utils
-
-
-class UtilsTestCase(unittest.TestCase):
-    def setUp(self):
-        pass
-
-
-    def tearDown(self):
-        pass
-
-
-    def testGetWithOpenFile(self):
-        tmpdir = utils.get_tmp_dir()
-        tmppath = os.path.join(tmpdir, 'testfile')
-        tmpfile = file(tmppath, 'w')
-        print >> tmpfile, 'Test string'
-        tmpfile.close()
-        tmpfile = file(tmppath)
-        newtmppath = utils.get(tmpfile)
-        self.assertEqual(file(newtmppath).read(), 'Test string\n')
-
-
-    def testGetWithHTTP(self):
-        # Yeah, this test is a bad idea, oh well
-        url = 'http://www.kernel.org/pub/linux/kernel/README'
-        tmppath = utils.get(url)
-        f = file(tmppath)
-        f.readline()
-        self.assertTrue('Linux' in f.readline().split())
-
-
-    def testGetWithPath(self):
-        path = utils.get('/proc/cpuinfo')
-        self.assertTrue(file(path).readline().startswith('processor'))
-
-
-    def testGetWithString(self):
-        path = utils.get('/tmp loves rabbits!')
-        self.assertTrue(file(path).readline().startswith('/tmp loves'))
-
-
-    def testGetWithDir(self):
-        tmpdir = utils.get_tmp_dir()
-        origpath = os.path.join(tmpdir, 'testGetWithDir')
-        os.mkdir(origpath)
-        dstpath = utils.get(origpath)
-        self.assertTrue(dstpath.endswith('/'))
-        self.assertTrue(os.path.isdir(dstpath))
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(UtilsTestCase)
-
-if __name__ == '__main__':
-    unittest.TextTestRunner(verbosity=2).run(suite())
diff --git a/utils/coverage_suite.py b/utils/coverage_suite.py
deleted file mode 100755
index 7ca66e9..0000000
--- a/utils/coverage_suite.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/python
-
-import os, sys
-import unittest_suite
-from autotest_lib.client.common_lib import utils
-
-
-root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
-
-
-invalid_dirs = ['client/tests/', 'client/site_tests/', 'tko/migrations/',
-                'server/tests/', 'server/site_tests/', 'server/self-test/',
-                'contrib/', 'utils/', 'ui/', 'frontend/migrations',
-                'frontend/afe/simplejson/', 'metrics/', 'old_cli/',
-                'client/common_lib/test_utils/', 'client/profilers/',
-                'site_packages']
-# append site specific invalid_dirs list, if any
-invalid_dirs.extend(utils.import_site_symbol(
-    __file__, 'autotest_lib.utils.site_coverage_suite', 'invalid_dirs', []))
-
-
-invalid_files = ['unittest_suite.py', 'coverage_suite.py', '__init__.py',
-                 'common.py']
-# append site specific invalid_files list, if any
-invalid_files.extend(utils.import_site_symbol(
-    __file__, 'autotest_lib.utils.site_coverage_suite', 'invalid_files', []))
-
-
-def is_valid_directory(dirpath):
-    dirpath += '/'
-    for invalid_dir in invalid_dirs:
-        if dirpath.startswith(os.path.join(root, invalid_dir)):
-            return False
-
-    return True
-
-
-def is_test_filename(filename):
-    return (filename.endswith('_unittest.py') or filename.endswith('_test.py'))
-
-
-def is_valid_filename(f):
-    # has to be a .py file
-    if not f.endswith('.py'):
-        return False
-
-    # but there are exceptions
-    if is_test_filename(f):
-        return False
-    elif f in invalid_files:
-        return False
-    else:
-        return True
-
-
-def run_unittests(prog, dirname, files):
-    for f in files:
-        if is_test_filename(f):
-            testfile = os.path.abspath(os.path.join(dirname, f))
-            cmd = "%s -x %s" % (prog, testfile)
-            utils.system_output(cmd, ignore_status=True, timeout=100)
-
-
-def main():
-    coverage = os.path.join(root, "contrib/coverage.py")
-
-    # remove preceeding coverage data
-    cmd = "%s -e" % (coverage)
-    os.system(cmd)
-
-    # I know this looks weird but is required for accurate results
-    cmd = "cd %s && find . -name '*.pyc' | xargs rm" % root
-    os.system(cmd)
-
-    # now walk through directory grabbing list of files
-    if len(sys.argv) == 2:
-        start = os.path.join(root, sys.argv[1])
-    else:
-        start = root
-
-    # run unittests through coverage analysis
-    os.path.walk(start, run_unittests, coverage)
-
-    module_strings = []
-    for dirpath, dirnames, files in os.walk(start):
-        if is_valid_directory(dirpath):
-            for f in files:
-                if is_valid_filename(f):
-                    temp = os.path.join(dirpath, f)
-                    module_strings.append(temp)
-
-    # analyze files
-    cmd = "%s -r -m %s" % (coverage, " ".join(module_strings))
-    os.system(cmd)
-
-
-if __name__ == "__main__":
-    main()