Compare commits

...

9 Commits

Author SHA1 Message Date
Harald Welte f69fc380b8 params: Use addresses compatible with libosmo-sccp test scripts 2021-12-15 20:58:31 +01:00
Harald Welte a1cbac4453 osmocom test config and test suite 2021-12-15 20:58:31 +01:00
Harald Welte 735518125a add runtest-junitxml.py to export junit-xml from test cases 2021-12-15 20:58:31 +01:00
Harald Welte 050e4977b9 run-sua-test: Avoid having to use a ~/.guile script
Rather, we can specify the path in which the sua-testtool files are
located using the '-d ...' command line argument of run-sua-test.
2021-12-15 20:58:31 +01:00
Harald Welte 77aacbc72d port "guile executable path" hack for non-macos from m3ua-testtool
I think it's a bad idea to make assumptions where the executalbe of the
guile interpreter lives, but in any case, let's at least make
m3ua-testtool and sua-testtool behave consistently here.
2021-12-15 20:52:37 +01:00
Harald Welte acf67d1ec4 Fix copy+paste mistake from m3ua in runner script 2021-12-15 20:52:36 +01:00
Michael Tuexen 767e20ba7d Only use colors when writing to tty 2021-12-12 19:16:07 +01:00
Michael Tuexen 14073f34be Allow sleeping 2021-12-12 19:11:43 +01:00
Michael Tuexen fe670b16df Use sh instead of tcsh 2021-12-12 19:04:45 +01:00
6 changed files with 165 additions and 28 deletions

View File

@ -26,7 +26,7 @@
;;; $Id: dotguile,v 1.1 2011/03/20 16:48:30 tuexen Exp $
;;; Change the following line to reflect where the files are located.
(define dir "/Users/tuexen/Documents/sua-testtool/")
(define dir "")
(define files (list "common.scm"
"sua.scm"
"sua-param-testtool-asp.scm"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env tcsh
#!/usr/bin/env sh
#
# Copyright (c) 2011 Michael Tuexen
# All rights reserved.
@ -27,9 +27,12 @@
# $Id: run-some-sua-asp-tests,v 1.3 2011/03/20 16:53:06 tuexen Exp $
#
set timeout = 10
set testcases = ( )
timeout=10
sleeptime=1
testcases=
foreach testcase ($testcases)
(runm3uatest -t $timeout $testcase > /dev/tty) >& /dev/null
end
for testcase in $testcases
do
run-sua-test -t $timeout $testcase 2> /dev/null
sleep $sleeptime
done

View File

@ -1,4 +1,4 @@
#!/usr/bin/env tcsh
#!/usr/bin/env sh
#
# Copyright (c) 2011 Michael Tuexen
# All rights reserved.
@ -27,9 +27,37 @@
# $Id: run-some-sua-sgp-tests,v 1.3 2011/03/20 16:53:06 tuexen Exp $
#
set timeout = 10
set testcases = ( )
timeout=10
sleeptime=1
testcases='sua-sgp-aspsm-v-02
sua-sgp-aspsm-v-03
sua-sgp-aspsm-i-01
sua-sgp-aspsm-i-02
sua-sgp-aspsm-i-04
sua-sgp-aspsm-o-01
sua-sgp-aspsm-o-02
sua-sgp-aspsm-o-03
sua-sgp-asptm-v-01
sua-sgp-asptm-v-02
sua-sgp-asptm-v-04
sua-sgp-asptm-v-05
sua-sgp-asptm-v-06
sua-sgp-asptm-v-07
sua-sgp-asptm-i-01
sua-sgp-asptm-i-03
sua-sgp-asptm-i-04
sua-sgp-asptm-i-05
sua-sgp-asptm-i-06
sua-sgp-asptm-i-08
sua-sgp-asptm-o-01
sua-sgp-asptm-o-02
sua-sgp-mtr-i-01
sua-sgp-mtr-i-02
sua-sgp-mtr-i-03
sua-sgp-mtr-i-04'
foreach testcase ($testcases)
(runm3uatest -t $timeout $testcase > /dev/tty) >& /dev/null
end
for testcase in $testcases
do
./run-sua-test -d . -t $timeout $testcase 2> /dev/null
sleep $sleeptime
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,16 +94,18 @@ 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;
}
if ((pid = fork()) == 0) {
execlp("/usr/local/bin/guile", "guile",
"-c", command,
(char *)0);
#if defined(__APPLE__) || defined(__FreeBSD__)
execlp("/usr/local/bin/guile", "guile", "-L", dir, "-c", command, NULL);
#else
execlp("/usr/bin/guile", "guile", "-L", dir, "-c", command, NULL);
#endif
fprintf(stderr, "%s\n", "Couln't start guile.");
}
printf("Test %-40.40s ", argv[optind]);

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='sua'
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])))

View File

@ -26,25 +26,25 @@
;;; $Id: sua-param-testtool-sgp.scm,v 1.2 2011/03/21 22:18:29 tuexen Exp $
;;; Define a transport address of the system under test
(define sut-addr "127.0.0.1")
(define sut-addr "172.18.0.200")
(define sut-port sua-port)
(define sut-port-1 sua-port)
(define sut-port-2 (1+ sua-port))
;;; Define the transport address of the tester
(define tester-addr "127.0.0.1")
(define tester-addr "172.18.0.3")
(define tester-port 0)
(define tester-port-1 3000)
(define tester-port-2 3001)
;;; Define the point code of the SUT
(define sut-pc 4001)
(define sut-pc 1)
;;; Define the SSN of the SUT
(define sut-ssn 3)
;;; Define the point code of the tester
(define tester-pc 100)
(define tester-pc 24)
(define tester-pc-1 100)
(define tester-pc-2 101)
(define tester-invalid-pc 102)
@ -77,8 +77,8 @@
(define sccp-test-message (list))
;;; Define traffic-type-mode
;;;(define traffic-mode sua-traffic-mode-type-override)
(define traffic-mode sua-traffic-mode-type-loadshare)
(define traffic-mode sua-traffic-mode-type-override)
;(define traffic-mode sua-traffic-mode-type-loadshare)
;;;(define traffic-mode sua-traffic-mode-type-broadcast)
(define asp-up-message-parameters (list))