From d64ff72c3605be453f4c889e5324eeb0f734ec3b Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sun, 23 Feb 2025 19:49:38 +0100 Subject: [PATCH] tests: Improve the backtrace test Make sure that the backtrace contains at least 3 frames. --- tests/Gtest-bt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Gtest-bt.c b/tests/Gtest-bt.c index d1ac6f3d..8790ac84 100644 --- a/tests/Gtest-bt.c +++ b/tests/Gtest-bt.c @@ -48,6 +48,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define panic(...) \ { fprintf (stderr, __VA_ARGS__); exit (-1); } +#define MIN_FRAMES 3 #define SIG_STACK_SIZE 0x100000 int verbose; @@ -65,6 +66,7 @@ do_backtrace (void) { unw_word_t ip, sp, off; unw_proc_info_t pi; + unsigned int num_frames = 0; int ret; if (verbose) @@ -120,9 +122,17 @@ do_backtrace (void) ret, (long) ip); ++num_errors; } + + ++num_frames; } while (ret > 0); + if (num_frames < MIN_FRAMES) { + printf ("FAILURE: only found %u frames in the backtrace\n", + num_frames); + ++num_errors; + } + { void *buffer[20]; int i, n;