diff options
author | Thomas Huth <thuth@redhat.com> | 2021-03-10 07:33:14 +0100 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2021-03-12 15:46:30 +0100 |
commit | da668aa15b99150a8595c491aee00d5d2426aaf9 (patch) | |
tree | 0463b0a303e807bdab46460f6c702be611bd7179 /tests/ptimer-test-stubs.c | |
parent | 363fc963054d8e82cfd55fa9b9aa130692a8dbd7 (diff) |
tests: Move unit tests into a separate directory
The main tests directory still looks very crowded, and it's not
clear which files are part of a unit tests and which belong to
a different test subsystem. Let's clean up the mess and move the
unit tests to a separate directory.
Message-Id: <20210310063314.1049838-1-thuth@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/ptimer-test-stubs.c')
-rw-r--r-- | tests/ptimer-test-stubs.c | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/tests/ptimer-test-stubs.c b/tests/ptimer-test-stubs.c deleted file mode 100644 index 7f801a4d09..0000000000 --- a/tests/ptimer-test-stubs.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Stubs for the ptimer-test - * - * Copyright (c) 2016 Dmitry Osipenko <digetx@gmail.com> - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "qemu/main-loop.h" -#include "sysemu/replay.h" -#include "migration/vmstate.h" -#include "sysemu/cpu-timers.h" - -#include "ptimer-test.h" - -const VMStateInfo vmstate_info_uint8; -const VMStateInfo vmstate_info_uint32; -const VMStateInfo vmstate_info_uint64; -const VMStateInfo vmstate_info_int64; -const VMStateInfo vmstate_info_timer; - -struct QEMUBH { - QEMUBHFunc *cb; - void *opaque; -}; - -QEMUTimerListGroup main_loop_tlg; - -int64_t ptimer_test_time_ns; - -/* under qtest_enabled(), will not artificially limit period - see hw/core/ptimer.c. */ -int use_icount; -bool qtest_allowed; - -void timer_init_full(QEMUTimer *ts, - QEMUTimerListGroup *timer_list_group, QEMUClockType type, - int scale, int attributes, - QEMUTimerCB *cb, void *opaque) -{ - if (!timer_list_group) { - timer_list_group = &main_loop_tlg; - } - ts->timer_list = timer_list_group->tl[type]; - ts->cb = cb; - ts->opaque = opaque; - ts->scale = scale; - ts->attributes = attributes; - ts->expire_time = -1; -} - -void timer_mod(QEMUTimer *ts, int64_t expire_time) -{ - QEMUTimerList *timer_list = ts->timer_list; - QEMUTimer *t = &timer_list->active_timers; - - while (t->next != NULL) { - if (t->next == ts) { - break; - } - - t = t->next; - } - - ts->expire_time = MAX(expire_time * ts->scale, 0); - ts->next = NULL; - t->next = ts; -} - -void timer_del(QEMUTimer *ts) -{ - QEMUTimerList *timer_list = ts->timer_list; - QEMUTimer *t = &timer_list->active_timers; - - while (t->next != NULL) { - if (t->next == ts) { - t->next = ts->next; - return; - } - - t = t->next; - } -} - -int64_t qemu_clock_get_ns(QEMUClockType type) -{ - return ptimer_test_time_ns; -} - -int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask) -{ - QEMUTimerList *timer_list = main_loop_tlg.tl[QEMU_CLOCK_VIRTUAL]; - QEMUTimer *t = timer_list->active_timers.next; - int64_t deadline = -1; - - while (t != NULL) { - if (deadline == -1) { - deadline = t->expire_time; - } else { - deadline = MIN(deadline, t->expire_time); - } - - t = t->next; - } - - return deadline; -} - -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) -{ - QEMUBH *bh = g_new(QEMUBH, 1); - - bh->cb = cb; - bh->opaque = opaque; - - return bh; -} - -void qemu_bh_delete(QEMUBH *bh) -{ - g_free(bh); -} |