Add a simple stack_walker test

This commit is contained in:
Théophile Bastian 2018-04-26 19:17:34 +02:00
parent f587eadbcc
commit 4ab7d0a594
2 changed files with 23 additions and 0 deletions

8
tests/Makefile Normal file
View file

@ -0,0 +1,8 @@
CXX=g++
CXXFLAGS=-Wall -Wextra -O2 -g -I../stack_walker -rdynamic
stack_walked.bin: stack_walked.cpp
$(CXX) $(CXXFLAGS) -o $@ $^ -L../stack_walker -ldl -lstack_walker
clean:
rm *.bin

15
tests/stack_walked.cpp Normal file
View file

@ -0,0 +1,15 @@
#include <cstdio>
#include <dlfcn.h>
#include "../stack_walker/stack_walker.hpp"
int main() {
Dl_info main_info;
int rc = dladdr((void*)&main, &main_info);
printf("I'm in %s!\n", (rc != 0) ? main_info.dli_sname : "[No data]");
stack_walker_init();
return 0;
}