test-gdb: can now run in either userland or baremetal modes

Selection with --mode userland (default because has x86_64) or --mode baremetal.

This is the first userland tool where this choice is done on the command line,
which led to a refactor of supported_archs and is_baremetal and is_userland
into a single self.env['mode'].
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-29 00:00:00 +00:00
parent b6126a5268
commit 6994dc21af
21 changed files with 106 additions and 55 deletions

View File

@@ -0,0 +1 @@
../build

View File

@@ -0,0 +1 @@
../test

View File

@@ -0,0 +1 @@
../build

View File

@@ -0,0 +1 @@
../test

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests

View File

@@ -0,0 +1 @@
../build

View File

@@ -0,0 +1,11 @@
#include <lkmc.h>
LKMC_PROLOGUE
/* 1 + 2 == 3 */
mov $1, %rax
/* test-gdb-op1 */
mov $2, %rbx
add %rax, %rbx
/* test-gdb-result */
LKMC_ASSERT_EQ(%rbx, $3)
LKMC_EPILOGUE

View File

@@ -0,0 +1,7 @@
def test(self):
self.sendline('tbreak main')
self.sendline('continue')
self.continue_to('op1')
assert self.get_int('$rax') == 1
self.continue_to('result')
assert self.get_int('$rbx') == 3

View File

@@ -0,0 +1,10 @@
/* Test that we can set registers from GDB. */
#include <lkmc.h>
LKMC_PROLOGUE
mov $1, %rax
/* test-gdb-rax */
mov $2, %rbx
/* test-gdb-rbx */
LKMC_EPILOGUE

View File

@@ -0,0 +1,9 @@
def test(self):
self.sendline('tbreak main')
self.sendline('continue')
self.continue_to('rax')
self.sendline('set $rax = 3')
self.continue_to('rbx')
assert self.get_int('$rax') == 3
assert self.get_int('$rbx') == 2

View File

@@ -0,0 +1 @@
../test