Neels Hofmeyr | 726b58d | 2017-10-15 03:01:09 +0200 | [diff] [blame] | 1 | #!/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 | ''' |
| 22 | Run VTY test transcripts against a given application. |
| 23 | |
| 24 | A VTY transcript contains VTY commands and their expected results. |
| 25 | It looks like: |
| 26 | |
| 27 | " |
| 28 | OsmoHLR> enable |
| 29 | |
| 30 | OsmoHLR# subscriber show imsi 123456789023000 |
| 31 | % No subscriber for imsi = '123456789023000' |
| 32 | OsmoHLR# subscriber show msisdn 12345 |
| 33 | % No subscriber for msisdn = '12345' |
| 34 | |
| 35 | OsmoHLR# subscriber create imsi 123456789023000 |
| 36 | % Created subscriber 123456789023000 |
| 37 | ID: 1 |
| 38 | IMSI: 123456789023000 |
| 39 | MSISDN: none |
| 40 | No auth data |
| 41 | " |
| 42 | |
| 43 | The 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 | |
| 49 | This module can either be run directly to run or update a given VTY transcript, |
| 50 | or it can be imported as a module to run more complex setups. |
| 51 | ''' |
| 52 | |
| 53 | import re |
| 54 | |
Neels Hofmeyr | 6562c08 | 2017-10-18 03:20:04 +0200 | [diff] [blame] | 55 | from osmopy.osmo_interact_vty import * |
Neels Hofmeyr | 726b58d | 2017-10-15 03:01:09 +0200 | [diff] [blame] | 56 | |
| 57 | if __name__ == '__main__': |
| 58 | parser = common_parser() |
Neels Hofmeyr | 6562c08 | 2017-10-18 03:20:04 +0200 | [diff] [blame] | 59 | parser_add_vty_args(parser) |
| 60 | parser_add_verify_args(parser) |
Neels Hofmeyr | 726b58d | 2017-10-15 03:01:09 +0200 | [diff] [blame] | 61 | args = parser.parse_args() |
| 62 | |
| 63 | interact = InteractVty(args.prompt, args.port, args.host, args.verbose, args.update) |
| 64 | |
Neels Hofmeyr | 6562c08 | 2017-10-18 03:20:04 +0200 | [diff] [blame] | 65 | main_verify_transcripts(args.run_app_str, args.transcript_files, interact, args.verbose) |
Neels Hofmeyr | 726b58d | 2017-10-15 03:01:09 +0200 | [diff] [blame] | 66 | |
| 67 | # vim: tabstop=4 shiftwidth=4 expandtab nocin ai |