Commit ccd86787 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b7a3f5d5
...@@ -30,20 +30,6 @@ setUpModule, AmariTestCase = makeModuleSetUpAndTestCaseClass( ...@@ -30,20 +30,6 @@ setUpModule, AmariTestCase = makeModuleSetUpAndTestCaseClass(
os.path.join(os.path.dirname(__file__), '..', 'software.cfg'))) os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))
# yload loads yaml config file after preprocessing it.
#
# preprocessing is needed to e.g. remove // and /* comments.
def yload(path):
with open(path, 'r') as f:
data = f.read() # original input
p = pcpp.Preprocessor()
p.parse(data)
f = io.StringIO()
p.write(f)
data_ = f.getvalue() # preprocessed input
return yaml.load(data_, Loader=yaml.Loader)
# ---- building blocks to construct cells + peers ---- # ---- building blocks to construct cells + peers ----
# #
# - TDD/FDD are basic parameters to indicate TDD/FDD mode. # - TDD/FDD are basic parameters to indicate TDD/FDD mode.
...@@ -129,13 +115,6 @@ PEERCELL5 = NR(520000,38) | NR_PEER(0x77712,22, 75, 0x321) ...@@ -129,13 +115,6 @@ PEERCELL5 = NR(520000,38) | NR_PEER(0x77712,22, 75, 0x321)
# XXX explain ENB does not support mixing SDR + CPRI # XXX explain ENB does not support mixing SDR + CPRI
# # XXX explain CELL_xy ... XXX goes away
# CELL_4t = TDD | LTE(38050) | BW( 5) # 2600 MHz
# CELL_5t = TDD | NR(523020,41) | BW(10) # 2615.1 MHz
# CELL_4f = FDD | LTE(3350) | BW( 5) # 2680 MHz
# CELL_5f = FDD | NR(537200,7) | BW( 5) # 2686 MHz
# XXX doc # XXX doc
class ENBTestCase(AmariTestCase): class ENBTestCase(AmariTestCase):
maxDiff = None # want to see full diff in test run log on an error maxDiff = None # want to see full diff in test run log on an error
...@@ -199,7 +178,7 @@ class ENBTestCase(AmariTestCase): ...@@ -199,7 +178,7 @@ class ENBTestCase(AmariTestCase):
return '%s/%s' % (self.computer_partition_root_path, path) return '%s/%s' % (self.computer_partition_root_path, path)
def test_enb_conf(self): def test_enb_conf(self):
conf = yload(self.ipath('etc/enb.cfg')) conf = yamlpp_load(self.ipath('etc/enb.cfg'))
# XXX assert about enb_id/gnb_id, PEER, PEERCELL + HO(inter) ... # XXX assert about enb_id/gnb_id, PEER, PEERCELL + HO(inter) ...
...@@ -248,7 +227,7 @@ class TestENB_SDR(ENBTestCase): ...@@ -248,7 +227,7 @@ class TestENB_SDR(ENBTestCase):
def test_enb_conf(self): def test_enb_conf(self):
super().test_enb_conf() super().test_enb_conf()
conf = yload(self.ipath('etc/enb.cfg')) conf = yamlpp_load(self.ipath('etc/enb.cfg'))
rf_driver = conf['rf_driver'] rf_driver = conf['rf_driver']
self.assertEqual(rf_driver['args'], self.assertEqual(rf_driver['args'],
...@@ -419,7 +398,7 @@ class _TestENB_CPRI(ENBTestCase): ...@@ -419,7 +398,7 @@ class _TestENB_CPRI(ENBTestCase):
def test_enb_conf(self): def test_enb_conf(self):
super().test_enb_conf() super().test_enb_conf()
conf = yload('%s/etc/enb.cfg' % self.computer_partition_root_path) conf = yamlpp_load('%s/etc/enb.cfg' % self.computer_partition_root_path)
rf_driver = conf['rf_driver'] rf_driver = conf['rf_driver']
self.assertEqual(rf_driver['args'], self.assertEqual(rf_driver['args'],
...@@ -531,6 +510,23 @@ class TestUEMonitorGadgetUrl(ORSTestCase): ...@@ -531,6 +510,23 @@ class TestUEMonitorGadgetUrl(ORSTestCase):
test_monitor_gadget_url(self) test_monitor_gadget_url(self)
""" """
# ---- misc ----
# yamlpp_load loads yaml config file after preprocessing it.
#
# preprocessing is needed to e.g. remove // and /* comments.
def yamlpp_load(path):
with open(path, 'r') as f:
data = f.read() # original input
p = pcpp.Preprocessor()
p.parse(data)
f = io.StringIO()
p.write(f)
data_ = f.getvalue() # preprocessed input
return yaml.load(data_, Loader=yaml.Loader)
# assertMatch recursively matches data structure against specified pattern. # assertMatch recursively matches data structure against specified pattern.
# #
# - dict match by verifying v[k] == vok[k] for keys from the pattern. # - dict match by verifying v[k] == vok[k] for keys from the pattern.
......
...@@ -30,7 +30,7 @@ import json ...@@ -30,7 +30,7 @@ import json
import glob import glob
import requests import requests
from test import yload from test import yamlpp_load
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
...@@ -142,7 +142,7 @@ def test_enb_conf(self): ...@@ -142,7 +142,7 @@ def test_enb_conf(self):
conf_file = glob.glob(os.path.join( conf_file = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'etc', 'enb.cfg'))[0] self.slap.instance_directory, '*', 'etc', 'enb.cfg'))[0]
conf = yload(conf_file) conf = yamlpp_load(conf_file)
if 'tx_gain' in conf and 'rx_gain' in conf: if 'tx_gain' in conf and 'rx_gain' in conf:
self.assertEqual(conf['tx_gain'], [enb_param_dict['tx_gain']] * enb_param_dict['n_antenna_dl']) self.assertEqual(conf['tx_gain'], [enb_param_dict['tx_gain']] * enb_param_dict['n_antenna_dl'])
self.assertEqual(conf['rx_gain'], [enb_param_dict['rx_gain']] * enb_param_dict['n_antenna_ul']) self.assertEqual(conf['rx_gain'], [enb_param_dict['rx_gain']] * enb_param_dict['n_antenna_ul'])
...@@ -180,7 +180,7 @@ def test_gnb_conf1(self): ...@@ -180,7 +180,7 @@ def test_gnb_conf1(self):
conf_file = glob.glob(os.path.join( conf_file = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'etc', 'enb.cfg'))[0] self.slap.instance_directory, '*', 'etc', 'enb.cfg'))[0]
conf = yload(conf_file) conf = yamlpp_load(conf_file)
self.assertEqual(conf['tx_gain'], [gnb_param_dict1['tx_gain']] * gnb_param_dict1['n_antenna_dl']) self.assertEqual(conf['tx_gain'], [gnb_param_dict1['tx_gain']] * gnb_param_dict1['n_antenna_dl'])
self.assertEqual(conf['rx_gain'], [gnb_param_dict1['rx_gain']] * gnb_param_dict1['n_antenna_ul']) self.assertEqual(conf['rx_gain'], [gnb_param_dict1['rx_gain']] * gnb_param_dict1['n_antenna_ul'])
self.assertEqual(len(conf['cell_list']), 0) self.assertEqual(len(conf['cell_list']), 0)
...@@ -227,7 +227,7 @@ def test_gnb_conf2(self): ...@@ -227,7 +227,7 @@ def test_gnb_conf2(self):
conf_file = glob.glob(os.path.join( conf_file = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'etc', 'enb.cfg'))[0] self.slap.instance_directory, '*', 'etc', 'enb.cfg'))[0]
conf = yload(conf_file) conf = yamlpp_load(conf_file)
for p in conf['nr_cell_default']['plmn_list'][0]['nssai']: for p in conf['nr_cell_default']['plmn_list'][0]['nssai']:
sd = hex(p['sd']) sd = hex(p['sd'])
...@@ -239,7 +239,7 @@ def test_mme_conf(self): ...@@ -239,7 +239,7 @@ def test_mme_conf(self):
conf_file = glob.glob(os.path.join( conf_file = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'etc', 'mme.cfg'))[0] self.slap.instance_directory, '*', 'etc', 'mme.cfg'))[0]
conf = yload(conf_file) conf = yamlpp_load(conf_file)
self.assertEqual(conf['plmn'], param_dict['core_network_plmn']) self.assertEqual(conf['plmn'], param_dict['core_network_plmn'])
def test_sim_card(self): def test_sim_card(self):
...@@ -247,7 +247,7 @@ def test_sim_card(self): ...@@ -247,7 +247,7 @@ def test_sim_card(self):
conf_file = glob.glob(os.path.join( conf_file = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'etc', 'ue_db.cfg'))[0] self.slap.instance_directory, '*', 'etc', 'ue_db.cfg'))[0]
conf = yload(conf_file) conf = yamlpp_load(conf_file)
for n in "sim_algo imsi opc sqn impu impi".split(): for n in "sim_algo imsi opc sqn impu impi".split():
self.assertEqual(conf['ue_db'][0][n], param_dict[n]) self.assertEqual(conf['ue_db'][0][n], param_dict[n])
self.assertEqual(conf['ue_db'][0]['K'], param_dict['k']) self.assertEqual(conf['ue_db'][0]['K'], param_dict['k'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment