diff options
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/tests.py')
-rw-r--r-- | bitbake/lib/toaster/contrib/tts/tests.py | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/tests.py b/bitbake/lib/toaster/contrib/tts/tests.py index 15a9a874ff..eb91947d83 100644 --- a/bitbake/lib/toaster/contrib/tts/tests.py +++ b/bitbake/lib/toaster/contrib/tts/tests.py | |||
@@ -24,7 +24,8 @@ | |||
24 | # as this file. | 24 | # as this file. |
25 | 25 | ||
26 | import unittest | 26 | import unittest |
27 | from shellutils import * | 27 | from shellutils import run_shell_cmd, ShellCmdException |
28 | import config | ||
28 | 29 | ||
29 | import pexpect | 30 | import pexpect |
30 | import sys, os, signal, time | 31 | import sys, os, signal, time |
@@ -33,12 +34,9 @@ class TestPyCompilable(unittest.TestCase): | |||
33 | ''' Verifies that all Python files are syntactically correct ''' | 34 | ''' Verifies that all Python files are syntactically correct ''' |
34 | def test_compile_file(self): | 35 | def test_compile_file(self): |
35 | try: | 36 | try: |
36 | out = run_shell_cmd("find . -name *py -type f -print0 | xargs -0 -n1 -P20 python -m py_compile", config.testdir) | 37 | run_shell_cmd("find . -name *py -type f -print0 | xargs -0 -n1 -P20 python -m py_compile", config.TESTDIR) |
37 | except ShellCmdException as e: | 38 | except ShellCmdException as exc: |
38 | self.fail("Error compiling python files: %s" % (e)) | 39 | self.fail("Error compiling python files: %s" % (exc)) |
39 | except Exception as e: | ||
40 | self.fail("Unknown error: %s" % e) | ||
41 | |||
42 | 40 | ||
43 | class TestPySystemStart(unittest.TestCase): | 41 | class TestPySystemStart(unittest.TestCase): |
44 | ''' Attempts to start Toaster, verify that it is succesfull, and stop it ''' | 42 | ''' Attempts to start Toaster, verify that it is succesfull, and stop it ''' |
@@ -47,29 +45,28 @@ class TestPySystemStart(unittest.TestCase): | |||
47 | 45 | ||
48 | def test_start_interactive_mode(self): | 46 | def test_start_interactive_mode(self): |
49 | try: | 47 | try: |
50 | run_shell_cmd("bash -c 'source %s/oe-init-build-env && source toaster start webport=%d && source toaster stop'" % (config.testdir, config.TOASTER_PORT), config.testdir) | 48 | run_shell_cmd("bash -c 'source %s/oe-init-build-env && source toaster start webport=%d && source toaster stop'" % (config.TESTDIR, config.TOASTER_PORT), config.TESTDIR) |
51 | except ShellCmdException as e: | 49 | except ShellCmdException as exc: |
52 | self.fail("Failed starting interactive mode: %s" % (e)) | 50 | self.fail("Failed starting interactive mode: %s" % (exc)) |
53 | 51 | ||
54 | def test_start_managed_mode(self): | 52 | def test_start_managed_mode(self): |
55 | try: | 53 | try: |
56 | run_shell_cmd("%s/bitbake/bin/toaster webport=%d nobrowser & sleep 10 && curl http://localhost:%d/ && kill -2 %1" % (config.testdir, config.TOASTER_PORT, config.TOASTER_PORT), config.testdir) | 54 | run_shell_cmd("%s/bitbake/bin/toaster webport=%d nobrowser & sleep 10 && curl http://localhost:%d/ && kill -2 %%1" % (config.TESTDIR, config.TOASTER_PORT, config.TOASTER_PORT), config.TESTDIR) |
57 | pass | 55 | except ShellCmdException as exc: |
58 | except ShellCmdException as e: | 56 | self.fail("Failed starting managed mode: %s" % (exc)) |
59 | self.fail("Failed starting managed mode: %s" % (e)) | ||
60 | 57 | ||
61 | class TestHTML5Compliance(unittest.TestCase): | 58 | class TestHTML5Compliance(unittest.TestCase): |
62 | def setUp(self): | 59 | def setUp(self): |
63 | self.origdir = os.getcwd() | 60 | self.origdir = os.getcwd() |
64 | self.crtdir = os.path.dirname(config.testdir) | 61 | self.crtdir = os.path.dirname(config.TESTDIR) |
65 | os.chdir(self.crtdir) | 62 | os.chdir(self.crtdir) |
66 | if not os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")): | 63 | if not os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")): |
67 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py syncdb --noinput" % config.testdir) | 64 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py syncdb --noinput" % config.TESTDIR) |
68 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate orm" % config.testdir) | 65 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate orm" % config.TESTDIR) |
69 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate bldcontrol" % config.testdir) | 66 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate bldcontrol" % config.TESTDIR) |
70 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py loadconf %s/meta-yocto/conf/toasterconf.json" % (config.testdir, config.testdir)) | 67 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py loadconf %s/meta-yocto/conf/toasterconf.json" % (config.TESTDIR, config.TESTDIR)) |
71 | 68 | ||
72 | setup = pexpect.spawn("%s/bitbake/lib/toaster/manage.py checksettings" % config.testdir) | 69 | setup = pexpect.spawn("%s/bitbake/lib/toaster/manage.py checksettings" % config.TESTDIR) |
73 | setup.logfile = sys.stdout | 70 | setup.logfile = sys.stdout |
74 | setup.expect(r".*or type the full path to a different directory: ") | 71 | setup.expect(r".*or type the full path to a different directory: ") |
75 | setup.sendline('') | 72 | setup.sendline('') |
@@ -79,8 +76,8 @@ class TestHTML5Compliance(unittest.TestCase): | |||
79 | setup.expect(r"Enter your option: ") | 76 | setup.expect(r"Enter your option: ") |
80 | setup.sendline('0') | 77 | setup.sendline('0') |
81 | 78 | ||
82 | self.child = pexpect.spawn("%s/bitbake/bin/toaster webport=%d nobrowser" % (config.testdir, config.TOASTER_PORT)) | 79 | self.child = pexpect.spawn("%s/bitbake/bin/toaster webport=%d nobrowser" % (config.TESTDIR, config.TOASTER_PORT)) |
83 | self.child.logfile=sys.stdout | 80 | self.child.logfile = sys.stdout |
84 | self.child.expect("Toaster is now running. You can stop it with Ctrl-C") | 81 | self.child.expect("Toaster is now running. You can stop it with Ctrl-C") |
85 | 82 | ||
86 | def test_html5_compliance(self): | 83 | def test_html5_compliance(self): |
@@ -95,7 +92,7 @@ class TestHTML5Compliance(unittest.TestCase): | |||
95 | failed.append((url, results[url])) | 92 | failed.append((url, results[url])) |
96 | 93 | ||
97 | 94 | ||
98 | self.assertTrue(len(failed)== 0, "Not all URLs validate: \n%s " % "\n".join(map(lambda x: "".join(str(x)),failed))) | 95 | self.assertTrue(len(failed) == 0, "Not all URLs validate: \n%s " % "\n".join(["".join(str(x)) for x in failed])) |
99 | 96 | ||
100 | #(config.TOASTER_BASEURL + url, status, errors, warnings)) | 97 | #(config.TOASTER_BASEURL + url, status, errors, warnings)) |
101 | 98 | ||