=== modified file 'lava_dispatcher/tests/helper.py'
@@ -19,13 +19,14 @@
import os
from lava_dispatcher.config import get_device_config
+import lava_dispatcher.config
-__tmp_dir = os.getenv("TMPDIR") or '/tmp'
-__tmp_config_dir = os.path.join(__tmp_dir, 'lava-dispatcher-config')
+tmp_dir = os.getenv("TMPDIR") or '/tmp'
+tmp_config_dir = os.path.join(tmp_dir, 'lava-dispatcher-config')
def create_config(name, data):
- filename = os.path.join(__tmp_config_dir, name)
+ filename = os.path.join(tmp_config_dir, name)
if not os.path.exists(os.path.dirname(filename)):
os.mkdir(os.path.dirname(filename))
with open(filename, 'w') as f:
@@ -35,23 +36,27 @@
def create_device_config(name, data):
create_config("devices/%s.conf" % name, data)
- return get_device_config(name, __tmp_config_dir)
+ lava_dispatcher.utils.custom_config_path = tmp_config_dir
+ config = get_device_config(name)
+ lava_dispatcher.utils.custom_config_path = None
+ return config
def setup_config_dir():
- os.mkdir(__tmp_config_dir)
+ os.mkdir(tmp_config_dir)
def cleanup_config_dir():
- os.system('rm -rf %s' % __tmp_config_dir)
+ os.system('rm -rf %s' % tmp_config_dir)
from unittest import TestCase
-
class LavaDispatcherTestCase(TestCase):
def setUp(self):
setup_config_dir()
+ lava_dispatcher.config.custom_config_path = tmp_config_dir
def tearDown(self):
+ lava_dispatcher.config.custom_config_path = None
cleanup_config_dir()
=== added directory 'lava_dispatcher/tests/test-config/bin'
=== added file 'lava_dispatcher/tests/test-config/bin/fake-qemu'
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo 'QEMU emulator version 1.5.0 (Debian 1.5.0+dfsg-4), Copyright (c) 2003-2008 Fabrice Bellard'
=== removed directory 'lava_dispatcher/tests/test-config/devices'
=== removed file 'lava_dispatcher/tests/test-config/devices/beaglexm01.conf'
@@ -1,1 +0,0 @@
-device_type = beagle-xm
\ No newline at end of file
=== removed file 'lava_dispatcher/tests/test-config/lava-dispatcher.conf'
@@ -1,1 +0,0 @@
-LAVA_SERVER_IP = 192.168.200.200
\ No newline at end of file
=== modified file 'lava_dispatcher/tests/test_config.py'
@@ -19,39 +19,17 @@
from unittest import TestCase
+import lava_dispatcher.config
from lava_dispatcher.config import get_config, get_device_config
from lava_dispatcher.utils import string_to_list
from lava_dispatcher.tests.helper import *
-test_config_dir = os.path.join(os.path.dirname(__file__), 'test-config')
-
-
-class TestConfigData(TestCase):
-
- def setUp(self):
- setup_config_dir()
-
- def tearDown(self):
- cleanup_config_dir()
-
- def test_beagle01_uboot_cmds(self):
- beagle01_config = get_device_config("beaglexm01", test_config_dir)
- expected = [
- "mmc init",
- "mmc part 0",
- "setenv bootcmd 'fatload mmc 0:3 0x80000000 uImage; fatload mmc "
- "0:3 0x81600000 uInitrd; bootm 0x80000000 0x81600000'",
- "setenv bootargs ' console=tty0 console=ttyO2,115200n8 "
- "root=LABEL=testrootfs rootwait ro earlyprintk fixrtc "
- "nocompcache vram=12M omapfb.debug=y "
- "omapfb.mode=dvi:1280x720MR-16@60'",
- "boot"]
- uboot_cmds = beagle01_config.boot_cmds
- self.assertEquals(expected, string_to_list(uboot_cmds))
+class TestConfigData(LavaDispatcherTestCase):
def test_server_ip(self):
- server_config = get_config(test_config_dir)
- expected = "192.168.200.200"
+ create_config('lava-dispatcher.conf', { 'LAVA_SERVER_IP': '99.99.99.99' })
+ server_config = get_config()
+ expected = "99.99.99.99"
lava_server_ip = server_config.lava_server_ip
self.assertEqual(expected, lava_server_ip)
=== modified file 'lava_dispatcher/tests/test_device_version.py'
@@ -18,7 +18,9 @@
# along with this program; if not, see <http://www.gnu.org/licenses>.
import re
-from lava_dispatcher.tests.helper import LavaDispatcherTestCase, create_device_config, create_config, __tmp_config_dir
+import lava_dispatcher.config
+from lava_dispatcher.tests.helper import LavaDispatcherTestCase, create_device_config, create_config
+import os
from lava_dispatcher.device.target import Target
from lava_dispatcher.device.qemu import QEMUTarget
@@ -34,10 +36,14 @@
return target
-def _create_qemu_target():
- create_config('lava-dispatcher.conf', {'default_qemu_binary': 'qemu-system-arm'})
- device_config = create_device_config('qemu01', {'device_type': 'qemu'})
- dispatcher_config = get_config(__tmp_config_dir)
+def _create_qemu_target(extra_device_config={}):
+ create_config('lava-dispatcher.conf', {})
+
+ device_config_data = {'device_type': 'qemu'}
+ device_config_data.update(extra_device_config)
+ device_config = create_device_config('qemu01', device_config_data)
+
+ dispatcher_config = get_config()
context = LavaContext('qemu01', dispatcher_config, None, None, None)
return QEMUTarget(context, device_config)
@@ -50,22 +56,7 @@
self.assertIsInstance(target.get_device_version(), str)
def test_qemu(self):
- target = _create_qemu_target()
+ fake_qemu = os.path.join(os.path.dirname(__file__), 'test-config', 'bin', 'fake-qemu')
+ target = _create_qemu_target({ 'qemu_binary': fake_qemu })
device_version = target.get_device_version()
assert(re.search('^[0-9.]+', device_version))
-
- def test_fastmodel(self):
- banner = "\n".join([
- "Fast Models [7.1.36 (May 17 2012)]",
- "Copyright 2000-2012 ARM Limited.",
- "All Rights Reserved.",
- "Top component name: RTSM_VE_Cortex_A15x1_A7x1"
- ])
- target = _create_fastmodel_target()
- version = target._parse_fastmodel_version(banner)
- self.assertEqual('7.1.36', version)
-
- def test_fastmodel_wrong_format(self):
- client = _create_fastmodel_target()
- version = client._parse_fastmodel_version('random string')
- self.assertEqual('unknown', version)