Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

calltrace.introduction

Klemens David Morgenstern edited this page Apr 4, 2018 · 1 revision

metal.calltrace is a light-weight calltrace library that allows to validate call sequences.

  • call tracing at runtime
  • detailed output through the dbg-runner
  • human-readable-format or json output
  • C and C++ implementation

Here's a simple example of a test with metal.test.backend:

#include <metal/calltrace.hpp>

void foo();
void bar();
void func() {foo(); bar();}

int main(int argc, char *argv[])
{
    //Check that func calls foo and bar in this order.
    metal::test::calltrace<2> ct{&func,
                           &foo, & bar};

    func();

    return ct ? 0 : 1;
}

Using the metal.runner we can launch the test on a remote arm device, which would look like this:

metal.runner --debug --gdb=arm-none-eabi-gdb --exe=test.elf --lib metal-calltrace metal-exitcode --remote localhost:3333 --other "openocd -f ..\scripts\interface\stlink-v2.cfg -f ..\scripts\target\stm32f4x.cfg -c init"

Which will give us an exit-code unqual to zero if the call sequence doesn't match.