From ef0aa6af47da16f5367f545deb599a14ea408bee Mon Sep 17 00:00:00 2001 From: Andrey Shinkevich Date: Tue, 30 Jul 2019 19:01:36 +0300 Subject: test-throttle: Fix uninitialized use of burst_length ThrottleState::cfg of the static variable 'ts' is reassigned with the local one in the do_test_accounting() and then is passed to the throttle_account() with uninitialized member LeakyBucket::burst_length. Signed-off-by: Andrey Shinkevich Message-Id: <1564502498-805893-2-git-send-email-andrey.shinkevich@virtuozzo.com> Signed-off-by: Paolo Bonzini --- tests/test-throttle.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 083e1f9..7adb5e6 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -558,6 +558,8 @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */ BucketType index; int i; + throttle_config_init(&cfg); + for (i = 0; i < 3; i++) { BucketType index = to_test[is_ops][i]; cfg.buckets[index].avg = avg; -- cgit v1.1 From f673174e3f62096f45b874fbe1cd469127d9c21c Mon Sep 17 00:00:00 2001 From: Andrey Shinkevich Date: Tue, 30 Jul 2019 19:01:37 +0300 Subject: tests: Fix uninitialized byte in test_visitor_in_fuzz One byte in the local buffer stays uninitialized, at least with the first iteration, because of the double decrement in the test_visitor_in_fuzz(). This is what Valgrind does not like and not critical for the test itself. So, reduce the number of the memory issues reports. Signed-off-by: Andrey Shinkevich Message-Id: <1564502498-805893-3-git-send-email-andrey.shinkevich@virtuozzo.com> Signed-off-by: Paolo Bonzini --- tests/test-string-input-visitor.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c index 34b54df..5418e08 100644 --- a/tests/test-string-input-visitor.c +++ b/tests/test-string-input-visitor.c @@ -444,16 +444,14 @@ static void test_visitor_in_fuzz(TestInputVisitorData *data, char buf[10000]; for (i = 0; i < 100; i++) { - unsigned int j; + unsigned int j, k; j = g_test_rand_int_range(0, sizeof(buf) - 1); buf[j] = '\0'; - if (j != 0) { - for (j--; j != 0; j--) { - buf[j - 1] = (char)g_test_rand_int_range(0, 256); - } + for (k = 0; k != j; k++) { + buf[k] = (char)g_test_rand_int_range(0, 256); } v = visitor_input_test_init(data, buf); -- cgit v1.1 From dcb1578069dd072f9aec74e3024cadb9ed0f3aae Mon Sep 17 00:00:00 2001 From: Pavel Dovgalyuk Date: Thu, 25 Jul 2019 11:44:26 +0300 Subject: util/qemu-timer: refactor deadline calculation for external timers icount-based record/replay uses qemu_clock_deadline_ns_all to measure the period until vCPU may be interrupted. This function takes in account the virtual timers, because they belong to the virtual devices that may generate interrupt request or affect the virtual machine state. However, there are a subset of virtual timers, that are marked with 'external' flag. These do not change the virtual machine state and only based on virtual clock. Calculating the deadling using the external timers breaks the determinism, because they do not belong to the replayed part of the virtual machine. This patch fixes the deadline calculation for this case by adding new parameter for skipping the external timers when it is needed. Signed-off-by: Pavel Dovgalyuk -- v2 changes: - added new parameter for timer attribute mask Message-Id: <156404426682.18669.17014100602930969222.stgit@pasha-Precision-3630-Tower> Signed-off-by: Paolo Bonzini --- tests/ptimer-test-stubs.c | 4 ++-- tests/ptimer-test.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/ptimer-test-stubs.c b/tests/ptimer-test-stubs.c index 54b3fd2..ed393d9 100644 --- a/tests/ptimer-test-stubs.c +++ b/tests/ptimer-test-stubs.c @@ -88,9 +88,9 @@ int64_t qemu_clock_get_ns(QEMUClockType type) return ptimer_test_time_ns; } -int64_t qemu_clock_deadline_ns_all(QEMUClockType type) +int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask) { - QEMUTimerList *timer_list = main_loop_tlg.tl[type]; + QEMUTimerList *timer_list = main_loop_tlg.tl[QEMU_CLOCK_VIRTUAL]; QEMUTimer *t = timer_list->active_timers.next; int64_t deadline = -1; diff --git a/tests/ptimer-test.c b/tests/ptimer-test.c index b30aad0..5b20e91 100644 --- a/tests/ptimer-test.c +++ b/tests/ptimer-test.c @@ -50,13 +50,15 @@ static void ptimer_test_set_qemu_time_ns(int64_t ns) static void qemu_clock_step(uint64_t ns) { - int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); int64_t advanced_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns; while (deadline != -1 && deadline <= advanced_time) { ptimer_test_set_qemu_time_ns(deadline); ptimer_test_expire_qemu_timers(deadline, QEMU_CLOCK_VIRTUAL); - deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); } ptimer_test_set_qemu_time_ns(advanced_time); -- cgit v1.1 From a060297822ea6b4194bf36654e58c802448a3eea Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 14 Aug 2019 08:27:23 +0800 Subject: test-bitmap: test set 1 bit case for bitmap_set All current bitmap_set test cases set range across word, while the handle of a range within one word is different from that. Add case to set 1 bit as a represent for set range within one word. Signed-off-by: Wei Yang Signed-off-by: Paolo Bonzini --- tests/test-bitmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/test-bitmap.c b/tests/test-bitmap.c index 18aa584..087e02a 100644 --- a/tests/test-bitmap.c +++ b/tests/test-bitmap.c @@ -67,6 +67,18 @@ static void bitmap_set_case(bmap_set_func set_func) bmap = bitmap_new(BMAP_SIZE); + /* Set one bit at offset in second word */ + for (offset = 0; offset <= BITS_PER_LONG; offset++) { + bitmap_clear(bmap, 0, BMAP_SIZE); + set_func(bmap, BITS_PER_LONG + offset, 1); + g_assert_cmpint(find_first_bit(bmap, 2 * BITS_PER_LONG), + ==, BITS_PER_LONG + offset); + g_assert_cmpint(find_next_zero_bit(bmap, + 3 * BITS_PER_LONG, + BITS_PER_LONG + offset), + ==, BITS_PER_LONG + offset + 1); + } + /* Both Aligned, set bits [BITS_PER_LONG, 3*BITS_PER_LONG] */ set_func(bmap, BITS_PER_LONG, 2 * BITS_PER_LONG); g_assert_cmpuint(bmap[1], ==, -1ul); -- cgit v1.1