aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/gtp/gtpie_test.c11
-rw-r--r--tests/lib/in46a_test.c3
2 files changed, 8 insertions, 6 deletions
diff --git a/tests/gtp/gtpie_test.c b/tests/gtp/gtpie_test.c
index 8d87dcc..e3bc2e0 100644
--- a/tests/gtp/gtpie_test.c
+++ b/tests/gtp/gtpie_test.c
@@ -7,6 +7,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/application.h>
#include <osmocom/core/logging.h>
+#include <osmocom/core/bits.h>
#include "../../lib/syserr.h"
#include "../../gtp/gtpie.h"
@@ -27,7 +28,7 @@ static void test_gtpie_tlv()
OSMO_ASSERT(rc == 0);
OSMO_ASSERT(len == sizeof(in) + 3);
OSMO_ASSERT(buf[0] == 23);
- OSMO_ASSERT(ntohs(*(uint16_t *) &buf[1]) == sizeof(in));
+ OSMO_ASSERT(osmo_load16be(&buf[1]) == sizeof(in));
OSMO_ASSERT(!memcmp(buf+3, in, sizeof(in)));
/* overflow */
@@ -73,7 +74,7 @@ static void test_gtpie_tv2()
OSMO_ASSERT(rc == 0);
OSMO_ASSERT(len == 3);
OSMO_ASSERT(buf[0] == 42);
- OSMO_ASSERT(ntohs(*(uint16_t *) &buf[1]) == 0xABCD);
+ OSMO_ASSERT(osmo_load16be(&buf[1]) == 0xABCD);
}
static void test_gtpie_tv4()
@@ -87,7 +88,7 @@ static void test_gtpie_tv4()
OSMO_ASSERT(rc == 0);
OSMO_ASSERT(len == 5);
OSMO_ASSERT(buf[0] == 42);
- OSMO_ASSERT(ntohl(*(uint32_t *) &buf[1]) == 0xABCD0123);
+ OSMO_ASSERT(osmo_load32be(&buf[1]) == 0xABCD0123);
}
static void test_gtpie_tv8()
@@ -101,8 +102,8 @@ static void test_gtpie_tv8()
OSMO_ASSERT(rc == 0);
OSMO_ASSERT(len == 9);
OSMO_ASSERT(buf[0] == 42);
- OSMO_ASSERT(ntohl(*(uint32_t *) &buf[1]) == 0x00010203);
- OSMO_ASSERT(ntohl(*(uint32_t *) &buf[5]) == 0x04050607);
+ OSMO_ASSERT(osmo_load32be(&buf[1]) == 0x00010203);
+ OSMO_ASSERT(osmo_load32be(&buf[5]) == 0x04050607);
}
int main(int argc, char **argv)
diff --git a/tests/lib/in46a_test.c b/tests/lib/in46a_test.c
index ab7156f..d4a5dbc 100644
--- a/tests/lib/in46a_test.c
+++ b/tests/lib/in46a_test.c
@@ -10,6 +10,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/application.h>
#include <osmocom/core/logging.h>
+#include <osmocom/core/bits.h>
#include "../../lib/in46_addr.h"
#include "../../lib/syserr.h"
@@ -171,7 +172,7 @@ static void test_in46a_to_eua(void)
OSMO_ASSERT(in46a_to_eua(&g_ia4, &eua) == 0);
OSMO_ASSERT(eua.v[0] == PDP_EUA_ORG_IETF);
OSMO_ASSERT(eua.v[1] == PDP_EUA_TYPE_v4);
- OSMO_ASSERT(*(uint32_t *) &eua.v[2] == g_ia4.v4.s_addr);
+ OSMO_ASSERT(osmo_load32le(&eua.v[2]) == g_ia4.v4.s_addr);
/* IPv6 address */
OSMO_ASSERT(in46a_to_eua(&g_ia6, &eua) == 0);