[Skiboot] [PATCH v2 05/16] core/test/run-trace: Stop using indeterminate fields
Jordan Niethe
jniethe5 at gmail.com
Tue Apr 2 10:43:16 AEDT 2019
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 at gmail.com>
---
core/test/run-trace.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
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));
--
2.20.1
More information about the Skiboot
mailing list