core implementation

code bomb implementing the bulk of the osmo-gsm-tester

Change-Id: I53610becbf643ed51b90cfd9debc6992fe211ec9
diff --git a/selftest/real_suite/README.txt b/selftest/real_suite/README.txt
new file mode 100644
index 0000000..f18840a
--- /dev/null
+++ b/selftest/real_suite/README.txt
@@ -0,0 +1,18 @@
+This a real gsm test suite configured and ready to use.
+The only thing missing is a trial dir containing binaries.
+
+If you have your trial with binary tar archives in ~/my_trial
+you can run the suite for example like this:
+
+    . ./env  # point your environment at all the right places
+    run_once.py ~/my_trial -s sms:trx
+
+This combines the suites/sms test suite with the scenarios/trx choice of
+osmo-bts-trx and runs all tests in the 'sms' suite.
+
+A ./state dir will be created to store the current osmo-gsm-tester state. If
+you prefer not to write to this dir, set up an own configuration pointing at a
+different path (see paths.conf: 'state_dir' and the env file).  When there is
+no OSMO_GSM_TESTER_CONF set (from ./env), osmo-gsm-tester will instead look for
+conf files in several locations like ~/.config/osmo-gsm-tester,
+/usr/local/etc/osmo-gsm-tester, /etc/osmo-gsm-tester
diff --git a/selftest/real_suite/default.conf b/selftest/real_suite/default.conf
new file mode 100644
index 0000000..b247722
--- /dev/null
+++ b/selftest/real_suite/default.conf
@@ -0,0 +1,31 @@
+nitb:
+  net:
+    mcc: 1
+    mnc: 868
+    short_name: osmo-gsm-tester
+    long_name: osmo-gsm-tester
+    auth_policy: closed
+    encryption: a5 0
+
+nitb_bts:
+  location_area_code: 23
+  base_station_id_code: 63
+  stream_id: 255
+  trx_list:
+  - max_power_red: 22
+    arfcn: 868
+    timeslot_list:
+    - phys_chan_config: CCCH+SDCCH4
+    - phys_chan_config: SDCCH8
+    - phys_chan_config: TCH_F/TCH_H/PDCH
+    - phys_chan_config: TCH_F/TCH_H/PDCH
+    - phys_chan_config: TCH_F/TCH_H/PDCH
+    - phys_chan_config: TCH_F/TCH_H/PDCH
+    - phys_chan_config: TCH_F/TCH_H/PDCH
+    - phys_chan_config: TCH_F/TCH_H/PDCH
+
+osmo_bts_sysmo:
+  ipa_unit_id: 1123
+
+osmo_bts_trx:
+  ipa_unit_id: 1124
diff --git a/selftest/real_suite/env b/selftest/real_suite/env
new file mode 100644
index 0000000..1d9cc0a
--- /dev/null
+++ b/selftest/real_suite/env
@@ -0,0 +1,4 @@
+OSMO_GSM_TESTER_SRC="$(readlink -f ../../src)"
+export PYTHONPATH="$OSMO_GSM_TESTER_SRC"
+export PATH="$OSMO_GSM_TESTER_SRC:$PATH"
+export OSMO_GSM_TESTER_CONF="$PWD"
diff --git a/selftest/real_suite/paths.conf b/selftest/real_suite/paths.conf
new file mode 100644
index 0000000..bb7316c
--- /dev/null
+++ b/selftest/real_suite/paths.conf
@@ -0,0 +1,3 @@
+state_dir: './state'
+suites_dir: './suites'
+scenarios_dir: './scenarios'
diff --git a/selftest/real_suite/resources.conf b/selftest/real_suite/resources.conf
new file mode 100644
index 0000000..a6c396b
--- /dev/null
+++ b/selftest/real_suite/resources.conf
@@ -0,0 +1,139 @@
+# all hardware and interfaces available to this osmo-gsm-tester
+
+nitb_iface:
+- addr: 127.0.0.10
+- addr: 127.0.0.11
+- addr: 127.0.0.12
+
+bts:
+- label: sysmoBTS 1002
+  type: sysmo
+  unit_id: 1
+  addr: 10.42.42.114
+  band: GSM-1800
+
+- label: octBTS 3000
+  type: oct
+  unit_id: 5
+  addr: 10.42.42.115
+  band: GSM-1800
+  trx:
+  - hwaddr: 00:0c:90:32:b5:8a
+
+- label: Ettus B210
+  type: osmotrx
+  unit_id: 6
+  addr: 10.42.42.116
+  band: GSM-1800
+
+- label: nanoBTS 1900
+  type: nanobts
+  unit_id: 1902
+  addr: 10.42.42.190
+  band: GSM-1900
+  trx:
+  - hwaddr: 00:02:95:00:41:b3
+
+arfcn:
+  - arfcn: 512
+    band: GSM-1800
+  - arfcn: 514
+    band: GSM-1800
+  - arfcn: 516
+    band: GSM-1800
+  - arfcn: 518
+    band: GSM-1800
+  - arfcn: 520
+    band: GSM-1800
+
+  - arfcn: 540
+    band: GSM-1900
+  - arfcn: 542
+    band: GSM-1900
+  - arfcn: 544
+    band: GSM-1900
+  - arfcn: 546
+    band: GSM-1900
+  - arfcn: 548
+    band: GSM-1900
+
+modem:
+- label: m7801
+  path: '/wavecom_0'
+  imsi: 901700000007801
+  ki: D620F48487B1B782DA55DF6717F08FF9
+
+- label: m7802
+  path: '/wavecom_1'
+  imsi: 901700000007802
+  ki: 47FDB2D55CE6A10A85ABDAD034A5B7B3
+
+- label: m7803
+  path: '/wavecom_2'
+  imsi: 901700000007803
+  ki: ABBED4C91417DF710F60675B6EE2C8D2
+
+- label: m7804
+  path: '/wavecom_3'
+  imsi: 901700000007804
+  ki: 8BA541179156F2BF0918CA3CFF9351B0
+
+- label: m7805
+  path: '/wavecom_4'
+  imsi: 901700000007805
+  ki: 82BEC24B5B50C9FAA69D17DEC0883A23
+
+- label: m7806
+  path: '/wavecom_5'
+  imsi: 901700000007806
+  ki: DAF6BD6A188F7A4F09866030BF0F723D
+
+- label: m7807
+  path: '/wavecom_6'
+  imsi: 901700000007807
+  ki: AEB411CFE39681A6352A1EAE4DDC9DBA
+
+- label: m7808
+  path: '/wavecom_7'
+  imsi: 901700000007808
+  ki: F5DEF8692B305D7A65C677CA9EEE09C4
+
+- label: m7809
+  path: '/wavecom_8'
+  imsi: 901700000007809
+  ki: A644F4503E812FD75329B1C8D625DA44
+
+- label: m7810
+  path: '/wavecom_9'
+  imsi: 901700000007810
+  ki: EF663BDF3477DCD18D3D2293A2BAED67
+
+- label: m7811
+  path: '/wavecom_10'
+  imsi: 901700000007811
+  ki: E88F37F048A86A9BC4D652539228C039
+
+- label: m7812
+  path: '/wavecom_11'
+  imsi: 901700000007812
+  ki: E8D940DD66FCF6F1CD2C0F8F8C45633D
+
+- label: m7813
+  path: '/wavecom_12'
+  imsi: 901700000007813
+  ki: DBF534700C10141C49F699B0419107E3
+
+- label: m7814
+  path: '/wavecom_13'
+  imsi: 901700000007814
+  ki: B36021DEB90C4EA607E408A92F3B024D
+
+- label: m7815
+  path: '/wavecom_14'
+  imsi: 901700000007815
+  ki: 1E209F6F839F9195778C4F96BE281A24
+
+- label: m7816
+  path: '/wavecom_15'
+  imsi: 901700000007816
+  ki: BF827D219E739DD189F6F59E60D6455C
diff --git a/selftest/real_suite/scenarios/trx.conf b/selftest/real_suite/scenarios/trx.conf
new file mode 100644
index 0000000..98065aa
--- /dev/null
+++ b/selftest/real_suite/scenarios/trx.conf
@@ -0,0 +1,3 @@
+resources:
+  bts:
+  - type: osmotrx
diff --git a/selftest/real_suite/suites/sms/mo_mt_sms.py b/selftest/real_suite/suites/sms/mo_mt_sms.py
new file mode 100755
index 0000000..05be48c
--- /dev/null
+++ b/selftest/real_suite/suites/sms/mo_mt_sms.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+from osmo_gsm_tester.test import *
+
+print('use resources...')
+nitb = suite.nitb()
+bts = suite.bts()
+ms_mo = suite.modem()
+ms_mt = suite.modem()
+
+print('start nitb and bts...')
+nitb.add_bts(bts)
+nitb.start()
+sleep(.1)
+assert nitb.running()
+bts.start()
+
+nitb.add_subscriber(ms_mo)
+nitb.add_subscriber(ms_mt)
+
+ms_mo.connect(nitb)
+ms_mt.connect(nitb)
+wait(nitb.subscriber_attached, ms_mo, ms_mt)
+
+sms = ms_mo.sms_send(ms_mt.msisdn)
+sleep(3)
+wait(nitb.sms_received, sms)
diff --git a/selftest/real_suite/suites/sms/suite.conf b/selftest/real_suite/suites/sms/suite.conf
new file mode 100644
index 0000000..4a03379
--- /dev/null
+++ b/selftest/real_suite/suites/sms/suite.conf
@@ -0,0 +1,10 @@
+resources:
+  nitb_iface:
+  - times: 1
+  bts:
+  - times: 1
+  modem:
+  - times: 2
+
+defaults:
+  timeout: 60s