Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()

In 2015, Jacob moved/copied related functions to libosmocore, but
for some reason didn't remove the copies here.  Let's follow-up on
that and remove duplicated code.

The libosmocore commit introducing osmo_apn_to_str() was
8114294bf29ac6e44822c0ae43d4b0819f11b022

Change-Id: I7315ffcbed8a54cca2056f313bb7783ad82d0ee9
diff --git a/tests/gprs/gprs_test.c b/tests/gprs/gprs_test.c
index ff77404..aac9bb8 100644
--- a/tests/gprs/gprs_test.c
+++ b/tests/gprs/gprs_test.c
@@ -48,101 +48,6 @@
 	ASSERT_FALSE(nu_is_retransmission(479, 511)); // wrapped
 }
 
-static void apn_round_trip(const uint8_t *input, size_t len, const char *wanted_output)
-{
-	char output[len ? len : 1];
-	uint8_t encoded[len + 50];
-	char *out_str;
-	int enc_len;
-
-	/* decode and verify we have what we want */
-	out_str = gprs_apn_to_str(output, input, len);
-	OSMO_ASSERT(out_str);
-	OSMO_ASSERT(out_str == &output[0]);
-	OSMO_ASSERT(strlen(out_str) == strlen(wanted_output));
-	OSMO_ASSERT(strcmp(out_str, wanted_output) == 0);
-
-	/* encode and verify it */
-	if (len != 0) {
-		enc_len = gprs_str_to_apn(encoded, ARRAY_SIZE(encoded), wanted_output);
-		OSMO_ASSERT(enc_len == len);
-		OSMO_ASSERT(memcmp(encoded, input, enc_len) == 0);
-	} else {
-		enc_len = gprs_str_to_apn(encoded, 0, wanted_output);
-		OSMO_ASSERT(enc_len == -1);
-	}
-}
-
-static void test_gsm_03_03_apn(void)
-{
-
-	{
-		/* test invalid writes */
-		const uint8_t ref[10] = { 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF };
-		uint8_t output[10];
-		int enc_len;
-
-		memcpy(output, ref, ARRAY_SIZE(output));
-		enc_len = gprs_str_to_apn(output, 0, "");
-		OSMO_ASSERT(enc_len == -1);
-		OSMO_ASSERT(memcmp(ref, output, ARRAY_SIZE(ref)) == 0);
-
-		memcpy(output, ref, ARRAY_SIZE(output));
-		enc_len = gprs_str_to_apn(output, 0, "foo");
-		OSMO_ASSERT(enc_len == -1);
-		OSMO_ASSERT(memcmp(ref, output, ARRAY_SIZE(ref)) == 0);
-
-		memcpy(output, ref, ARRAY_SIZE(output));
-		enc_len = gprs_str_to_apn(output, 1, "foo");
-		OSMO_ASSERT(enc_len == -1);
-		OSMO_ASSERT(memcmp(ref + 1, output + 1, ARRAY_SIZE(ref) - 1) == 0);
-
-		memcpy(output, ref, ARRAY_SIZE(output));
-		enc_len = gprs_str_to_apn(output, 2, "foo");
-		OSMO_ASSERT(enc_len == -1);
-		OSMO_ASSERT(memcmp(ref + 2, output + 2, ARRAY_SIZE(ref) - 2) == 0);
-
-		memcpy(output, ref, ARRAY_SIZE(output));
-		enc_len = gprs_str_to_apn(output, 3, "foo");
-		OSMO_ASSERT(enc_len == -1);
-		OSMO_ASSERT(memcmp(ref + 3, output + 3, ARRAY_SIZE(ref) - 3) == 0);
-	}
-
-	{
-		/* single empty label */
-		uint8_t input[] = { 0x0 };
-		const char *output = "";
-		apn_round_trip(input, ARRAY_SIZE(input), output);
-	}
-
-	{
-		/* no label */
-		uint8_t input[] = { };
-		const char *output = "";
-		apn_round_trip(input, ARRAY_SIZE(input), output);
-	}
-
-	{
-		/* single label with A */
-		uint8_t input[] = { 0x1, 65 };
-		const char *output = "A";
-		apn_round_trip(input, ARRAY_SIZE(input), output);
-		OSMO_ASSERT(gprs_apn_to_str(NULL, input, ARRAY_SIZE(input) - 1) == NULL);
-	}
-
-	{
-		uint8_t input[] = { 0x3, 65, 66, 67, 0x2, 90, 122 };
-		const char *output = "ABC.Zz";
-		char tmp[strlen(output) + 1];
-		apn_round_trip(input, ARRAY_SIZE(input), output);
-		OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 1) == NULL);
-		OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 2) == NULL);
-		OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 4) == NULL);
-		OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 5) == NULL);
-		OSMO_ASSERT(gprs_apn_to_str(tmp, input, ARRAY_SIZE(input) - 6) == NULL);
-	}
-}
-
 static void test_gprs_timer_enc_dec(void)
 {
 	int i, u, secs, tmr;
@@ -228,7 +133,6 @@
 	osmo_init_logging(&info);
 
 	test_8_4_2();
-	test_gsm_03_03_apn();
 	test_gprs_timer_enc_dec();
 
 	printf("Done.\n");
diff --git a/tests/gtphub/Makefile.am b/tests/gtphub/Makefile.am
index 5c834b7..f2a6b88 100644
--- a/tests/gtphub/Makefile.am
+++ b/tests/gtphub/Makefile.am
@@ -8,6 +8,7 @@
 	-ggdb3 \
 	$(LIBOSMOCORE_CFLAGS) \
 	$(LIBOSMOABIS_CFLAGS) \
+	$(LIBOSMOGSM_CFLAGS) \
 	$(LIBGTP_CFLAGS) \
 	$(NULL)
 
@@ -37,6 +38,7 @@
 	$(top_builddir)/src/gprs/gtphub.o \
 	$(top_builddir)/src/gprs/gprs_utils.o \
 	$(LIBOSMOCORE_LIBS) \
+	$(LIBOSMOGSM_LIBS) \
 	$(LIBGTP_LIBS) \
 	-lrt \
 	$(NULL)