diff mbox series

[v2,05/16] core/test/run-trace: Stop using indeterminate fields

Message ID 20190401234327.26819-6-jniethe5@gmail.com
State Accepted
Headers show
Series Improvements to trace buffers | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (050d8165ab05b6d9cdf4bfee42d9776969c77029)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Jordan Niethe April 1, 2019, 11:43 p.m. UTC
The parallel_test uses the cpu field of the trace_hdr struct. However it
is expected that some of the trace entries that are gotten will be
trace_overflow structs. This type of entry leaves the cpu field
indeterminate when it is interpreted as a trace_hdr struct. This means
it possible tests will fail when they try to use the cpu field of an
overflow struct, as the cpu field could hold anything.

Move the checks that use the cpu field until after it has been
determined the trace entry is an overflow type.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
 core/test/run-trace.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/core/test/run-trace.c b/core/test/run-trace.c
index ef7ebfe12655..ec907c82bddc 100644
--- a/core/test/run-trace.c
+++ b/core/test/run-trace.c
@@ -210,9 +210,6 @@  static void test_parallel(void)
 		i = (i + last) % CPUS;
 		last = i;
 
-		assert(be16_to_cpu(t.hdr.cpu) < CPUS);
-		assert(!done[be16_to_cpu(t.hdr.cpu)]);
-
 		if (t.hdr.type == TRACE_OVERFLOW) {
 			/* Conveniently, each record is 16 bytes here. */
 			assert(be64_to_cpu(t.overflow.bytes_missed) % 16 == 0);
@@ -221,6 +218,8 @@  static void test_parallel(void)
 			continue;
 		}
 
+		assert(be16_to_cpu(t.hdr.cpu) < CPUS);
+		assert(!done[be16_to_cpu(t.hdr.cpu)]);
 		assert(be64_to_cpu(t.hdr.timestamp) % CPUS == be16_to_cpu(t.hdr.cpu));
 		if (t.hdr.type == TRACE_REPEAT) {
 			assert(t.hdr.len_div_8 * 8 == sizeof(t.repeat));