blob: 288450fd5b5361983745bf1807ad6a0b2341699b [file] [log] [blame]
Pau Espin Pedrolc9faa9e2020-02-06 16:13:53 +01001#!/usr/bin/env python3
2import os
3from mako.template import Template
4
5from osmo_gsm_tester.testenv import *
6
Pau Espin Pedrola7e7fc52020-02-06 19:14:13 +01007def run_ttcn3(suite, test_obj, testdir, bts, osmocon, nat_rsl_ip, ttcn3_test_execute, ttcn3_test_extra_module_params=""):
Pau Espin Pedrolc9faa9e2020-02-06 16:13:53 +01008 own_dir = testdir
9 script_file = os.path.join(testdir, 'scripts', 'run_ttcn3_docker.sh')
10 bts_tmpl_file = os.path.join(testdir, 'scripts', 'BTS_Tests.cfg.tmpl')
11 script_run_dir = test_obj.get_run_dir().new_dir('ttcn3')
12 bts_cfg_file = os.path.join(str(script_run_dir), 'BTS_Tests.cfg')
13 junit_ttcn3_dst_file = os.path.join(str(suite.trial.get_run_dir()), 'trial-') + test_obj.basename + '.xml'
14 if bts.bts_type() == 'osmo-bts-trx':
15 pcu_available = True
16 pcu_sk = bts.pcu_socket_path()
17 else: # PCU unix socket not available locally
18 pcu_available = False
19 pcu_sk = ''
20 docker_cmd = (script_file, str(script_run_dir), junit_ttcn3_dst_file, nat_rsl_ip, osmocon.l2_socket_path(), pcu_sk)
21
22 print('Creating template')
23 mytemplate = Template(filename=bts_tmpl_file)
Pau Espin Pedrola7e7fc52020-02-06 19:14:13 +010024 r = mytemplate.render(btsvty_ctrl_hostname=bts.remote_addr(), pcu_available=pcu_available, ttcn3_test_execute=ttcn3_test_execute, ttcn3_test_extra_module_params=ttcn3_test_extra_module_params)
Pau Espin Pedrolc9faa9e2020-02-06 16:13:53 +010025 with open(bts_cfg_file, 'w') as f:
26 f.write(r)
27
28
29 print('Starting TTCN3 test suite')
30 proc = process.Process('ttcn3', script_run_dir, docker_cmd)
31 try:
32 proc.launch()
33 print('TTCN3 test suite launched, waiting until it finishes')
34 proc.wait(timeout=3600)
35 except Exception as e:
36 proc.terminate()
37 raise e
38
39 if proc.result != 0:
40 raise RuntimeError("run_ttcn3_docker.sh exited with error code %d" % proc.result)
41
42 print('Done')