summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-11-20 12:02:14 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-11-20 12:11:57 +0100
commit72df7f09ecb0dc0bb6352aa9ec30728ba896341d (patch)
tree5c8f38e8030708a1ff269704b8e2b8d7ee3cf6e2
parentebd4f4563c819e36544759aef85fc6836c244c88 (diff)
tests: Run the existing tests with GNU Autotest
SCCP: Use DST/SRC Ref instead of the pointer value to create stable releases.
-rw-r--r--.gitignore6
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am39
-rw-r--r--tests/m2ua/Makefile.am2
-rw-r--r--tests/m2ua/m2ua_test.c6
-rw-r--r--tests/m2ua/m2ua_test.ok3
-rwxr-xr-xtests/missing376
-rw-r--r--tests/mtp/Makefile.am2
-rw-r--r--tests/mtp/mtp_parse_test.c4
-rw-r--r--tests/mtp/mtp_parse_test.ok2
-rw-r--r--tests/sccp/Makefile.am2
-rw-r--r--tests/sccp/sccp_test.c29
-rw-r--r--tests/sccp/sccp_test.ok86
-rw-r--r--tests/testsuite.at20
14 files changed, 572 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index d5c4bc9..65fb1ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ autom4te.cache/
config.log
config.status
configure
+configure.lineno
depcomp
install-sh
missing
@@ -51,6 +52,11 @@ tests/sccp/sccp_test
tests/sms/sms_test
tests/timer/timer_test
+tests/atconfig
+tests/package.m4
+tests/testsuite
+tests/testsuite.log
+
*.pc
config.*
diff --git a/configure.ac b/configure.ac
index b16b1f3..89390b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,7 @@ AC_INIT([libosmo-sccp],
[openbsc-devel@lists.openbsc.org])
AM_INIT_AUTOMAKE([dist-bzip2])
+AC_CONFIG_TESTDIR(tests)
dnl kernel style compile messages
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 882d1e2..ae9b4dd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1 +1,40 @@
SUBDIRS = sccp mtp m2ua
+
+# The `:;' works around a Bash 3.2 bug when the output is not writeable.
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME],' && \
+ echo ' [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME],' && \
+ echo ' [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION],' && \
+ echo ' [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING],' && \
+ echo ' [$(PACKAGE_STRING)])' && \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \
+ echo ' [$(PACKAGE_BUGREPORT)])'; \
+ echo 'm4_define([AT_PACKAGE_URL],' && \
+ echo ' [$(PACKAGE_URL)])'; \
+ } >'$(srcdir)/package.m4'
+
+EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) missing
+TESTSUITE = $(srcdir)/testsuite
+
+check-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+
+installcheck-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
+ $(TESTSUITEFLAGS)
+
+clean-local:
+ test ! -f '$(TESTSUITE)' || \
+ $(SHELL) '$(TESTSUITE)' --clean
+ $(RM) -f atconfig
+
+AUTOM4TE = $(SHELL) $(srcdir)/missing --run autom4te
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4
+ $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+ mv $@.tmp $@
diff --git a/tests/m2ua/Makefile.am b/tests/m2ua/Makefile.am
index 2795d64..0eb8302 100644
--- a/tests/m2ua/Makefile.am
+++ b/tests/m2ua/Makefile.am
@@ -1,6 +1,8 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall
AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
+EXTRA_DIST = m2ua_test.ok
+
noinst_PROGRAMS = m2ua_test
m2ua_test_SOURCES = m2ua_test.c
m2ua_test_LDADD = $(top_builddir)/src/libm2ua.a $(LIBOSMOCORE_LIBS)
diff --git a/tests/m2ua/m2ua_test.c b/tests/m2ua/m2ua_test.c
index c6c36f8..d629ad5 100644
--- a/tests/m2ua/m2ua_test.c
+++ b/tests/m2ua/m2ua_test.c
@@ -51,6 +51,8 @@ static void test_asp_up(void)
struct msgb *msg = m2ua_to_msg(m2u);
const uint8_t res[] = { 0xac, 0x10, 0x01, 0x51 };
+ printf("Testing ASP UP parsing.\n");
+
if (msg->len != ARRAY_SIZE(asp_up)) {
printf("Got %d wanted %d\n", msg->len, ARRAY_SIZE(asp_up));
FAIL("Wrong size");
@@ -79,6 +81,8 @@ static void test_data(void)
struct m2ua_msg *m2u = m2ua_from_msg(ARRAY_SIZE(data), data);
struct msgb *msg = m2ua_to_msg(m2u);
+ printf("Testing parsing of data.\n");
+
if (msg->len != ARRAY_SIZE(data)) {
printf("Got %d wanted %d\n", msg->len, ARRAY_SIZE(data));
FAIL("Wrong size");
@@ -105,5 +109,7 @@ int main(int argc, char **argv)
{
test_asp_up();
test_data();
+
+ printf("All tests passed.\n");
return 0;
}
diff --git a/tests/m2ua/m2ua_test.ok b/tests/m2ua/m2ua_test.ok
new file mode 100644
index 0000000..ab74b86
--- /dev/null
+++ b/tests/m2ua/m2ua_test.ok
@@ -0,0 +1,3 @@
+Testing ASP UP parsing.
+Testing parsing of data.
+All tests passed.
diff --git a/tests/missing b/tests/missing
new file mode 100755
index 0000000..28055d2
--- /dev/null
+++ b/tests/missing
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ # Exit code 63 means version mismatch. This often happens
+ # when the user try to use an ancient version of a tool on
+ # a file that requires a minimum version. In this case we
+ # we should proceed has if the program had been absent, or
+ # if --run hadn't been passed.
+ if test $? = 63; then
+ run=:
+ msg="probably too old"
+ fi
+ ;;
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+ exit $?
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+ s/^gnu-//; t
+ s/^gnu//; t
+ s/^g//; t'`
+
+# Now exit if we have it, but it failed. Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program). This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+ lex*|yacc*)
+ # Not GNU programs, they don't have --version.
+ ;;
+
+ tar*)
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ exit 1
+ fi
+ ;;
+
+ *)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ # Could not run --version or --help. This is probably someone
+ # running `$TOOL --version' or `$TOOL --help' to check whether
+ # $TOOL exists and not knowing $TOOL uses missing.
+ exit 1
+ fi
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+ aclocal*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case $f in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te*)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison*|yacc*)
+ echo 1>&2 "\
+WARNING: \`$1' $msg. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f y.tab.h; then
+ echo >y.tab.h
+ fi
+ if test ! -f y.tab.c; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex*|flex*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f lex.yy.c; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit $?
+ fi
+ ;;
+
+ makeinfo*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ # The file to touch is that specified with -o ...
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -z "$file"; then
+ # ... or it is the one specified with @setfilename ...
+ infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
+ # ... or it is derived from the source name (dir/f.texi becomes f.info)
+ test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+ fi
+ # If the file does not exist, the user really needs makeinfo;
+ # let's fail without touching anything.
+ test -f $file || exit 1
+ touch $file
+ ;;
+
+ tar*)
+ shift
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case $firstarg in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case $firstarg in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequisites for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/tests/mtp/Makefile.am b/tests/mtp/Makefile.am
index 1f364b6..9e9292c 100644
--- a/tests/mtp/Makefile.am
+++ b/tests/mtp/Makefile.am
@@ -1,4 +1,6 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall
noinst_PROGRAMS = mtp_parse_test
+EXTRA_DIST = mtp_parse_test.ok
+
mtp_parse_test_SOURCES = mtp_parse_test.c
diff --git a/tests/mtp/mtp_parse_test.c b/tests/mtp/mtp_parse_test.c
index 434f825..0e38077 100644
--- a/tests/mtp/mtp_parse_test.c
+++ b/tests/mtp/mtp_parse_test.c
@@ -583,6 +583,8 @@ int main(int argc, char **argv)
uint32_t addr;
int i;
+ printf("Basic MTP Structure testing.\n");
+
/* set the addresses here due big endian MTP_ADDRESS macro */
tests[0].hdr.addr = MTP_ADDR(0x00, 136, 91);
tests[1].hdr.addr = MTP_ADDR(0x00, 136, 91);
@@ -624,6 +626,6 @@ int main(int argc, char **argv)
}
}
- fprintf(stderr, "SUCCESS\n");
+ printf("All tests passed.\n");
return 0;
}
diff --git a/tests/mtp/mtp_parse_test.ok b/tests/mtp/mtp_parse_test.ok
new file mode 100644
index 0000000..cee2aeb
--- /dev/null
+++ b/tests/mtp/mtp_parse_test.ok
@@ -0,0 +1,2 @@
+Basic MTP Structure testing.
+All tests passed.
diff --git a/tests/sccp/Makefile.am b/tests/sccp/Makefile.am
index 9392363..90790a3 100644
--- a/tests/sccp/Makefile.am
+++ b/tests/sccp/Makefile.am
@@ -1,6 +1,8 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS)
+EXTRA_DIST = sccp_test.ok
+
noinst_PROGRAMS = sccp_test
sccp_test_SOURCES = sccp_test.c $(top_srcdir)/src/sccp.c
diff --git a/tests/sccp/sccp_test.c b/tests/sccp/sccp_test.c
index 96a012b..7cff5d0 100644
--- a/tests/sccp/sccp_test.c
+++ b/tests/sccp/sccp_test.c
@@ -1,8 +1,8 @@
/*
* SCCP testing code
*
- * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2009 by On-Waves
+ * (C) 2009,2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2009,2011 by On-Waves
*
* All Rights Reserved
*
@@ -506,6 +506,8 @@ static void sccp_udt_write_cb(struct sccp_connection *conn, struct msgb *data, v
static void test_sccp_system(void)
{
+ printf("Testing SCCP System\n");
+
sccp_system_init(sccp_write_cb, NULL);
sccp_set_read(&sccp_ssn_bssap, sccp_read_cb, NULL);
sccp_connection_set_incoming(&sccp_ssn_bssap, sccp_accept_cb, NULL);
@@ -531,6 +533,8 @@ static void test_sccp_system(void)
/* test sending of udt */
static void test_sccp_send_udt(void)
{
+ printf("Testing send UDT\n");
+
sccp_system_init(sccp_udt_write_cb, NULL);
sccp_set_read(NULL, NULL, NULL);
sccp_connection_set_incoming(NULL, NULL, NULL);
@@ -582,6 +586,8 @@ static void test_sccp_udt_communication(void)
struct msgb *data;
unsigned int *val;
+ printf("Testing UDT Communication.\n");
+
sccp_system_init(sccp_write_loop, NULL);
sccp_set_read(&sccp_ssn_bssap, sccp_udt_read, NULL);
sccp_connection_set_incoming(NULL, NULL, NULL);
@@ -652,7 +658,8 @@ static void sccp_conn_in_data(struct sccp_connection *conn, struct msgb *msg, un
static int sccp_conn_accept(struct sccp_connection *conn, void *ctx)
{
- printf("\taccept: %p\n", conn);
+ printf("\taccept: srcref(%u)\n",
+ sccp_src_ref_to_int(&conn->source_local_reference));
conn->state_cb = sccp_conn_in_state;
conn->data_cb = sccp_conn_in_data;
@@ -666,7 +673,9 @@ static int sccp_conn_accept(struct sccp_connection *conn, void *ctx)
/* callbacks for the outgoing side */
static void sccp_conn_out_state(struct sccp_connection *conn, int old_state)
{
- printf("\toutgoing: %p %d -> %d\n", conn, old_state, conn->connection_state);
+ printf("\toutgoing: dstref(%u) %d -> %d\n",
+ sccp_src_ref_to_int(&conn->destination_local_reference),
+ old_state, conn->connection_state);
if (conn->connection_state >= SCCP_CONNECTION_STATE_RELEASE_COMPLETE) {
if (conn == outgoing_con) {
@@ -679,7 +688,8 @@ static void sccp_conn_out_state(struct sccp_connection *conn, int old_state)
static void sccp_conn_out_data(struct sccp_connection *conn, struct msgb *msg, unsigned int len)
{
++outgoing_data;
- printf("\toutgoing data: %p %d\n", conn, len);
+ printf("\toutgoing data: dstref(%u) %d\n",
+ sccp_src_ref_to_int(&conn->destination_local_reference), len);
if (len != 4)
FAIL("Length of packet is wrong: %u %u\n", msgb_l3len(msg), len);
@@ -761,6 +771,8 @@ static void do_test_sccp_connection(const struct connection_test *test)
static void test_sccp_connection(void)
{
+ printf("Testing SCCP connection.\n");
+
sccp_system_init(sccp_write_loop, NULL);
sccp_set_read(NULL, NULL, NULL);
sccp_connection_set_incoming(&sccp_ssn_bssap, sccp_conn_accept, NULL);
@@ -819,6 +831,8 @@ static void test_sccp_system_crash(void)
static void test_sccp_parsing(void)
{
+ printf("Test SCCP Parsing.\n");
+
for (current_test = 0; current_test < ARRAY_SIZE(parse_result); ++current_test) {
struct msgb *msg;
struct sccp_parse_result result;
@@ -953,6 +967,8 @@ static void test_sccp_address(void)
int i, ret;
struct msgb *msg = msgb_alloc(128, "sccp-addr");
+ printf("Test SCCP Address\n");
+
for (i = 0; i < ARRAY_SIZE(sccp_addr_tst); ++i) {
msgb_reset(msg);
ret = sccp_create_sccp_addr(msg, sccp_addr_tst[i].addr);
@@ -993,6 +1009,8 @@ int main(int argc, char **argv)
stderr_target = log_target_create_stderr();
log_add_target(stderr_target);
+ printf("Testing SCCP handling.\n");
+
sccp_set_log_area(0);
test_sccp_system();
@@ -1002,6 +1020,7 @@ int main(int argc, char **argv)
test_sccp_system_crash();
test_sccp_parsing();
test_sccp_address();
+ printf("All tests passed.\n");
return 0;
}
diff --git a/tests/sccp/sccp_test.ok b/tests/sccp/sccp_test.ok
new file mode 100644
index 0000000..2b55a16
--- /dev/null
+++ b/tests/sccp/sccp_test.ok
@@ -0,0 +1,86 @@
+Testing SCCP handling.
+Testing SCCP System
+Testing packet: 0
+Testing packet: 1
+Testing packet: 2
+Testing packet: 3
+Testing packet: 4
+Testing packet: 5
+Testing packet: 6
+Testing send UDT
+Testing packet: 0
+Testing packet: 1
+Testing UDT Communication.
+Testing SCCP connection.
+Testing 0 refuse: 1 with_data: 0
+ outgoing: dstref(0) 0 -> 1
+ accept: srcref(0)
+ outgoing: dstref(0) 1 -> 6
+ income: 0 -> 6
+Testing 1 refuse: 1 with_data: 1
+ outgoing: dstref(0) 0 -> 1
+ accept: srcref(0)
+ outgoing: dstref(0) 1 -> 6
+ income: 0 -> 6
+Testing 2 refuse: 0 with_data: 0
+ outgoing: dstref(0) 0 -> 1
+ accept: srcref(0)
+ outgoing: dstref(196612) 1 -> 3
+ income: 0 -> 3
+ Writing test data2
+ incoming data: 4
+ Returning data3
+ outgoing data: dstref(196612) 4
+ outgoing: dstref(196612) 3 -> 4
+ outgoing: dstref(196612) 4 -> 5
+ income: 3 -> 5
+Testing 3 refuse: 0 with_data: 1
+ outgoing: dstref(0) 0 -> 1
+ accept: srcref(0)
+ outgoing: dstref(196614) 1 -> 3
+ income: 0 -> 3
+ incoming data: 4
+ Writing test data2
+ incoming data: 4
+ Returning data3
+ outgoing data: dstref(196614) 4
+ outgoing: dstref(196614) 3 -> 4
+ outgoing: dstref(196614) 4 -> 5
+ income: 3 -> 5
+Testing 4 refuse: 0 with_data: 0
+ outgoing: dstref(0) 0 -> 1
+ accept: srcref(0)
+ outgoing: dstref(196616) 1 -> 3
+ income: 0 -> 3
+ Writing test data2
+ incoming data: 4
+ Returning data3
+ outgoing data: dstref(196616) 4
+ income: 3 -> 4
+ income: 4 -> 5
+ outgoing: dstref(196616) 3 -> 5
+Testing 5 refuse: 0 with_data: 1
+ outgoing: dstref(0) 0 -> 1
+ accept: srcref(0)
+ outgoing: dstref(196618) 1 -> 3
+ income: 0 -> 3
+ incoming data: 4
+ Writing test data2
+ incoming data: 4
+ Returning data3
+ outgoing data: dstref(196618) 4
+ income: 3 -> 4
+ income: 4 -> 5
+ outgoing: dstref(196618) 3 -> 5
+trying to provoke a crash with invalid input
+Testing packet: 0
+Testing packet: 1
+Testing packet: 2
+Testing packet: 3
+Testing packet: 4
+Testing packet: 5
+Testing packet: 6
+survived
+Test SCCP Parsing.
+Test SCCP Address
+All tests passed.
diff --git a/tests/testsuite.at b/tests/testsuite.at
new file mode 100644
index 0000000..8907ffa
--- /dev/null
+++ b/tests/testsuite.at
@@ -0,0 +1,20 @@
+AT_INIT
+AT_BANNER([Regression tests.])
+
+AT_SETUP([m2ua])
+AT_KEYWORDS([m2ua])
+cat $abs_srcdir/m2ua/m2ua_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/m2ua/m2ua_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([mtp])
+AT_KEYWORDS([mtp])
+cat $abs_srcdir/mtp/mtp_parse_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/mtp/mtp_parse_test], [], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([sccp])
+AT_KEYWORDS([sccp])
+cat $abs_srcdir/sccp/sccp_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/sccp/sccp_test], [], [expout], [ignore])
+AT_CLEANUP