diff options
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/tests.py')
-rw-r--r-- | bitbake/lib/toaster/contrib/tts/tests.py | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/tests.py b/bitbake/lib/toaster/contrib/tts/tests.py index 2e630db575..15a9a874ff 100644 --- a/bitbake/lib/toaster/contrib/tts/tests.py +++ b/bitbake/lib/toaster/contrib/tts/tests.py | |||
@@ -26,6 +26,9 @@ | |||
26 | import unittest | 26 | import unittest |
27 | from shellutils import * | 27 | from shellutils import * |
28 | 28 | ||
29 | import pexpect | ||
30 | import sys, os, signal, time | ||
31 | |||
29 | class TestPyCompilable(unittest.TestCase): | 32 | class TestPyCompilable(unittest.TestCase): |
30 | ''' Verifies that all Python files are syntactically correct ''' | 33 | ''' Verifies that all Python files are syntactically correct ''' |
31 | def test_compile_file(self): | 34 | def test_compile_file(self): |
@@ -44,14 +47,62 @@ class TestPySystemStart(unittest.TestCase): | |||
44 | 47 | ||
45 | def test_start_interactive_mode(self): | 48 | def test_start_interactive_mode(self): |
46 | try: | 49 | try: |
47 | run_shell_cmd("bash -c 'source %s/oe-init-build-env && source toaster start webport=56789 && source toaster stop'" % config.testdir, config.testdir) | 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 | except ShellCmdException as e: | 51 | except ShellCmdException as e: |
49 | self.fail("Failed starting interactive mode: %s" % (e)) | 52 | self.fail("Failed starting interactive mode: %s" % (e)) |
50 | 53 | ||
51 | def test_start_managed_mode(self): | 54 | def test_start_managed_mode(self): |
52 | try: | 55 | try: |
53 | run_shell_cmd("./poky/bitbake/bin/toaster webport=56789 & sleep 10 && curl http://localhost:56789/ && kill -2 %1") | 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 | pass | 57 | pass |
55 | except ShellCmdException as e: | 58 | except ShellCmdException as e: |
56 | self.fail("Failed starting managed mode: %s" % (e)) | 59 | self.fail("Failed starting managed mode: %s" % (e)) |
57 | 60 | ||
61 | class TestHTML5Compliance(unittest.TestCase): | ||
62 | def setUp(self): | ||
63 | self.origdir = os.getcwd() | ||
64 | self.crtdir = os.path.dirname(config.testdir) | ||
65 | os.chdir(self.crtdir) | ||
66 | 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) | ||
68 | 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) | ||
70 | run_shell_cmd("%s/bitbake/lib/toaster/manage.py loadconf %s/meta-yocto/conf/toasterconf.json" % (config.testdir, config.testdir)) | ||
71 | |||
72 | setup = pexpect.spawn("%s/bitbake/lib/toaster/manage.py checksettings" % config.testdir) | ||
73 | setup.logfile = sys.stdout | ||
74 | setup.expect(r".*or type the full path to a different directory: ") | ||
75 | setup.sendline('') | ||
76 | setup.sendline('') | ||
77 | setup.expect(r".*or type the full path to a different directory: ") | ||
78 | setup.sendline('') | ||
79 | setup.expect(r"Enter your option: ") | ||
80 | setup.sendline('0') | ||
81 | |||
82 | self.child = pexpect.spawn("%s/bitbake/bin/toaster webport=%d nobrowser" % (config.testdir, config.TOASTER_PORT)) | ||
83 | self.child.logfile=sys.stdout | ||
84 | self.child.expect("Toaster is now running. You can stop it with Ctrl-C") | ||
85 | |||
86 | def test_html5_compliance(self): | ||
87 | import urllist, urlcheck | ||
88 | results = {} | ||
89 | for url in urllist.URLS: | ||
90 | results[url] = urlcheck.validate_html5(config.TOASTER_BASEURL + url) | ||
91 | |||
92 | failed = [] | ||
93 | for url in results: | ||
94 | if results[url][1] != 0: | ||
95 | failed.append((url, results[url])) | ||
96 | |||
97 | |||
98 | self.assertTrue(len(failed)== 0, "Not all URLs validate: \n%s " % "\n".join(map(lambda x: "".join(str(x)),failed))) | ||
99 | |||
100 | #(config.TOASTER_BASEURL + url, status, errors, warnings)) | ||
101 | |||
102 | def tearDown(self): | ||
103 | while self.child.isalive(): | ||
104 | self.child.kill(signal.SIGINT) | ||
105 | time.sleep(1) | ||
106 | os.chdir(self.origdir) | ||
107 | # if os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")): | ||
108 | # os.remove(os.path.join(self.crtdir, "toaster.sqlite")) | ||