All the unittests in here are better implemented
in the base autoserv directory, and others are very
outdated. So let's get rid of it and continue to
focus on unittests.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 server/self-test/alltests_suite.py    |   30 -----------
 server/self-test/autotest_unittest.py |   93 ---------------------------------
 server/self-test/common.py            |    8 ---
 server/self-test/local_cmd            |   43 ---------------
 server/self-test/machine              |   14 -----
 server/self-test/remote_cmd           |   45 ----------------
 server/self-test/timed_test.srv       |   12 -----
 server/self-test/utils_unittest.py    |   72 -------------------------
 8 files changed, 317 deletions(-)
 delete mode 100755 server/self-test/alltests_suite.py
 delete mode 100755 server/self-test/autotest_unittest.py
 delete mode 100644 server/self-test/common.py
 delete mode 100644 server/self-test/local_cmd
 delete mode 100644 server/self-test/machine
 delete mode 100644 server/self-test/remote_cmd
 delete mode 100644 server/self-test/timed_test.srv
 delete mode 100755 server/self-test/utils_unittest.py

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__ = """[email protected] (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_unittest.py 
b/server/self-test/autotest_unittest.py
deleted file mode 100755
index e612a71..0000000
--- a/server/self-test/autotest_unittest.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2007 Google Inc. Released under the GPL v2
-
-"""This module defines the unittests for the Autotest class
-"""
-
-__author__ = """[email protected] (Ryan Stutsman)"""
-
-import os
-import sys
-import unittest
-import logging
-
-import common
-
-from autotest.server import utils
-from autotest.server import autotest_remote
-from autotest.server import hosts
-from autotest.client.shared import global_config
-
-
-_GLOBAL_CONFIG = global_config.global_config
-_TOP_PATH = _GLOBAL_CONFIG.get_config_value('COMMON', 'autotest_top_path')
-
-class AutotestTestCase(unittest.TestCase):
-    def setUp(self):
-        self.autotest = autotest_remote.Autotest()
-
-    def tearDown(self):
-        pass
-
-
-    def testGetAutoDir(self):
-        class MockInstallHost:
-            def __init__(self):
-                self.commands = []
-
-            def run(self, command, ignore_status=False):
-                self.commands.append(command)
-
-            def wait_up(self, timeout):
-                pass
-
-            def get_autodir(self):
-                pass
-
-        host = MockInstallHost()
-        self.assertEqual(_TOP_PATH,
-                         autotest_remote.Autotest.get_installed_autodir(host))
-
-
-    def testInstallFromDir(self):
-        class MockInstallHost:
-            def __init__(self):
-                self.commands = []
-                self.hostname = 'autotest-client.foo.com'
-
-            def run(self, command, ignore_status=False):
-                self.commands.append(command)
-
-            def send_file(self, src, dst, delete_dest=False):
-                self.commands.append("send_file: %s %s" % (src, dst))
-
-            def wait_up(self, timeout):
-                pass
-
-            def get_autodir(self):
-                pass
-
-            def set_autodir(self, autodir):
-                pass
-
-            def setup(self):
-                pass
-
-        host = MockInstallHost()
-        tmpdir = utils.get_tmp_dir()
-        self.autotest.get(tmpdir)
-        self.autotest.install(host)
-        self.assertEqual(host.commands[0],
-                         'test -x %s/bin/autotest' % _TOP_PATH)
-        self.assertEqual(host.commands[1], 'test -w %s' % _TOP_PATH)
-        self.assertEqual(host.commands[2], 'mkdir -p %s' % _TOP_PATH)
-        self.assertTrue(host.commands[4].startswith('send_file: []'))
-        self.assertTrue(host.commands[4].endswith(_TOP_PATH))
-
-
-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 cdf0f6a..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")
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 f8bc7fb..0000000
--- a/server/self-test/timed_test.srv
+++ /dev/null
@@ -1,12 +0,0 @@
-def run(machine):
-       host = hosts.create_host(machine)
-        at = autotest_remote.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_remote.AutotestTimeoutError:
-               print 'Timeout test success!'
-
-job.parallel_simple(run, machines)
diff --git a/server/self-test/utils_unittest.py 
b/server/self-test/utils_unittest.py
deleted file mode 100755
index 4196a6f..0000000
--- a/server/self-test/utils_unittest.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__ = """[email protected] (Ryan Stutsman)"""
-
-import os
-import sys
-import os.path
-import unittest
-
-import common
-
-from autotest.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())
-- 
1.7.10

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to