laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-iuh/+/26856 )
Change subject: add unittest for ranap_transp_layer_addr_decode()
......................................................................
add unittest for ranap_transp_layer_addr_decode()
The function ranap_transp_layer_addr_decode() lacks a unit test. Lets
add one.
Change-Id: I6d7427dc07c858a8dd76c1fb536ec3df3d96f1b1
---
M src/tests/test-helpers.c
M src/tests/test-helpers.ok
2 files changed, 34 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/tests/test-helpers.c b/src/tests/test-helpers.c
index 96540dc..5b5004a 100644
--- a/src/tests/test-helpers.c
+++ b/src/tests/test-helpers.c
@@ -319,6 +319,34 @@
OSMO_ASSERT(tli == NULL);
}
+void test_ranap_transp_layer_addr_decode(void)
+{
+ int rc;
+ char addr[100];
+ RANAP_TransportLayerAddress_t trasp_layer_addr = { 0 };
+ uint8_t encoded_addr_x213_nsap[] = {
+ 0x35, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00 };
+ uint8_t encoded_addr[] = { 0x01, 0x02, 0x03, 0x04 };
+
+ printf("Testing function ranap_transp_layer_addr_decode()\n");
+
+ printf(" ipv4, x213_nsap\n");
+ trasp_layer_addr.buf = encoded_addr_x213_nsap;
+ trasp_layer_addr.size = sizeof(encoded_addr_x213_nsap);
+ rc = ranap_transp_layer_addr_decode(addr, sizeof(addr), &trasp_layer_addr);
+ printf(" addr=%s\n", addr);
+ OSMO_ASSERT(rc == 0);
+
+ printf(" ipv4\n");
+ trasp_layer_addr.buf = encoded_addr;
+ trasp_layer_addr.size = sizeof(encoded_addr);
+ rc = ranap_transp_layer_addr_decode(addr, sizeof(addr), &trasp_layer_addr);
+ printf(" addr=%s\n", addr);
+ OSMO_ASSERT(rc == 0);
+}
+
int main(int argc, char **argv)
{
asn1_xer_print = 0;
@@ -331,6 +359,7 @@
test_ranap_common();
test_ranap_new_transp_info_gtp();
test_ranap_new_transp_info_rtp();
+ test_ranap_transp_layer_addr_decode();
test_common_cleanup();
return 0;
diff --git a/src/tests/test-helpers.ok b/src/tests/test-helpers.ok
index 049fbb4..fe08287 100644
--- a/src/tests/test-helpers.ok
+++ b/src/tests/test-helpers.ok
@@ -51,3 +51,8 @@
transportLayerAddress = f11ff22ff33ff44ff55ff66ff77ff88f
bindingID = 11220000
unsupported address family
+Testing function ranap_transp_layer_addr_decode()
+ ipv4, x213_nsap
+ addr=1.2.3.4
+ ipv4
+ addr=1.2.3.4
--
To view, visit
https://gerrit.osmocom.org/c/osmo-iuh/+/26856
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I6d7427dc07c858a8dd76c1fb536ec3df3d96f1b1
Gerrit-Change-Number: 26856
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged