Merge lp:~terceiro/lava-dispatcher/fix-unit-tests into lp:lava-dispatcher

Proposed by Antonio Terceiro
Status: Merged
Merged at revision: 644
Proposed branch: lp:~terceiro/lava-dispatcher/fix-unit-tests
Merge into: lp:lava-dispatcher
Diff against target: 185 lines (+33/-58)
6 files modified
lava_dispatcher/tests/helper.py (+12/-7)
lava_dispatcher/tests/test-config/bin/fake-qemu (+3/-0)
lava_dispatcher/tests/test-config/devices/beaglexm01.conf (+0/-1)
lava_dispatcher/tests/test-config/lava-dispatcher.conf (+0/-1)
lava_dispatcher/tests/test_config.py (+5/-27)
lava_dispatcher/tests/test_device_version.py (+13/-22)
To merge this branch: bzr merge lp:~terceiro/lava-dispatcher/fix-unit-tests
Reviewer Review Type Date Requested Status
Milo Casagrande (community) Approve
Review via email: mp+178186@code.launchpad.net

Description of the change

this branch removes 2 unit tests that are definitively broken beyond repair and leaves the remaining 4 (!!) passing (even though still kind of horrible). Let's assume this the initial spark of the revolution :-)

To post a comment you must log in.
Revision history for this message
Milo Casagrande (milo) wrote :

Antonio, I just tried to run the tests, but I get this error:

Exception: no config files named 'devices/qemu01.conf' found

This is the test that fails:

ERROR: lava_dispatcher.tests.test_device_version.TestDeviceVersion.test_qemu

review: Needs Fixing
645. By Antonio Terceiro

reworking unit test crap

Revision history for this message
Antonio Terceiro (terceiro) wrote :

Just pushed a fix for this. Another bad test went out of the window.

Revision history for this message
Milo Casagrande (milo) wrote :

I had another error:

OSError: [Errno 2] No such file or directory

But I was missing the qemu-system-arm package. Full traceback if you want is here: https://pastebin.linaro.org/view/7072231c

I looked through the README or other files, but couldn't find anything about the lava-dispatcher dependencies other than the one listed in the setup.py file. Might be good to add something in the README (not sure if you want to do it with this MP, in case add when merging). Not sure if this will be a problem if we want to set up a CI job for it.

Overall it looks good to be merged.

review: Approve
Revision history for this message
Antonio Terceiro (terceiro) wrote :

On Thu, Aug 08, 2013 at 06:45:58AM -0000, Milo Casagrande wrote:
> Review: Approve
>
> I had another error:
>
> OSError: [Errno 2] No such file or directory
>
> But I was missing the qemu-system-arm package. Full traceback if you want is here: https://pastebin.linaro.org/view/7072231c
>
> I looked through the README or other files, but couldn't find anything
> about the lava-dispatcher dependencies other than the one listed in
> the setup.py file. Might be good to add something in the README (not
> sure if you want to do it with this MP, in case add when merging). Not
> sure if this will be a problem if we want to set up a CI job for it.

it is a problem, because the test will fail whenever qemu (which is an
optional dependency only required if you actually want to use qemu
devices) is not installed. I will stub that out for the test.

Thanks for your feedback again :-)

646. By Antonio Terceiro

Fake QEMU binary to not require actual QEMU for unit tests

647. By Antonio Terceiro

cleanup: removing unused files - tests are mostly self-contained now

Revision history for this message
Antonio Terceiro (terceiro) wrote :

So I have just pushed an update, and tested against a clean chroot.

Amazing how much work was needed to make 3 unit tests pass. :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava_dispatcher/tests/helper.py'
--- lava_dispatcher/tests/helper.py 2013-07-16 16:09:42 +0000
+++ lava_dispatcher/tests/helper.py 2013-08-08 09:19:50 +0000
@@ -19,13 +19,14 @@
1919
20import os20import os
21from lava_dispatcher.config import get_device_config21from lava_dispatcher.config import get_device_config
22import lava_dispatcher.config
2223
23__tmp_dir = os.getenv("TMPDIR") or '/tmp'24tmp_dir = os.getenv("TMPDIR") or '/tmp'
24__tmp_config_dir = os.path.join(__tmp_dir, 'lava-dispatcher-config')25tmp_config_dir = os.path.join(tmp_dir, 'lava-dispatcher-config')
2526
2627
27def create_config(name, data):28def create_config(name, data):
28 filename = os.path.join(__tmp_config_dir, name)29 filename = os.path.join(tmp_config_dir, name)
29 if not os.path.exists(os.path.dirname(filename)):30 if not os.path.exists(os.path.dirname(filename)):
30 os.mkdir(os.path.dirname(filename))31 os.mkdir(os.path.dirname(filename))
31 with open(filename, 'w') as f:32 with open(filename, 'w') as f:
@@ -35,23 +36,27 @@
3536
36def create_device_config(name, data):37def create_device_config(name, data):
37 create_config("devices/%s.conf" % name, data)38 create_config("devices/%s.conf" % name, data)
38 return get_device_config(name, __tmp_config_dir)39 lava_dispatcher.utils.custom_config_path = tmp_config_dir
40 config = get_device_config(name)
41 lava_dispatcher.utils.custom_config_path = None
42 return config
3943
4044
41def setup_config_dir():45def setup_config_dir():
42 os.mkdir(__tmp_config_dir)46 os.mkdir(tmp_config_dir)
4347
4448
45def cleanup_config_dir():49def cleanup_config_dir():
46 os.system('rm -rf %s' % __tmp_config_dir)50 os.system('rm -rf %s' % tmp_config_dir)
4751
48from unittest import TestCase52from unittest import TestCase
4953
50
51class LavaDispatcherTestCase(TestCase):54class LavaDispatcherTestCase(TestCase):
5255
53 def setUp(self):56 def setUp(self):
54 setup_config_dir()57 setup_config_dir()
58 lava_dispatcher.config.custom_config_path = tmp_config_dir
5559
56 def tearDown(self):60 def tearDown(self):
61 lava_dispatcher.config.custom_config_path = None
57 cleanup_config_dir()62 cleanup_config_dir()
5863
=== added directory 'lava_dispatcher/tests/test-config/bin'
=== added file 'lava_dispatcher/tests/test-config/bin/fake-qemu'
--- lava_dispatcher/tests/test-config/bin/fake-qemu 1970-01-01 00:00:00 +0000
+++ lava_dispatcher/tests/test-config/bin/fake-qemu 2013-08-08 09:19:50 +0000
@@ -0,0 +1,3 @@
1#!/bin/sh
2
3echo 'QEMU emulator version 1.5.0 (Debian 1.5.0+dfsg-4), Copyright (c) 2003-2008 Fabrice Bellard'
04
=== removed directory 'lava_dispatcher/tests/test-config/devices'
=== removed file 'lava_dispatcher/tests/test-config/devices/beaglexm01.conf'
--- lava_dispatcher/tests/test-config/devices/beaglexm01.conf 2011-11-28 20:27:03 +0000
+++ lava_dispatcher/tests/test-config/devices/beaglexm01.conf 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1device_type = beagle-xm
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'lava_dispatcher/tests/test-config/lava-dispatcher.conf'
--- lava_dispatcher/tests/test-config/lava-dispatcher.conf 2011-11-28 20:27:03 +0000
+++ lava_dispatcher/tests/test-config/lava-dispatcher.conf 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1LAVA_SERVER_IP = 192.168.200.200
2\ No newline at end of file0\ No newline at end of file
31
=== modified file 'lava_dispatcher/tests/test_config.py'
--- lava_dispatcher/tests/test_config.py 2013-07-16 16:09:24 +0000
+++ lava_dispatcher/tests/test_config.py 2013-08-08 09:19:50 +0000
@@ -19,39 +19,17 @@
1919
20from unittest import TestCase20from unittest import TestCase
2121
22import lava_dispatcher.config
22from lava_dispatcher.config import get_config, get_device_config23from lava_dispatcher.config import get_config, get_device_config
23from lava_dispatcher.utils import string_to_list24from lava_dispatcher.utils import string_to_list
2425
25from lava_dispatcher.tests.helper import *26from lava_dispatcher.tests.helper import *
2627
27test_config_dir = os.path.join(os.path.dirname(__file__), 'test-config')28class TestConfigData(LavaDispatcherTestCase):
28
29
30class TestConfigData(TestCase):
31
32 def setUp(self):
33 setup_config_dir()
34
35 def tearDown(self):
36 cleanup_config_dir()
37
38 def test_beagle01_uboot_cmds(self):
39 beagle01_config = get_device_config("beaglexm01", test_config_dir)
40 expected = [
41 "mmc init",
42 "mmc part 0",
43 "setenv bootcmd 'fatload mmc 0:3 0x80000000 uImage; fatload mmc "
44 "0:3 0x81600000 uInitrd; bootm 0x80000000 0x81600000'",
45 "setenv bootargs ' console=tty0 console=ttyO2,115200n8 "
46 "root=LABEL=testrootfs rootwait ro earlyprintk fixrtc "
47 "nocompcache vram=12M omapfb.debug=y "
48 "omapfb.mode=dvi:1280x720MR-16@60'",
49 "boot"]
50 uboot_cmds = beagle01_config.boot_cmds
51 self.assertEquals(expected, string_to_list(uboot_cmds))
5229
53 def test_server_ip(self):30 def test_server_ip(self):
54 server_config = get_config(test_config_dir)31 create_config('lava-dispatcher.conf', { 'LAVA_SERVER_IP': '99.99.99.99' })
55 expected = "192.168.200.200"32 server_config = get_config()
33 expected = "99.99.99.99"
56 lava_server_ip = server_config.lava_server_ip34 lava_server_ip = server_config.lava_server_ip
57 self.assertEqual(expected, lava_server_ip)35 self.assertEqual(expected, lava_server_ip)
5836
=== modified file 'lava_dispatcher/tests/test_device_version.py'
--- lava_dispatcher/tests/test_device_version.py 2013-07-16 16:09:15 +0000
+++ lava_dispatcher/tests/test_device_version.py 2013-08-08 09:19:50 +0000
@@ -18,7 +18,9 @@
18# along with this program; if not, see <http://www.gnu.org/licenses>.18# along with this program; if not, see <http://www.gnu.org/licenses>.
1919
20import re20import re
21from lava_dispatcher.tests.helper import LavaDispatcherTestCase, create_device_config, create_config, __tmp_config_dir21import lava_dispatcher.config
22from lava_dispatcher.tests.helper import LavaDispatcherTestCase, create_device_config, create_config
23import os
2224
23from lava_dispatcher.device.target import Target25from lava_dispatcher.device.target import Target
24from lava_dispatcher.device.qemu import QEMUTarget26from lava_dispatcher.device.qemu import QEMUTarget
@@ -34,10 +36,14 @@
34 return target36 return target
3537
3638
37def _create_qemu_target():39def _create_qemu_target(extra_device_config={}):
38 create_config('lava-dispatcher.conf', {'default_qemu_binary': 'qemu-system-arm'})40 create_config('lava-dispatcher.conf', {})
39 device_config = create_device_config('qemu01', {'device_type': 'qemu'})41
40 dispatcher_config = get_config(__tmp_config_dir)42 device_config_data = {'device_type': 'qemu'}
43 device_config_data.update(extra_device_config)
44 device_config = create_device_config('qemu01', device_config_data)
45
46 dispatcher_config = get_config()
4147
42 context = LavaContext('qemu01', dispatcher_config, None, None, None)48 context = LavaContext('qemu01', dispatcher_config, None, None, None)
43 return QEMUTarget(context, device_config)49 return QEMUTarget(context, device_config)
@@ -50,22 +56,7 @@
50 self.assertIsInstance(target.get_device_version(), str)56 self.assertIsInstance(target.get_device_version(), str)
5157
52 def test_qemu(self):58 def test_qemu(self):
53 target = _create_qemu_target()59 fake_qemu = os.path.join(os.path.dirname(__file__), 'test-config', 'bin', 'fake-qemu')
60 target = _create_qemu_target({ 'qemu_binary': fake_qemu })
54 device_version = target.get_device_version()61 device_version = target.get_device_version()
55 assert(re.search('^[0-9.]+', device_version))62 assert(re.search('^[0-9.]+', device_version))
56
57 def test_fastmodel(self):
58 banner = "\n".join([
59 "Fast Models [7.1.36 (May 17 2012)]",
60 "Copyright 2000-2012 ARM Limited.",
61 "All Rights Reserved.",
62 "Top component name: RTSM_VE_Cortex_A15x1_A7x1"
63 ])
64 target = _create_fastmodel_target()
65 version = target._parse_fastmodel_version(banner)
66 self.assertEqual('7.1.36', version)
67
68 def test_fastmodel_wrong_format(self):
69 client = _create_fastmodel_target()
70 version = client._parse_fastmodel_version('random string')
71 self.assertEqual('unknown', version)

Subscribers

People subscribed via source and target branches