Change in osmo-gsm-tester[master]: srs-enb: adds support to the malloc interceptor.

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/.

Alejandro Leal gerrit-no-reply at lists.osmocom.org
Wed May 19 14:38:58 UTC 2021


Alejandro Leal has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24284 )


Change subject: srs-enb: adds support to the malloc interceptor.
......................................................................

srs-enb: adds support to the malloc interceptor.

Adds support to the malloc interceptor for the SRS eNodeB. This interceptor will generate a log file that lists the mallocs, reallocs and frees produced by the srsenb.

Change-Id: I0078020468f58bdd70b0b5de879eb58192f947a6
---
M src/osmo_gsm_tester/obj/enb_srs.py
A sysmocom/scenarios/cfg-enb-malloc-interceptor.conf
2 files changed, 44 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/84/24284/1

diff --git a/src/osmo_gsm_tester/obj/enb_srs.py b/src/osmo_gsm_tester/obj/enb_srs.py
index b3166a5..95f3407 100644
--- a/src/osmo_gsm_tester/obj/enb_srs.py
+++ b/src/osmo_gsm_tester/obj/enb_srs.py
@@ -39,6 +39,7 @@
     schema.register_resource_schema('enb', resource_schema)
 
     config_schema = {
+        'enable_malloc_interceptor': schema.BOOL_STR,
         'enable_pcap': schema.BOOL_STR,
         'enable_tracing': schema.BOOL_STR,
         'enable_ul_qam64': schema.BOOL_STR,
@@ -62,6 +63,7 @@
     S1AP_PCAPFILE = 'srsenb_s1ap.pcap'
     TRACINGFILE = 'srsenb_tracing.log'
     METRICSFILE = 'srsenb_metrics.csv'
+    INTERCEPTORFILE = 'srsenb_minterceptor.log'
 
     def __init__(self, testenv, conf):
         super().__init__(testenv, conf, srsENB.BINFILE)
@@ -74,6 +76,7 @@
         self.config_rr_file = None
         self.config_drb_file = None
         self.tracing_file = None
+        self.interceptor_file = None
         self.log_file = None
         self.pcap_file = None
         self.s1ap_pcap_file = None
@@ -89,9 +92,11 @@
         self.remote_s1ap_pcap_file = None
         self.remote_tracing_file = None
         self.remote_metrics_file = None
+        self.remote_interceptor_file = None
         self.enable_pcap = False
         self.enable_ul_qam64 = False
         self.enable_tracing = False
+        self.enable_malloc_interceptor = False
         self.metrics_file = None
         self.have_metrics_file = False
         self.stop_sleep_time = 6 # We require at most 5s to stop
@@ -146,6 +151,12 @@
             except Exception as e:
                 self.log(repr(e))
 
+        if self.enable_malloc_interceptor:
+            try:
+                self.rem_host.scpfrom('scp-back-interceptor', self.remote_interceptor_file, self.interceptor_file)
+            except Exception as e:
+                self.log(repr(e))
+
         # Collect KPIs for each TC
         self.testenv.test().set_kpis(self.get_kpi_tree())
         # Clean up for parent class:
@@ -256,10 +267,34 @@
 
     def start_remotely(self):
         remote_env = { 'LD_LIBRARY_PATH': self.remote_inst.child('lib') }
+        # Add the malloc interceptor env variable when it's required.
+        if self.enable_malloc_interceptor:
+            env_var = self._conf.get('env_variables', None)
+            if not env_var:
+                raise log.Error('Could not get the environment variables. Aborting')
+                return
+
+            interceptor_env = [s for s in env_var if 'LD_PRELOAD' in s]
+
+            if not interceptor_env or len(interceptor_env) > 1:
+                raise log.Error('Could not get the LD_PRELOAD variable. Aborting')
+                return
+
+            self.log(f'Found LD_PRELOAD variable with value: {interceptor_env}')
+
+            env = str(interceptor_env[0])
+            index = env.find(':')
+            self.log(f'Setting var: {env[:index]} to value: {env[index + 1:]}')                
+            remote_env[env[:index]] = env[index + 1:]
+            
         remote_binary = self.remote_inst.child('bin', srsENB.BINFILE)
         args = (remote_binary, self.remote_config_file)
         args += tuple(self._additional_args)
 
+        # Force the output of the malloc interceptor to the interceptor_file.
+        if self.enable_malloc_interceptor:
+            args += tuple([f" 2> {self.remote_interceptor_file}"])
+
         self.process = self.rem_host.RemoteProcessSafeExit(srsENB.BINFILE, self.remote_run_dir, args, remote_env=remote_env, wait_time_sec=7)
         self.testenv.remember_to_stop(self.process)
         self.process.launch()
@@ -299,6 +334,7 @@
         self.s1ap_pcap_file = self.run_dir.child(srsENB.S1AP_PCAPFILE)
         self.metrics_file = self.run_dir.child(srsENB.METRICSFILE)
         self.tracing_file = self.run_dir.child(srsENB.TRACINGFILE)
+        self.interceptor_file = self.run_dir.child(srsENB.INTERCEPTORFILE)
 
         if not self._run_node.is_local():
             self.rem_host = remote.RemoteHost(self.run_dir, self._run_node.ssh_user(), self._run_node.ssh_addr())
@@ -315,6 +351,7 @@
             self.remote_s1ap_pcap_file = self.remote_run_dir.child(srsENB.S1AP_PCAPFILE)
             self.remote_metrics_file = self.remote_run_dir.child(srsENB.METRICSFILE)
             self.remote_tracing_file = self.remote_run_dir.child(srsENB.TRACINGFILE)
+            self.remote_interceptor_file = self.remote_run_dir.child(srsENB.INTERCEPTORFILE)
 
         values = super().configure(['srsenb'])
 
@@ -336,6 +373,9 @@
                                              s1ap_pcap_filename=s1ap_pcapfile,
                                              )))
 
+        # Retrieve the malloc interceptor option.
+        self.enable_malloc_interceptor = util.str2bool(values['enb'].get('enable_malloc_interceptor', 'false'))
+
         # Convert parsed boolean string to Python boolean:
         self.enable_pcap = util.str2bool(values['enb'].get('enable_pcap', 'false'))
         config.overlay(values, dict(enb={'enable_pcap': self.enable_pcap}))
diff --git a/sysmocom/scenarios/cfg-enb-malloc-interceptor.conf b/sysmocom/scenarios/cfg-enb-malloc-interceptor.conf
new file mode 100644
index 0000000..973c64d
--- /dev/null
+++ b/sysmocom/scenarios/cfg-enb-malloc-interceptor.conf
@@ -0,0 +1,4 @@
+config:
+  enb:
+    enable_malloc_interceptor: true 
+    
\ No newline at end of file

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24284
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I0078020468f58bdd70b0b5de879eb58192f947a6
Gerrit-Change-Number: 24284
Gerrit-PatchSet: 1
Gerrit-Owner: Alejandro Leal <alejandro.leal at srs.io>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210519/80eaacf1/attachment.htm>


More information about the gerrit-log mailing list