diff --git a/testsuites/tmtests/tmcontext01/init.c b/testsuites/tmtests/tmcontext01/init.c
index 7f4ababfe5..dc1da718c7 100644
--- a/testsuites/tmtests/tmcontext01/init.c
+++ b/testsuites/tmtests/tmcontext01/init.c
@@ -168,14 +168,8 @@ static __attribute__((__noipa__)) void test_by_function_level(int fl, bool dirty
max = t[SAMPLES - 1];
printf(
- " \n"
- " %" PRIu64 ""
- "%" PRIu64 ""
- "%" PRIu64 ""
- "%" PRIu64 ""
- "%" PRIu64 "\n"
- " \n",
- fl,
+ "%s\n [%" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 "]",
+ fl == 0 ? "" : ",",
rtems_counter_ticks_to_nanoseconds(min),
rtems_counter_ticks_to_nanoseconds(q1),
rtems_counter_ticks_to_nanoseconds(q2),
@@ -184,26 +178,38 @@ static __attribute__((__noipa__)) void test_by_function_level(int fl, bool dirty
);
}
-static void test(bool dirty, uint32_t load)
+static void test(bool first, bool dirty, uint32_t load)
{
int fl;
printf(
- " 0) {
- printf(" load=\"%" PRIu32 "\"", load);
+ if (dirty) {
+ if (load > 0) {
+ printf("Load/%" PRIu32 "", load);
+ } else {
+ printf("DirtyCache");
+ }
+ } else {
+ printf("HotCache");
}
- printf(">\n");
+ printf(
+ "\",\n"
+ " \"stats-by-function-nest-level\": ["
+ );
for (fl = 0; fl < FUNCTION_LEVELS; ++fl) {
test_by_function_level(fl, dirty);
}
- printf(" \n");
+ printf(
+ "\n ]"
+ );
}
static void Init(rtems_task_argument arg)
@@ -212,7 +218,7 @@ static void Init(rtems_task_argument arg)
TEST_BEGIN();
- printf("\n");
+ printf("*** BEGIN OF JSON DATA ***\n[");
cache_line_size = rtems_cache_get_data_line_size();
if (cache_line_size == 0) {
@@ -227,8 +233,8 @@ static void Init(rtems_task_argument arg)
main_data = malloc(data_size);
rtems_test_assert(main_data != NULL);
- test(false, load);
- test(true, load);
+ test(true, false, load);
+ test(false, true, load);
for (load = 1; load < rtems_scheduler_get_processor_maximum(); ++load) {
rtems_status_code sc;
@@ -253,10 +259,10 @@ static void Init(rtems_task_argument arg)
sc = rtems_task_start(id, load_task, (rtems_task_argument) load_data);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- test(true, load);
+ test(false, true, load);
}
- printf("\n");
+ printf("\n }\n]\n*** END OF JSON DATA ***\n");
TEST_END();
rtems_test_exit(0);
diff --git a/testsuites/tmtests/tmcontext01/plot.py b/testsuites/tmtests/tmcontext01/plot.py
index ce59efabe3..944a5962c2 100644
--- a/testsuites/tmtests/tmcontext01/plot.py
+++ b/testsuites/tmtests/tmcontext01/plot.py
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2014 embedded brains GmbH & Co. KG
+# Copyright (C) 2014, 2024 embedded brains GmbH & Co. KG
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -23,48 +22,38 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#
-import libxml2
-from libxml2 import xmlNode
-import matplotlib.pyplot as plt
-doc = libxml2.parseFile("tmcontext01.scn")
-ctx = doc.xpathNewContext()
+import json
+import re
+import matplotlib.pyplot as plt # type: ignore
+from matplotlib import ticker # type: ignore
-colors = ['k', 'r', 'b', 'g', 'y', 'm']
-def plot(y, color, label, first):
- n=len(y)
- x=range(0, n)
- if first:
- plt.plot(x, y, color=color, label=label)
- else:
- plt.plot(x, y, color=color)
+def _plot(data: dict) -> None:
+ _, axes = plt.subplots()
+ axes.set_title("Context Switch Timing Test")
+ axes.set_xlabel("Function Nest Level")
+ axes.set_ylabel("Context Switch Time [μs]")
+ x = list(range(0, len(data[0]["stats-by-function-nest-level"])))
+ axes.xaxis.set_major_locator(ticker.FixedLocator(x))
+ for samples in data:
+ y = [
+ values[2] / 1000.0
+ for values in samples["stats-by-function-nest-level"]
+ ]
+ axes.plot(x, y, label=samples["environment"], marker='o')
+ axes.legend(loc='best')
+ plt.savefig("tmcontext01.png")
+ plt.savefig("tmcontext01.pdf")
+ plt.close()
-plt.title("context switch timing test")
-plt.xlabel('function nest level')
-plt.ylabel('context switch time [ns]')
-c = 0
-for e in ["normal", "dirty"]:
- first = True
- for i in ["Min", "Q1", "Q2", "Q3", "Max"]:
- y=map(xmlNode.getContent, ctx.xpathEval("/Test/ContextSwitchTest[@environment='" + e + "' and not(@load)]/Sample/" + i))
- plot(y, colors[c], e, first)
- first = False
- c = c + 1
-load = 1
-while load > 0:
- first = True
- for i in ["Min", "Q1", "Q2", "Q3", "Max"]:
- y=map(xmlNode.getContent, ctx.xpathEval("/Test/ContextSwitchTest[@environment='dirty' and @load='" + str(load) + "']/Sample/" + i))
- if len(y) > 0:
- plot(y, colors[c], "load " + str(load), first)
- first = False
- else:
- load = 0
- if load > 0:
- load = load + 1
- c = c + 1
-plt.legend()
-plt.show()
+_JSON_DATA = re.compile(
+ r"\*\*\* BEGIN OF JSON DATA \*\*\*(.*)"
+ r"\*\*\* END OF JSON DATA \*\*\*", re.DOTALL)
+
+with open("tmcontext01.scn", "r", encoding="utf-8") as src:
+ match = _JSON_DATA.search(src.read())
+ data = json.loads(match.group(1))
+
+_plot(data)
diff --git a/testsuites/tmtests/tmcontext01/tmcontext01.scn b/testsuites/tmtests/tmcontext01/tmcontext01.scn
index 9044619319..8347d8b3fb 100644
--- a/testsuites/tmtests/tmcontext01/tmcontext01.scn
+++ b/testsuites/tmtests/tmcontext01/tmcontext01.scn
@@ -1,255 +1,124 @@
-
-
-
-
-
- 24402440248024802800
-
-
- 35203760380038004120
-
-
- 42804720472050405080
-
-
- 53205640568059606000
-
-
- 63606600660069206920
-
-
- 74807520784078407880
-
-
- 84808480880088008840
-
-
- 88408960928092809320
-
-
- 89208960928092809320
-
-
- 89208960896092809280
-
-
- 88008960924092809280
-
-
- 89208960928092809280
-
-
- 89208960924092809320
-
-
- 89208960924092809280
-
-
- 89208960924092809280
-
-
- 89208960896092809280
-
-
-
-
- 972010560106001068011160
-
-
- 1184012280125601260012640
-
-
- 1288013560136001364013680
-
-
- 1396014640146801472014720
-
-
- 1500015680157601576015800
-
-
- 1632016720168001680017040
-
-
- 1732017560178001788018160
-
-
- 1744017800178401788018160
-
-
- 1736017800178401788018200
-
-
- 1740017800178401788018120
-
-
- 1732017800178401788018200
-
-
- 1736017840178401788018160
-
-
- 1736017800178401788018160
-
-
- 1736017800178401788018200
-
-
- 1776017840178401788018200
-
-
- 1736017800178401788018200
-
-
-
-
- 2380024440246402472025080
-
-
- 2804028560286402868028720
-
-
- 3160032160321603220032280
-
-
- 3540035720357603592036080
-
-
- 3896039280393203956039640
-
-
- 4248042840430804312043200
-
-
- 4612046600466404668046880
-
-
- 4608046600466404668046760
-
-
- 4632046600466404668047040
-
-
- 4604046600466404668046960
-
-
- 4596046600466404668046960
-
-
- 4604046600466404668046720
-
-
- 4608046600466404668046920
-
-
- 4608046600466404668046720
-
-
- 4628046600466404668046760
-
-
- 4636046600466404668047040
-
-
-
-
- 3756038200382403848038600
-
-
- 4488045480455604560045640
-
-
- 5092051560516005180051960
-
-
- 5732057640578805792058240
-
-
- 6332063920639606400064600
-
-
- 6984069960700407024070400
-
-
- 7560076200762807632076880
-
-
- 7544076240762807632076840
-
-
- 7564076200762807632076960
-
-
- 7564076240762807632076440
-
-
- 7592076240762807632076400
-
-
- 7560076200762807632076920
-
-
- 7536076200762807632076440
-
-
- 7536076200762807632076960
-
-
- 7564076160762807632076960
-
-
- 7596076240762807632076400
-
-
-
-
- 5240052480525205280053720
-
-
- 6168062600626406268062800
-
-
- 7016071160713607148072160
-
-
- 7900079960800008000080920
-
-
- 8760088480887608880088880
-
-
- 9632097280973209736098600
-
-
- 105160105840106080106160107120
-
-
- 105200106040106120106160107080
-
-
- 104880105920106080106160106280
-
-
- 105760106000106120106160106280
-
-
- 104880105880106080106160107080
-
-
- 105720105960106120106160106240
-
-
- 104960105880106080106160106280
-
-
- 104880105880106120106160106280
-
-
- 105720105880106080106160106240
-
-
- 104920105840106120106160106280
-
-
-
-
+
+ SIS - SPARC/RISCV instruction simulator 2.30, copyright Jiri Gaisler 2020
+ Bug-reports to jiri@gaisler.se
+
+ GR740/LEON4 emulation enabled, 4 cpus online, delta 50 clocks
+
+ Loaded build/sparc/gr740/testsuites/tmtests/tmcontext01.exe, entry 0x00000000
+
+
+*** BEGIN OF TEST TMCONTEXT 1 ***
+*** TEST VERSION: 6.0.0.aa07dc10645c3dc855c3df2b53520aebc2751b06
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_SMP
+*** TEST TOOLS: 13.2.0 20230727 (RTEMS 6, RSB d3d738c35a71ca05f675b188539225099401ac79, Newlib a021448)
+*** BEGIN OF JSON DATA ***
+[
+ {
+ "environment": "HotCache",
+ "stats-by-function-nest-level": [
+ [2820, 2820, 2820, 2820, 2820],
+ [3640, 3640, 3640, 3640, 3640],
+ [4460, 4460, 4460, 4460, 4460],
+ [5280, 5280, 5280, 5280, 5280],
+ [6100, 6100, 6100, 6100, 6100],
+ [6920, 6920, 6920, 6920, 6920],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740]
+ ]
+ }, {
+ "environment": "DirtyCache",
+ "stats-by-function-nest-level": [
+ [2820, 2820, 2820, 2820, 2820],
+ [3640, 3640, 3640, 3640, 3640],
+ [4460, 4460, 4460, 4460, 4460],
+ [5280, 5280, 5280, 5280, 5280],
+ [6100, 6100, 6100, 6100, 6100],
+ [6920, 6920, 6920, 6920, 6920],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740]
+ ]
+ }, {
+ "environment": "Load/1",
+ "stats-by-function-nest-level": [
+ [2820, 2820, 2820, 2820, 2820],
+ [3640, 3640, 3640, 3640, 3640],
+ [4460, 4460, 4460, 4460, 4460],
+ [5280, 5280, 5280, 5280, 5280],
+ [6100, 6100, 6100, 6100, 6100],
+ [6920, 6920, 6920, 6920, 6920],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740]
+ ]
+ }, {
+ "environment": "Load/2",
+ "stats-by-function-nest-level": [
+ [2820, 2820, 2820, 2820, 2820],
+ [3640, 3640, 3640, 3640, 3640],
+ [4460, 4460, 4460, 4460, 4460],
+ [5280, 5280, 5280, 5280, 5280],
+ [6100, 6100, 6100, 6100, 6100],
+ [6920, 6920, 6920, 6920, 6920],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740]
+ ]
+ }, {
+ "environment": "Load/3",
+ "stats-by-function-nest-level": [
+ [2820, 2820, 2820, 2820, 2820],
+ [3640, 3640, 3640, 3640, 3640],
+ [4460, 4460, 4460, 4460, 4460],
+ [5280, 5280, 5280, 5280, 5280],
+ [6100, 6100, 6100, 6100, 6100],
+ [6920, 6920, 6920, 6920, 6920],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740],
+ [7740, 7740, 7740, 7740, 7740]
+ ]
+ }
+]
+*** END OF JSON DATA ***
+
+*** END OF TEST TMCONTEXT 1 ***
+
+cpu 3 in error mode (tt = 0x80)
+ 2081487650 00009060: 91d02000 ta 0x0