Compare commits

...

12 Commits

Author SHA1 Message Date
Harald Welte c0cc718853 runtest-junitxml: work with python3 2023-11-06 16:46:47 +01:00
Harald Welte fdda7d8a6e runtest-junitxml: Set GUILE_AUTO_COMPILE=0 to avoid stderr output
stderr output would make the junit test case "FAIL"
2023-11-06 16:46:47 +01:00
Harald Welte 81eb605dc2 runtest-junitxml: Disable guile warnings about deprecated features 2023-11-06 16:46:47 +01:00
Harald Welte 7bbc391b69 runtest-junitxml.py: Use $HOME as default 'directory' 2023-11-06 16:46:47 +01:00
Harald Welte f21a9a9a70 Add 'runtest-junitxml.py' to generate junit-xml output 2023-11-06 16:46:47 +01:00
Harald Welte 60efa78b92 params: Use addresses compatible with libosmo-sccp test scripts 2023-11-06 16:46:47 +01:00
Harald Welte 680df9afc6 runm3uatest: Avoid having to use a ~/.guile script
Rather, we can specify the path in which the m3ua-testtool files are
located using the '-d ...' command line argument of runm3uatest
2023-11-06 16:46:47 +01:00
Harald Welte f00e46de1e libosmo-sigtran test config + script 2023-11-06 16:46:47 +01:00
Michael Tuexen ae3e1b3f5e Improve test. 2022-01-21 11:19:08 +01:00
Michael Tuexen 0c979a7281 Only use colors when writing to tty 2021-12-12 19:15:37 +01:00
Michael Tuexen ca42223587 Use sh instead of tcsh 2021-12-12 19:02:16 +01:00
Michael Tuexen d9480fbc4f Use inet-pton instead of inet-aton, which is deprecated. 2021-12-01 01:42:44 +01:00
11 changed files with 216 additions and 56 deletions

1
.guile Symbolic link
View File

@ -0,0 +1 @@
dotguile

View File

@ -26,7 +26,7 @@
;;; $Id: dotguile,v 1.1 2012/08/26 21:06:27 tuexen Exp $
;;; Change the following line to reflect where the files are located.
(define dir "/Users/tuexen/Documents/m3ua-testtool/")
(define dir "")
(define files (list "common.scm"
"m3ua.scm"
"m3ua-asp-tests.scm"

View File

@ -198,7 +198,7 @@
(define (m3ua-asp-aspsm-o-002 tester-addr tester-port sut-addr sut-port)
(let ((fd (m3ua-accept tester-addr tester-port)))
(m3ua-wait-for-message fd m3ua-asp-up-message?)
(m3ua-send-message fd 0 (m3ua-make-asp-active-ack-message (list)))
(m3ua-send-message fd 0 (m3ua-make-asp-active-ack-message asp-active-ack-message-parameters))
(let ((msg (m3ua-recv-message-with-timeout fd 2)))
(close fd)
(if (or (null? msg)

View File

@ -35,23 +35,23 @@
;;; $Id: m3ua-param-testtool.scm,v 1.5 2012/08/28 19:56:13 tuexen Exp $
;;; Define a transport address of the system under test
(define sut-addr "127.0.0.1")
(define sut-port 0)
(define sut-port-1 0)
(define sut-port-2 0)
;;; Define a transport address of the system under test (osmo-stp)
(define sut-addr "172.18.0.200")
(define sut-port m3ua-port)
(define sut-port-1 m3ua-port)
(define sut-port-2 m3ua-port)
;;; Define the transport address of the tester
(define tester-addr "127.0.0.1")
(define tester-port m3ua-port)
(define tester-addr "172.18.0.2")
(define tester-port 3333)
(define tester-port-1 3000)
(define tester-port-2 3001)
;;; Define the point code of the IUT
(define iut-pc 4001)
(define iut-pc 1)
;;; Define the point code of the tester
(define tester-pc 100)
(define tester-pc 23)
(define tester-pc-1 100)
(define tester-pc-2 101)
(define tester-invalid-pc 102)
@ -79,7 +79,7 @@
(define invalid-network-appearance 2)
;;; Define an routing context
(define tester-rc-valid 1)
(define tester-rc-valid 23)
(define tester-rc-valid-1 1)
(define tester-rc-valid-2 2)
@ -124,7 +124,7 @@
;;;data-message-parameters
;;; Define parameter for DATA message
(define rc 1)
(define rc 23)
(define opc 1)
(define dpc 2)
(define si 0)

View File

@ -776,8 +776,8 @@
(let ((s (socket AF_INET SOCK_STREAM IPPROTO_SCTP)))
(catch 'system-error
(lambda ()
(bind s AF_INET (inet-aton local-addr) local-port)
(connect s AF_INET (inet-aton remote-addr) remote-port)
(bind s AF_INET (inet-pton AF_INET local-addr) local-port)
(connect s AF_INET (inet-pton AF_INET remote-addr) remote-port)
(if (defined? 'SCTP_NODELAY)
(setsockopt s IPPROTO_SCTP SCTP_NODELAY 1))
s)
@ -790,7 +790,7 @@
(let ((s (socket AF_INET SOCK_STREAM IPPROTO_SCTP)))
(catch 'system-error
(lambda ()
(bind s AF_INET (inet-aton local-addr) local-port)
(bind s AF_INET (inet-pton AF_INET local-addr) local-port)
(listen s 1)
(let ((ss (car (accept s))))
(close s)

43
run-all-sgp-tests Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env tcsh
set timeout = 10
set sleeptime = 1
set testcases = (m3ua-sgp-aspsm-v-001 \
m3ua-sgp-aspsm-v-003 \
m3ua-sgp-aspsm-v-005 \
m3ua-sgp-aspsm-i-001 \
m3ua-sgp-aspsm-i-002 \
m3ua-sgp-aspsm-i-003 \
m3ua-sgp-aspsm-i-004 \
m3ua-sgp-aspsm-o-001 \
m3ua-sgp-aspsm-o-003 \
m3ua-sgp-aspsm-o-004 \
m3ua-sgp-asptm-v-001 \
m3ua-sgp-asptm-v-003 \
m3ua-sgp-asptm-v-006 \
m3ua-sgp-asptm-v-008 \
m3ua-sgp-asptm-v-010 \
m3ua-sgp-asptm-v-011 \
m3ua-sgp-asptm-i-001 \
m3ua-sgp-asptm-i-004 \
m3ua-sgp-asptm-i-005 \
m3ua-sgp-asptm-i-006 \
m3ua-sgp-asptm-i-008 \
m3ua-sgp-asptm-i-010 \
m3ua-sgp-asptm-o-001 \
m3ua-sgp-asptm-o-003 \
m3ua-sgp-mtr-v-002-alternate \
m3ua-sgp-mtr-v-003-alternate \
m3ua-sgp-mtr-i-001 \
m3ua-sgp-mtr-i-002 \
m3ua-sgp-mtr-i-003 \
m3ua-sgp-rkm-v-001 \
m3ua-sgp-rkm-v-002 \
m3ua-sgp-rkm-v-003 \
)
foreach testcase ($testcases)
(./runm3uatest -d . -t $timeout $testcase > /dev/tty) >& /dev/null
sleep $sleeptime
end

View File

@ -1,20 +1,21 @@
#!/usr/bin/env tcsh
#!/usr/bin/env sh
set timeout = 10
set sleeptime = 1
timeout=10
sleeptime=1
set testcases = (m3ua-asp-aspsm-v-002 \
m3ua-asp-aspsm-i-001 \
m3ua-asp-aspsm-i-003 \
m3ua-asp-aspsm-o-001 \
m3ua-asp-aspsm-o-002 \
m3ua-asp-asptm-v-001 \
m3ua-asp-asptm-v-008 \
m3ua-asp-asptm-i-003 \
m3ua-asp-asptm-o-001 \
m3ua-asp-mtr-i-002 )
testcases='m3ua-asp-aspsm-v-002
m3ua-asp-aspsm-i-001
m3ua-asp-aspsm-i-003
m3ua-asp-aspsm-o-001
m3ua-asp-aspsm-o-002
m3ua-asp-asptm-v-001
m3ua-asp-asptm-v-008
m3ua-asp-asptm-i-003
m3ua-asp-asptm-o-001
m3ua-asp-mtr-i-002'
foreach testcase ($testcases)
(runm3uatest -t $timeout $testcase > /dev/tty) >& /dev/null
for testcase in $testcases
do
./runm3uatest -d . -t $timeout $testcase 2> /dev/null
sleep $sleeptime
end
done

View File

@ -1,20 +1,21 @@
#!/usr/bin/env tcsh
#!/usr/bin/env sh
set timeout = 10
set sleeptime = 1
timeout=10
sleeptime=1
set testcases = (m3ua-sgp-aspsm-v-003 \
m3ua-sgp-aspsm-i-001 \
m3ua-sgp-aspsm-i-002 \
m3ua-sgp-aspsm-i-003 \
m3ua-sgp-aspsm-o-001 \
m3ua-sgp-asptm-v-003 \
m3ua-sgp-asptm-v-008 \
m3ua-sgp-asptm-v-011 \
m3ua-sgp-asptm-i-004 \
m3ua-sgp-asptm-o-001)
testcases='m3ua-sgp-aspsm-v-003
m3ua-sgp-aspsm-i-001
m3ua-sgp-aspsm-i-002
m3ua-sgp-aspsm-i-003
m3ua-sgp-aspsm-o-001
m3ua-sgp-asptm-v-003
m3ua-sgp-asptm-v-008
m3ua-sgp-asptm-v-011
m3ua-sgp-asptm-i-004
m3ua-sgp-asptm-o-001'
foreach testcase ($testcases)
(runm3uatest -t $timeout $testcase > /dev/tty) >& /dev/null
for testcase in $testcases
do
./runm3uatest -d . -t $timeout $testcase 2> /dev/null
sleep $sleeptime
end
done

View File

@ -36,10 +36,10 @@
#define TIMEOUT 0
#define COMMAND_LENGTH 2048
#define RED(string) "\033[31m"string"\033[0m"
#define GREEN(string) "\033[32m"string"\033[0m"
#define YELLOW(string) "\033[33m"string"\033[0m"
#define BLUE(string) "\033[34m"string"\033[0m"
#define RED(string) isatty(fileno(stdout))?"\033[31m"string"\033[0m":string
#define GREEN(string) isatty(fileno(stdout))?"\033[32m"string"\033[0m":string
#define YELLOW(string) isatty(fileno(stdout))?"\033[33m"string"\033[0m":string
#define BLUE(string) isatty(fileno(stdout))?"\033[34m"string"\033[0m":string
char command_skel[] =
"(load-from-path \"%s/.guile\")"
@ -71,10 +71,11 @@ main(int argc, char *argv[]) {
unsigned int timeout;
int status, c;
char command[COMMAND_LENGTH];
char *dir = getenv("HOME");
timeout = TIMEOUT;
while ((c = getopt(argc, argv, "t:")) != -1) {
while ((c = getopt(argc, argv, "t:d:")) != -1) {
switch(c) {
case 'h':
print_usage();
@ -83,6 +84,9 @@ main(int argc, char *argv[]) {
case 't':
timeout = (unsigned int)atoi(optarg);
break;
case 'd':
dir = optarg;
break;
default:
print_usage();
return (1);
@ -90,7 +94,7 @@ main(int argc, char *argv[]) {
}
if (optind == argc - 1) {
snprintf(command, COMMAND_LENGTH, command_skel, getenv("HOME"), argv[optind]);
snprintf(command, COMMAND_LENGTH, command_skel, dir, argv[optind]);
} else {
print_usage();
return (1);
@ -98,9 +102,9 @@ main(int argc, char *argv[]) {
if ((pid = fork()) == 0) {
#if defined(__APPLE__) || defined(__FreeBSD__)
execlp("/usr/local/bin/guile", "guile", "-c", command, NULL);
execlp("/usr/local/bin/guile", "guile", "-L", dir, "-c", command, NULL);
#else
execlp("/usr/bin/guile", "guile", "-c", command, NULL);
execlp("/usr/bin/guile", "guile", "-L", dir, "-c", command, NULL);
#endif
return (255);
}

100
runtest-junitxml.py Executable file
View File

@ -0,0 +1,100 @@
#!/usr/bin/python3
# Alternative executor for m3ua tests suite by Michael Tuexen's nplab
# (C) 2017 by Harald Welte <laforge@gnumonks.org>
from optparse import OptionParser
import os, sys, signal, time
from subprocess import Popen, PIPE
from junit_xml import TestSuite, TestCase
PROTO='m3ua'
GUILE='/usr/bin/guile'
COMMAND_SKEL="""
(load-from-path "%s/.guile")
(let ((test-name "%s"))
(if (defined? (string->symbol test-name))
(exit ((eval-string test-name)
tester-addr tester-port sut-addr sut-port))
(exit 254)))
""";
TEST='%s-test' % PROTO
def status2tc(testcase, exitstatus, time_passed=0, stdout=None, stderr=None):
tc = TestCase(testcase, TEST, time_passed, stdout, stderr)
if exitstatus == 0:
return tc
elif exitstatus == 1:
tc.add_failure_info('FAILED')
elif exitstatus == 2:
tc.add_error_info('UNKNOWN')
elif exitstatus == 252:
tc.add_error_info('TIMEOUT')
elif exitstatus == 253:
tc.add_skipped_info('NON-APPLICABLE')
elif exitstatus == 254:
tc.add_error_info('NON-EXISTENT')
elif exitstatus == 255:
tc.add_error_info("COULDN'T START GUILE")
else:
tc.add_error_info("BUG")
return tc
def signal_handler(signum, frame):
raise IOError("Timeout!")
def start_testcase(directory, testcase, timeout=0):
cmd = COMMAND_SKEL % (directory, testcase)
signal.signal(signal.SIGALRM, signal_handler)
signal.alarm(timeout)
before = time.time()
my_env = os.environ
my_env["GUILE_WARN_DEPRECATED"] = "no"
my_env["GUILE_AUTO_COMPILE"] = "0"
p = Popen([GUILE, '-L', directory, '-c', cmd], env=my_env, stdout=PIPE, stderr=PIPE)
try:
(tc_stdout, tc_stderr) = p.communicate()
returncode = p.returncode
except IOError:
tc_stdout = tc_stderr = None
returncode = 252
signal.alarm(0)
after = time.time()
return status2tc(testcase, returncode, after-before, tc_stdout, tc_stderr)
def parse_options():
parser = OptionParser(usage="usage: %prog [options] test-case-list.txt")
parser.add_option('-d', '--directory', dest='directory', metavar='DIR',
help='Directory where to look for .guile file',
default=os.environ['HOME'])
parser.add_option('-t', '--timeout', dest='timeout', metavar='TOUT',
help='Timeout for individual test case in sconds',
default=60, type='int')
parser.add_option('-s', '--sleep', dest='sleep', metavar='SLEEP',
help='Sleep for given amount of time in between tests',
default=0, type='float')
(options, args) = parser.parse_args()
if len(args) < 1:
parser.error('You must specify a test list file name')
return options, args
(options, args) = parse_options()
with open(args[0]) as f:
cases = f.read().splitlines()
tcs = []
for c in cases:
res = start_testcase(options.directory, c, timeout=options.timeout)
tcs.append(res)
time.sleep(options.sleep)
ts = TestSuite(TEST, tcs)
print((TestSuite.to_xml_string([ts])))

10
some-sgp-tests.txt Normal file
View File

@ -0,0 +1,10 @@
m3ua-sgp-aspsm-v-003
m3ua-sgp-aspsm-i-001
m3ua-sgp-aspsm-i-002
m3ua-sgp-aspsm-i-003
m3ua-sgp-aspsm-o-001
m3ua-sgp-asptm-v-003
m3ua-sgp-asptm-v-008
m3ua-sgp-asptm-v-011
m3ua-sgp-asptm-i-004
m3ua-sgp-asptm-o-001