[MERGED] osmo-bsc[master]: handover_test: explicitly wrap abis_rsl_sendmsg()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Mar 8 20:21:56 UTC 2018


Neels Hofmeyr has submitted this change and it was merged.

Change subject: handover_test: explicitly wrap abis_rsl_sendmsg()
......................................................................


handover_test: explicitly wrap abis_rsl_sendmsg()

Until now, handover_test simply defines an abis_rsl_sendmsg() function to
override the one from libosmo-babis. To me this amounts to implicit linker
magic (aka luck).

The common pattern we're using for this scenario is to explicitly wrap an
existing function by instructing the linker. Also do this for
abis_rsl_sendmsg() in handover_test.c to clarify.

Change-Id: I05ce33a4e42bc82b9ce5060e2f811033f5a1f8d8
---
M tests/handover/Makefile.am
M tests/handover/handover_test.c
2 files changed, 8 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/handover/Makefile.am b/tests/handover/Makefile.am
index 5cdc0b0..7133fcd 100644
--- a/tests/handover/Makefile.am
+++ b/tests/handover/Makefile.am
@@ -27,6 +27,10 @@
 	handover_test.c \
 	$(NULL)
 
+handover_test_LDFLAGS =\
+	-Wl,--wrap=abis_rsl_sendmsg \
+	$(NULL)
+
 handover_test_LDADD = \
 	$(top_builddir)/src/libbsc/libbsc.a \
 	$(LIBOSMOCORE_LIBS) \
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index 8ba97fd..bf7350c 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -339,8 +339,10 @@
 	abis_rsl_rcvmsg(msg);
 }
 
-/* RSL messages from BSC */
-int abis_rsl_sendmsg(struct msgb *msg)
+/* override, requires '-Wl,--wrap=abis_rsl_sendmsg'.
+ * Catch RSL messages sent towards the BTS. */
+int __real_abis_rsl_sendmsg(struct msgb *msg);
+int __wrap_abis_rsl_sendmsg(struct msgb *msg)
 {
 	struct abis_rsl_dchan_hdr *dh = (struct abis_rsl_dchan_hdr *) msg->data;
 	struct e1inp_sign_link *sign_link = msg->dst;

-- 
To view, visit https://gerrit.osmocom.org/7121
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I05ce33a4e42bc82b9ce5060e2f811033f5a1f8d8
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list