Philipp Maier | 7124ad1 | 2023-08-01 16:00:28 +0200 | [diff] [blame] | 1 | #!/bin/bash |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 2 | |
Philipp Maier | a380e4e | 2023-08-01 15:29:13 +0200 | [diff] [blame] | 3 | # Utility to verify the functionality of pySim-trace.py |
| 4 | # |
| 5 | # (C) 2023 by Sysmocom s.f.m.c. GmbH |
| 6 | # All Rights Reserved |
| 7 | # |
| 8 | # Author: Philipp Maier |
| 9 | # |
| 10 | # This program is free software: you can redistribute it and/or modify |
| 11 | # it under the terms of the GNU General Public License as published by |
| 12 | # the Free Software Foundation, either version 2 of the License, or |
| 13 | # (at your option) any later version. |
| 14 | # |
| 15 | # This program is distributed in the hope that it will be useful, |
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | # GNU General Public License for more details. |
| 19 | # |
| 20 | # You should have received a copy of the GNU General Public License |
| 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 23 | PYSIM_TRACE=../pySim-trace.py |
| 24 | GSMTAP_TRACE=pySim-trace_test_gsmtap.pcapng |
Philipp Maier | a380e4e | 2023-08-01 15:29:13 +0200 | [diff] [blame] | 25 | TEMPFILE=temp.tmp |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 26 | |
Philipp Maier | 4af63dc | 2023-10-26 12:17:32 +0200 | [diff] [blame] | 27 | export PYSIM_INTEGRATION_TEST=1 |
| 28 | |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 29 | echo "pySim-trace_test - a test program to test pySim-trace.py" |
| 30 | echo "========================================================" |
| 31 | |
Philipp Maier | a380e4e | 2023-08-01 15:29:13 +0200 | [diff] [blame] | 32 | function usage { |
| 33 | echo "Options:" |
| 34 | echo "-o: generate .ok file" |
| 35 | } |
| 36 | |
| 37 | function gen_ok_file { |
| 38 | $PYSIM_TRACE gsmtap-pyshark-pcap -f $GSMTAP_TRACE > $GSMTAP_TRACE.ok |
| 39 | echo "Generated file: $GSMTAP_TRACE.ok" |
| 40 | echo "------------8<------------" |
| 41 | cat $GSMTAP_TRACE.ok |
| 42 | echo "------------8<------------" |
| 43 | } |
| 44 | |
| 45 | function run_test { |
| 46 | $PYSIM_TRACE gsmtap-pyshark-pcap -f $GSMTAP_TRACE | tee $TEMPFILE |
| 47 | if [ ${PIPESTATUS[0]} -ne 0 ]; then |
| 48 | echo "" |
| 49 | echo "========================================================" |
| 50 | echo "Testrun with $GSMTAP_TRACE failed (exception)." |
| 51 | rm -f $TEMPFILE |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | DIFF=`diff $GSMTAP_TRACE.ok $TEMPFILE` |
| 56 | if ! [ -z "$DIFF" ]; then |
| 57 | echo "Testrun with $GSMTAP_TRACE failed (unexpected output)." |
| 58 | echo "------------8<------------" |
| 59 | diff $GSMTAP_TRACE.ok $TEMPFILE |
| 60 | echo "------------8<------------" |
| 61 | rm -f $TEMPFILE |
| 62 | exit 1 |
| 63 | fi |
| 64 | |
| 65 | echo "" |
| 66 | echo "========================================================" |
| 67 | echo "trace parsed without problems -- everything ok!" |
| 68 | rm -f $TEMPFILE |
| 69 | } |
| 70 | |
| 71 | OPT_GEN_OK_FILE=0 |
| 72 | while getopts ":ho" OPT; do |
| 73 | case $OPT in |
| 74 | h) |
| 75 | usage |
| 76 | exit 0 |
| 77 | ;; |
| 78 | o) |
| 79 | OPT_GEN_OK_FILE=1 |
| 80 | ;; |
| 81 | \?) |
| 82 | echo "Invalid option: -$OPTARG" >&2 |
| 83 | exit 1 |
| 84 | ;; |
| 85 | esac |
| 86 | done |
| 87 | |
| 88 | if [ $OPT_GEN_OK_FILE -eq 1 ]; then |
| 89 | gen_ok_file |
| 90 | exit 0 |
| 91 | else |
| 92 | run_test |
| 93 | exit 0 |
Philipp Maier | ec9cdb7 | 2023-07-27 14:43:08 +0200 | [diff] [blame] | 94 | fi |