tests: dyn_ts_*: Add tests to verify dynamic timeslots during phone calls

Two different test suites are created since we want to run them with
different HW, because some HW support one type of PDCH channels, and
other HW supports the other one.

Change-Id: Id5e61eaff39ac7a6585dc7de2aeb2469dd2ce726
diff --git a/suites/dyn_ts_ipa/lib/testlib.py b/suites/dyn_ts_ipa/lib/testlib.py
new file mode 100755
index 0000000..28a4975
--- /dev/null
+++ b/suites/dyn_ts_ipa/lib/testlib.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+from osmo_gsm_tester.testenv import *
+
+def call_test_setup_run(bts_setup_cb=None, gprs_enable=True):
+    hlr = suite.hlr()
+    bts = suite.bts()
+    mgw_msc = suite.mgw()
+    mgw_bsc = suite.mgw()
+    stp = suite.stp()
+    msc = suite.msc(hlr, mgw_msc, stp)
+    bsc = suite.bsc(msc, mgw_bsc, stp)
+    ms_mo = suite.modem()
+    ms_mt = suite.modem()
+
+    if bts_setup_cb is not None:
+        bts_setup_cb(bts)
+
+    if gprs_enable:
+        ggsn = suite.ggsn()
+        sgsn = suite.sgsn(hlr, ggsn)
+        sgsn.bts_add(bts)
+        ggsn.start()
+        sgsn.start()
+
+    hlr.start()
+    stp.start()
+    msc.start()
+    mgw_msc.start()
+    mgw_bsc.start()
+
+    bsc.bts_add(bts)
+    bsc.start()
+
+    bts.start()
+    wait(bsc.bts_is_connected, bts)
+
+    hlr.subscriber_add(ms_mo)
+    hlr.subscriber_add(ms_mt)
+
+    ms_mo.connect(msc.mcc_mnc())
+    ms_mt.connect(msc.mcc_mnc())
+
+    ms_mo.log_info()
+    ms_mt.log_info()
+
+    print('waiting for modems to attach...')
+    wait(ms_mo.is_connected, msc.mcc_mnc())
+    wait(ms_mt.is_connected, msc.mcc_mnc())
+    wait(msc.subscriber_attached, ms_mo, ms_mt)
+
+    assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0
+    mo_cid = ms_mo.call_dial(ms_mt)
+    mt_cid = ms_mt.call_wait_incoming(ms_mo)
+    print('dial success')
+
+    assert not ms_mo.call_is_active(mo_cid) and not ms_mt.call_is_active(mt_cid)
+    ms_mt.call_answer(mt_cid)
+    wait(ms_mo.call_is_active, mo_cid)
+    wait(ms_mt.call_is_active, mt_cid)
+    print('answer success, call established and ongoing')
+
+    sleep(5) # maintain the call active for 5 seconds
+
+    assert ms_mo.call_is_active(mo_cid) and ms_mt.call_is_active(mt_cid)
+    ms_mt.call_hangup(mt_cid)
+    wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0)
+    print('hangup success')
diff --git a/suites/dyn_ts_ipa/mo_mt_call_dyn_ipa.py b/suites/dyn_ts_ipa/mo_mt_call_dyn_ipa.py
new file mode 100755
index 0000000..1e7a5c0
--- /dev/null
+++ b/suites/dyn_ts_ipa/mo_mt_call_dyn_ipa.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+from osmo_gsm_tester.testenv import *
+
+add_subdir_to_import_path("lib")
+from testlib import call_test_setup_run
+
+def my_bts_setup(bts):
+    bts.set_num_trx(1)
+    bts.set_trx_phy_channel(0, 0, 'CCCH+SDCCH4')
+    bts.set_trx_phy_channel(0, 1, 'SDCCH8')
+    bts.set_trx_phy_channel(0, 2, 'TCH/F_PDCH')
+    bts.set_trx_phy_channel(0, 3, 'TCH/F_PDCH')
+    bts.set_trx_phy_channel(0, 4, 'TCH/F_PDCH')
+    bts.set_trx_phy_channel(0, 5, 'TCH/F_PDCH')
+    bts.set_trx_phy_channel(0, 6, 'TCH/F_PDCH')
+    bts.set_trx_phy_channel(0, 7, 'PDCH')
+
+#FIXME: if we don't enable gprs (gprs none in BSC vty) then dyn chans are broken, see OS#3244
+# Once Fixed, add a new test with following test:
+#call_test_setup_run(bts_setup_cb=my_bts_setup, gprs_enable=False)
+
+call_test_setup_run(bts_setup_cb=my_bts_setup, gprs_enable=True)
diff --git a/suites/dyn_ts_ipa/suite.conf b/suites/dyn_ts_ipa/suite.conf
new file mode 100644
index 0000000..4ac2436
--- /dev/null
+++ b/suites/dyn_ts_ipa/suite.conf
@@ -0,0 +1,9 @@
+resources:
+  ip_address:
+  - times: 8 # msc, bsc, hlr, stp, mgw*2, sgsn, ggsn
+  bts:
+  - times: 1
+  modem:
+  - times: 2
+    features:
+    - voice
diff --git a/suites/dyn_ts_osmo/lib/testlib.py b/suites/dyn_ts_osmo/lib/testlib.py
new file mode 120000
index 0000000..8f0bc5a
--- /dev/null
+++ b/suites/dyn_ts_osmo/lib/testlib.py
@@ -0,0 +1 @@
+../../dyn_ts_ipa/lib/testlib.py
\ No newline at end of file
diff --git a/suites/dyn_ts_osmo/mo_mt_call_dyn_osmo.py b/suites/dyn_ts_osmo/mo_mt_call_dyn_osmo.py
new file mode 100755
index 0000000..3ba8045
--- /dev/null
+++ b/suites/dyn_ts_osmo/mo_mt_call_dyn_osmo.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+from osmo_gsm_tester.testenv import *
+
+add_subdir_to_import_path("lib")
+from testlib import call_test_setup_run
+
+def my_bts_setup(bts):
+    bts.set_num_trx(1)
+    bts.set_trx_phy_channel(0, 0, 'CCCH+SDCCH4')
+    bts.set_trx_phy_channel(0, 1, 'SDCCH8')
+    bts.set_trx_phy_channel(0, 2, 'TCH/F_TCH/H_PDCH')
+    bts.set_trx_phy_channel(0, 3, 'TCH/F_TCH/H_PDCH')
+    bts.set_trx_phy_channel(0, 4, 'TCH/F_TCH/H_PDCH')
+    bts.set_trx_phy_channel(0, 5, 'TCH/F_TCH/H_PDCH')
+    bts.set_trx_phy_channel(0, 6, 'TCH/F_TCH/H_PDCH')
+    bts.set_trx_phy_channel(0, 7, 'PDCH')
+
+#FIXME: if we don't enable gprs (gprs none in BSC vty) then dyn chans are broken, see OS#3244
+# Once Fixed, add a new test with following test:
+#call_test_setup_run(bts_setup_cb=my_bts_setup, gprs_enable=False)
+
+call_test_setup_run(bts_setup_cb=my_bts_setup, gprs_enable=True)
diff --git a/suites/dyn_ts_osmo/suite.conf b/suites/dyn_ts_osmo/suite.conf
new file mode 100644
index 0000000..4ac2436
--- /dev/null
+++ b/suites/dyn_ts_osmo/suite.conf
@@ -0,0 +1,9 @@
+resources:
+  ip_address:
+  - times: 8 # msc, bsc, hlr, stp, mgw*2, sgsn, ggsn
+  bts:
+  - times: 1
+  modem:
+  - times: 2
+    features:
+    - voice