=== modified file 'lava_dispatcher/config.py'
@@ -80,7 +80,10 @@
self.config_dir = config_dir
def get(self, key, default=_sentinel):
try:
- return self.cp.get("DEFAULT", key)
+ val = self.cp.get("DEFAULT", key)
+ if default is not _sentinel and val == '':
+ val = default
+ return val
except NoOptionError:
if default is not _sentinel:
return default
=== modified file 'lava_dispatcher/tests/test_config.py'
@@ -22,11 +22,29 @@
from lava_dispatcher.config import get_config, get_device_config
from lava_dispatcher.utils import string_to_list
+from lava_dispatcher.client.base import LavaClient
test_config_dir = os.path.join(os.path.dirname(__file__), 'test-config')
print test_config_dir
+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)
+ os.mkdir(os.path.dirname(filename))
+ with open(filename, 'w') as f:
+ for key in data.keys():
+ f.write("%s = %s\n" % (key, data[key]))
+
class TestConfigData(TestCase):
+
+ def setUp(self):
+ os.mkdir(tmp_config_dir)
+
+ def tearDown(self):
+ os.system('rm -rf %s' % tmp_config_dir)
+
def test_beagle01_uboot_cmds(self):
beagle01_config = get_device_config("beaglexm01", test_config_dir)
expected = [
@@ -48,3 +66,8 @@
lava_server_ip = server_config.get("LAVA_SERVER_IP")
self.assertEqual(expected, lava_server_ip)
+ def test_default_value_for_tester_hostname(self):
+ create_config('devices/qemu01.conf', { 'device_type': 'qemu' })
+ config = get_device_config("qemu01", tmp_config_dir)
+ client = LavaClient(None, config)
+ self.assertEqual('linaro', client.tester_hostname)