blob: e70c36c24cae88a88835ae2e2f710d03bdf139d0 [file] [log] [blame]
Neels Hofmeyr726b58d2017-10-15 03:01:09 +02001#!/usr/bin/env python3
2#
3# (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4# All rights reserved.
5#
6# Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21'''
22Run VTY test transcripts against a given application.
23
24A VTY transcript contains VTY commands and their expected results.
25It looks like:
26
27"
28OsmoHLR> enable
29
30OsmoHLR# subscriber show imsi 123456789023000
31% No subscriber for imsi = '123456789023000'
32OsmoHLR# subscriber show msisdn 12345
33% No subscriber for msisdn = '12345'
34
35OsmoHLR# subscriber create imsi 123456789023000
36% Created subscriber 123456789023000
37 ID: 1
38 IMSI: 123456789023000
39 MSISDN: none
40 No auth data
41"
42
43The application to be tested is described by
44- a binary to run,
45- command line arguments to pass to the binary,
46- the VTY telnet port,
47- the application name as printed in the VTY prompt.
48
49This module can either be run directly to run or update a given VTY transcript,
50or it can be imported as a module to run more complex setups.
51'''
52
53import re
54
Neels Hofmeyr6562c082017-10-18 03:20:04 +020055from osmopy.osmo_interact_vty import *
Neels Hofmeyr726b58d2017-10-15 03:01:09 +020056
57if __name__ == '__main__':
58 parser = common_parser()
Neels Hofmeyr6562c082017-10-18 03:20:04 +020059 parser_add_vty_args(parser)
60 parser_add_verify_args(parser)
Neels Hofmeyr726b58d2017-10-15 03:01:09 +020061 args = parser.parse_args()
62
63 interact = InteractVty(args.prompt, args.port, args.host, args.verbose, args.update)
64
Neels Hofmeyr6562c082017-10-18 03:20:04 +020065 main_verify_transcripts(args.run_app_str, args.transcript_files, interact, args.verbose)
Neels Hofmeyr726b58d2017-10-15 03:01:09 +020066
67# vim: tabstop=4 shiftwidth=4 expandtab nocin ai