ebpf-challenge/GetRuntimeAddresses/symbolyze/testdata/simple.c
Özgür Kesim 554ae92194 Test added to compare the Scanner vs GDB
gdb_test.go and testdata implement a go test to compare and verify that
we get correct results from the scanner.

testdata/simple.c is a small program that embeds Python and runs the
same code as in runforever.py.  The Makefile compiles this using
python3.7.  Adjustments to the flags might be needed in your environment

gdb_test.go contains only one test, TestSimpleGDB, that
  1. compiles simple.c
  2. runs it multiple times
  3. calls gdb to extract the address of symbol _PyRuntime for each pid
  4. runs our Scanner
  5. compares the results from gdb and our scanner
2020-01-16 10:30:49 +01:00

23 lines
420 B
C

#define PY_SSIZE_T_CLEAN
#include <Python.h>
static char script[] = "import time\n"
"import os\n"
"\n"
"print(\"Process ID: {}\".format(os.getpid()))\n"
"print(\"Entering infinite loop ...\")\n"
"while 1:\n"
" time.sleep(2)\n"
"\n";
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString(script);
if (Py_FinalizeEx() < 0) {
exit(120);
}
return 0;
}