Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 1 | From 40b2a4a793c81221a28f822d07135069456ea021 Mon Sep 17 00:00:00 2001 |
| 2 | From: Olivier Dion <odion@efficios.com> |
| 3 | Date: Fri, 10 Mar 2023 13:17:46 -0500 |
| 4 | Subject: [PATCH] Tests: fix: parse-callback reports missing addr2line |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=utf8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | Upstream-Status: Backport |
| 10 | |
| 11 | addr2line from binutils is required for this script to work correctly. |
| 12 | However, it silently fails. Fix this by using `subprocess.run' with |
| 13 | `check=True' instead of `subprocess.getoutput'. That way, an exception |
| 14 | is raised if an error occurs. |
| 15 | |
| 16 | Fix the shebang by not assuming where python is installed while at it. |
| 17 | |
| 18 | Change-Id: I5157b3dbccf6bfbe08a6b6840b38f5db9010fe96 |
| 19 | Signed-off-by: Olivier Dion <odion@efficios.com> |
| 20 | Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 21 | --- |
| 22 | tests/utils/parse-callstack.py | 6 ++++-- |
| 23 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 24 | |
| 25 | diff --git a/tests/utils/parse-callstack.py b/tests/utils/parse-callstack.py |
| 26 | index 3bfddd9ef..c3f0e2e9b 100755 |
| 27 | --- a/tests/utils/parse-callstack.py |
| 28 | +++ b/tests/utils/parse-callstack.py |
| 29 | @@ -1,4 +1,4 @@ |
| 30 | -#!/usr/bin/python3 |
| 31 | +#!/usr/bin/env python3 |
| 32 | # |
| 33 | # Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com> |
| 34 | # |
| 35 | @@ -24,7 +24,9 @@ def addr2line(executable, addr): |
| 36 | # Expand inlined functions |
| 37 | cmd += ['--addresses', addr] |
| 38 | |
| 39 | - addr2line_output = subprocess.getoutput(' '.join(cmd)) |
| 40 | + status = subprocess.run(cmd, stdout=subprocess.PIPE, check=True) |
| 41 | + |
| 42 | + addr2line_output = status.stdout.decode("utf-8") |
| 43 | |
| 44 | # Omit the last 2 lines as the caller of main can not be determine |
| 45 | fcts = [addr2line_output.split()[-2]] |
| 46 | -- |
| 47 | 2.34.1 |
| 48 | |