mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
kallsyms: make SpKallsyms more testable
This allows us to pass in the file to read from, and adds a quick test case to view the parsed output. It also fixes a base-10 vs base-16 mistake in parsing addresses.
This commit is contained in:
@ -18,6 +18,11 @@ test_capture_cursor = executable('test-capture-cursor',
|
||||
)
|
||||
test('test-capture-cursor', test_capture_cursor, env: test_env)
|
||||
|
||||
test_kallsyms = executable('test-kallsyms',
|
||||
['test-kallsyms.c', '../lib/sp-kallsyms.c'],
|
||||
dependencies: libsysprof_dep,
|
||||
)
|
||||
|
||||
if get_option('enable_gtk')
|
||||
|
||||
test_model_filter = executable('test-model-filter',
|
||||
|
||||
34
tests/test-kallsyms.c
Normal file
34
tests/test-kallsyms.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include "../lib/sp-address.h"
|
||||
#include "../lib/sp-kallsyms.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main (gint argc,
|
||||
gchar *argv[])
|
||||
{
|
||||
g_autoptr(SpKallsyms) kallsyms = NULL;
|
||||
const gchar *name;
|
||||
SpAddress addr = 0;
|
||||
guint8 type;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
g_printerr ("usage: %s FILE\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
kallsyms = sp_kallsyms_new (argv[1]);
|
||||
|
||||
while (sp_kallsyms_next (kallsyms, &name, &addr, &type))
|
||||
{
|
||||
g_assert (name != NULL);
|
||||
g_assert (addr != 0);
|
||||
g_assert (type != 0);
|
||||
|
||||
g_print ("%s %lx\n", name, addr);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user