factor out some common shared test init code
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 77b419a..3970f60 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -15,13 +15,13 @@
 test_helpers_SOURCES = $(HELPER_FILES) test-helpers.c
 test_helpers_LDADD = $(COMMON_LIBS)
 
-test_hnbap_SOURCES = $(HELPER_FILES) $(top_builddir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c test-hnbap.c
+test_hnbap_SOURCES = $(HELPER_FILES) $(top_builddir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c test-hnbap.c test_common.c
 test_hnbap_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a
 
-hnb_test_SOURCES = $(HELPER_FILES) $(HNBAP_FILES) $(RUA_FILES) $(RANAP_FILES) hnb-test.c rua_helper.c
+hnb_test_SOURCES = $(HELPER_FILES) $(HNBAP_FILES) $(RUA_FILES) $(RANAP_FILES) hnb-test.c rua_helper.c test_common.c
 hnb_test_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a $(top_builddir)/src/rua/libosmo-asn1-rua.a $(top_builddir)/src/ranap/libosmo-asn1-ranap.a
 
-test_ranap_SOURCES = $(HELPER_FILES) $(RANAP_FILES) test-ranap.c
+test_ranap_SOURCES = $(HELPER_FILES) $(RANAP_FILES) test-ranap.c test_common.c
 test_ranap_LDADD = $(COMMON_LIBS) $(top_builddir)/src/ranap/libosmo-asn1-ranap.a
 
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index 4d042e8..cd07d7c 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -52,11 +52,11 @@
 #include "rua_helper.h"
 #include "asn1helpers.h"
 #include "iu_helpers.h"
+#include "test_common.h"
 
 #include "ranap_msg_factory.h"
 
 static void *tall_hnb_ctx;
-void *talloc_asn1_ctx;
 
 struct hnb_test g_hnb_test = {
 	.gw_port = IUH_DEFAULT_SCTP_PORT,
@@ -64,7 +64,6 @@
 
 struct msgb *rua_new_udt(struct msgb *inmsg);
 
-
 static int hnb_test_ue_de_register_tx(struct hnb_test *hnb_test)
 {
 	struct msgb *msg;
@@ -563,12 +562,9 @@
 {
 	int rc;
 
-	tall_hnb_ctx = talloc_named_const(NULL, 0, "hnb_context");
-	talloc_asn1_ctx = talloc_named_const(NULL, 0, "asn1_context");
+	test_common_init();
 
-	rc = osmo_init_logging(&hnb_test_log_info);
-	if (rc < 0)
-		exit(1);
+	tall_hnb_ctx = talloc_named_const(NULL, 0, "hnb_context");
 
 	vty_init(&vty_info);
 	hnbtest_vty_init();
diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c
index 7773b97..0005fe1 100644
--- a/src/tests/test-hnbap.c
+++ b/src/tests/test-hnbap.c
@@ -24,14 +24,14 @@
 
 #include "hnbap_common.h"
 #include "hnbap_ies_defs.h"
+#include "test_common.h"
 
 #include <assert.h>
 #define ASSERT(x)	assert(x)
 
 #include <osmocom/core/utils.h>
 #include <osmocom/core/logging.h>
-
-void *talloc_asn1_ctx;
+#include <osmocom/core/application.h>
 
 static const unsigned char hnbap_reg_req[] = {
 0x00, 0x01,
@@ -161,21 +161,13 @@
 
 }
 
-
-static const struct log_info osmo_log = {
-	.cat = NULL,
-	.num_cat = 0,
-};
-
 int main(int argc, char **argv)
 {
 	int rc;
 
-	rc = osmo_init_logging(&osmo_log);
-	if (rc < 0) {
-		printf("Error in init logging\n");
-		return -1;
-	}
+	test_common_init();
+	log_set_log_level(osmo_stderr_target, LOGL_INFO);
+
 
 	test_asn1_decoding();
 
diff --git a/src/tests/test-ranap.c b/src/tests/test-ranap.c
index 7662473..f58c8c8 100644
--- a/src/tests/test-ranap.c
+++ b/src/tests/test-ranap.c
@@ -28,32 +28,14 @@
 #include "ranap_ies_defs.h"
 #include "ranap_msg_factory.h"
 
+#include "test_common.h"
+
 #include "hnbgw.h"
 
-void *talloc_asn1_ctx;
 int asn1_xer_print = 1;
 
 extern void *tall_msgb_ctx;
 
-static const struct log_info_cat log_cat[] = {
-	[DMAIN] = {
-		.name = "DMAIN", .loglevel = LOGL_INFO, .enabled = 1,
-		.color = "",
-		.description = "Main program",
-	},
-	[DHNBAP] = {
-		.name = "DHNBAP", .loglevel = LOGL_DEBUG, .enabled = 1,
-		.color = "",
-		.description = "Home Node B Application Part",
-	},
-};
-
-static const struct log_info hnbgw_log_info = {
-	.cat = log_cat,
-	.num_cat = ARRAY_SIZE(log_cat),
-};
-
-
 int main(int argc, char **argv)
 {
 	uint8_t nas_buf[] = { 0xaa, 0xbb, 0xcc };
@@ -70,12 +52,9 @@
 
 	//asn_debug = 1;
 
-	talloc_asn1_ctx = talloc_named_const(NULL, 1, "ASN");
 	msgb_set_talloc_ctx(talloc_named_const(NULL, 1, "msgb"));
 
-	rc = osmo_init_logging(&hnbgw_log_info);
-	if (rc < 0)
-		exit(1);
+	test_common_init();
 
 	for (i = 0; i < 1; i++) {
 		printf("\n==> DIRECT TRANSFER\n");
diff --git a/src/tests/test_common.c b/src/tests/test_common.c
new file mode 100644
index 0000000..d6c1351
--- /dev/null
+++ b/src/tests/test_common.c
@@ -0,0 +1,87 @@
+/* Common osmo-iuh test stub code */
+
+/* (C) 2015 by Sysmocom s.f.m.c. GmbH
+ * Author: Daniel Willmann <dwillmann@sysmocom.de>
+ * 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 <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/sctp.h>
+#include <arpa/inet.h>
+
+#include <osmocom/core/application.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/logging.h>
+
+#include "hnbgw.h"
+
+void *talloc_asn1_ctx;
+
+static const struct log_info_cat log_cat[] = {
+	[DMAIN] = {
+		.name = "DMAIN", .loglevel = LOGL_INFO, .enabled = 1,
+		.color = "",
+		.description = "Main program",
+	},
+	[DHNBAP] = {
+		.name = "DHNBAP", .loglevel = LOGL_DEBUG, .enabled = 1,
+		.color = "",
+		.description = "Home Node B Application Part",
+	},
+	[DRANAP] = {
+		.name = "RANAP", .loglevel = LOGL_DEBUG, .enabled = 1,
+		.color = "",
+		.description = "RAN Application Part",
+	},
+	[DRUA] = {
+		.name = "RUA", .loglevel = LOGL_DEBUG, .enabled = 1,
+		.color = "",
+		.description = "RANAP User Adaptation",
+	},
+	[DSUA] = {
+		.name = "SUA", .loglevel = LOGL_DEBUG, .enabled = 1,
+		.color = "",
+		.description = "SCCP User Adaptation",
+	},
+};
+
+static const struct log_info test_log_info = {
+	.cat = log_cat,
+	.num_cat = ARRAY_SIZE(log_cat),
+};
+
+int test_common_init(void)
+{
+	int rc;
+
+	talloc_asn1_ctx = talloc_named_const(NULL, 0, "asn1_context");
+
+	rc = osmo_init_logging(&test_log_info);
+	if (rc < 0)
+		exit(1);
+
+}
diff --git a/src/tests/test_common.h b/src/tests/test_common.h
new file mode 100644
index 0000000..1af1abd
--- /dev/null
+++ b/src/tests/test_common.h
@@ -0,0 +1,3 @@
+#pragma once
+
+int test_common_init(void);