diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-01-17 19:04:37 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-01-17 19:04:37 +0100 |
| commit | 1ac75f06add54089e4910ecb6a97198336155c63 (patch) | |
| tree | e7d5219d6589e4ef018a5b5822a4da05b9249300 /executor/test_kvm.cc | |
| parent | 8ead82246bc00830d0271933df316e973be4ebcc (diff) | |
executor: fix copyin of values
Currently non-bitfield values are copied incorrectly.
Probably all turned into zeros or something.
Fix that. Add test.
Diffstat (limited to 'executor/test_kvm.cc')
| -rw-r--r-- | executor/test_kvm.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/executor/test_kvm.cc b/executor/test_kvm.cc index 4d990dc19..6c76b5e78 100644 --- a/executor/test_kvm.cc +++ b/executor/test_kvm.cc @@ -8,6 +8,22 @@ #include <sys/utsname.h> +extern "C" int test_copyin() +{ + unsigned char x[4] = {}; + STORE_BY_BITMASK(uint16_t, &x[1], 0x1234, 0, 0); + if (x[0] != 0 || x[1] != 0x34 || x[2] != 0x12 || x[3] != 0) { + printf("bad result of STORE_BY_BITMASK(0, 0): %x %x %x %x\n", x[0], x[1], x[2], x[3]); + return 1; + } + STORE_BY_BITMASK(uint16_t, &x[1], 0x555a, 5, 4); + if (x[0] != 0 || x[1] != 0x54 || x[2] != 0x13 || x[3] != 0) { + printf("bad result of STORE_BY_BITMASK(7, 3): %x %x %x %x\n", x[0], x[1], x[2], x[3]); + return 1; + } + return 0; +} + static unsigned host_kernel_version(); static void dump_cpu_state(int cpufd, char* vm_mem); |
