tests: Add a test stub for the subchan_demux tests

Tobias has worked on CSD support and Dieter has helped with a CSD
trau fix. This is a stub that should allow to easily write a test
case for the syncing issue observed by Tobias.

Run the tests:
$ make check

In case of failure:
$ vi tests/testsuite.dir/1/testsuite.log

Add the actual content:
$ edit tests/subchan_demux/subchan_demux_test.c

Update the test result:
$ ./tests/subchan_demux/subchan_demux_test > tests/subchan_demux/subchan_demux_test.ok
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 724285c..8704014 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,7 +6,8 @@
 		  e1inp_ipa_bts_test	\
 		  e1inp_hsl_bsc_test	\
 		  e1inp_hsl_bts_test	\
-		  ipa_proxy_test
+		  ipa_proxy_test	\
+		  subchan_demux/subchan_demux_test
 
 e1inp_ipa_bsc_test_SOURCES = e1inp_ipa_bsc_test.c
 e1inp_ipa_bsc_test_LDADD = $(top_builddir)/src/libosmoabis.la \
@@ -29,6 +30,10 @@
 			$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) \
 			$(LIBOSMOVTY_LIBS)
 
+subchan_demux_subchan_demux_test_SOURCES = subchan_demux/subchan_demux_test.c
+subchan_demux_subchan_demux_test_LDADD = $(top_builddir)/src/libosmoabis.la \
+			$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) \
+			$(LIBOSMOVTY_LIBS)
 
 # boilerplate for the tests
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
@@ -49,7 +54,8 @@
                echo '  [$(PACKAGE_URL)])'; \
              } >'$(srcdir)/package.m4'
 
-EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE)
+EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \
+	subchan_demux/subchan_demux_test.ok
 
 TESTSUITE = $(srcdir)/testsuite
 
diff --git a/tests/subchan_demux/subchan_demux_test.c b/tests/subchan_demux/subchan_demux_test.c
new file mode 100644
index 0000000..75c5901
--- /dev/null
+++ b/tests/subchan_demux/subchan_demux_test.c
@@ -0,0 +1,57 @@
+/* Subchan Demux syncing test */
+
+/* (C) 2012 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/abis/subchan_demux.h>
+#include <osmocom/core/utils.h>
+
+#include <stdio.h>
+#include <string.h>
+
+static int data_cb(struct subch_demux *demux, int ch, uint8_t *data, int len, void *p)
+{
+	printf("DATA_CB Channel(%d): %s\n",
+		ch, osmo_hexdump(data, len));
+	return 0;
+}
+
+static void test_csd(void)
+{
+	struct subch_demux demux;
+	memset(&demux, 0, sizeof(demux));
+	subch_demux_init(&demux);
+
+	demux.out_cb = data_cb;
+
+	/* Push data into the demuxer and see what happens. */
+	printf("Testing the csd sync.\n");
+
+}
+
+int main(int argc, char **argv)
+{
+	printf("Testing the subchannel demux.\n");
+
+	/* run the tests */
+	test_csd();
+
+	printf("No crashes.\n");
+	return 0;
+}
diff --git a/tests/subchan_demux/subchan_demux_test.ok b/tests/subchan_demux/subchan_demux_test.ok
new file mode 100644
index 0000000..756f25e
--- /dev/null
+++ b/tests/subchan_demux/subchan_demux_test.ok
@@ -0,0 +1,3 @@
+Testing the subchannel demux.
+Testing the csd sync.
+No crashes.
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 1358534..04193c5 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -10,3 +10,9 @@
 # cat $abs_srcdir/NAME/NAME_test.ok > expout
 # AT_CHECK([$abs_top_builddir/tests/NAME/NAME_test], [], [expout])
 # AT_CLEANUP
+
+AT_SETUP([subchan_demux])
+AT_KEYWORDS([subchan_demux])
+cat $abs_srcdir/subchan_demux/subchan_demux_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/subchan_demux/subchan_demux_test], [], [expout])
+AT_CLEANUP