Implement part of test_modules_abi_vs_tools
[deliverable/lttng-ivc.git] / lttng_ivc / utils / runtime.py
index a89c23bf6c283a5b882870ad20bd5e159fcf27b5..f272d6571481c90f9d7ced410420a84392fd6015 100644 (file)
@@ -147,7 +147,8 @@ class Runtime(object):
 
         env_path = os.path.join(self.__runtime_log, str(tmp_id) + ".env")
         with open(env_path, 'w') as env_out:
-            pprint.pprint(env, stream=env_out)
+            for key, value in env.items():
+                env_out.write('{}={}\n'.format(key, value))
 
         cp = subprocess.run(args, stdout=stdout, stderr=stderr, env=env, cwd=cwd)
         _logger.debug("Command #{} args: {} stdout: {} stderr{}".format(tmp_id, cp.args, out_path, err_path))
@@ -231,6 +232,14 @@ class Runtime(object):
                     env[var] = value
         return env
 
+    def load_test_module(self):
+        # Base directory is provided by env
+        self.run("modprobe lttng-test")
+
+    def unload_test_module(self, check_return=True):
+        # Base directory is provided by env
+        self.run("modprobe -r lttng-test", check_return=check_return)
+
     def close(self):
         for key, subp in self.__subprocess.items():
             subp.terminate()
@@ -241,6 +250,10 @@ class Runtime(object):
             stdout.close()
             stderr.close()
 
+        # Always try to remove test module but do not perform check on return
+        # value.
+        self.unload_test_module(False)
+
         # Copy the lttng_home used at runtime using hardlink to prevent useless
         # data duplication
         shutil.copytree(self.lttng_home, self.__post_runtime_lttng_home_path, copy_function=os.link)
This page took 0.023293 seconds and 5 git commands to generate.