From 81d939f947fcfb2a94fae2bd7c1d1f8c2249d6fe Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Thu, 12 Aug 2021 16:00:29 +0200 Subject: [PATCH] test-trace: test destruction of trace subjects If the trace subjects are not properly destructed when the TRACE client disappears, enabled sources will be owned by a non-existing client. In other words, when a TRACE client disappears all sources owned by the client must be disabled. genodelabs/genode#4247 --- repos/os/recipes/pkg/test-trace/archives | 1 + repos/os/recipes/pkg/test-trace/runtime | 30 ++++++++++++++++++++---- repos/os/src/test/trace/main.cc | 14 +++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/repos/os/recipes/pkg/test-trace/archives b/repos/os/recipes/pkg/test-trace/archives index fab959b6e9..22150643ad 100644 --- a/repos/os/recipes/pkg/test-trace/archives +++ b/repos/os/recipes/pkg/test-trace/archives @@ -1,3 +1,4 @@ _/src/init _/src/top _/src/test-trace +_/src/sequence diff --git a/repos/os/recipes/pkg/test-trace/runtime b/repos/os/recipes/pkg/test-trace/runtime index f17ed6448f..6ab434391e 100644 --- a/repos/os/recipes/pkg/test-trace/runtime +++ b/repos/os/recipes/pkg/test-trace/runtime @@ -4,7 +4,7 @@ - child "test-trace" exited with exit value 0 + child "sequence" exited with exit value 0 Error: @@ -12,6 +12,7 @@ + @@ -31,11 +32,30 @@ - - - + + + - + + + + + + + + + + + + + + + + + + + + diff --git a/repos/os/src/test/trace/main.cc b/repos/os/src/test/trace/main.cc index 3e810859d4..22b24f9721 100644 --- a/repos/os/src/test/trace/main.cc +++ b/repos/os/src/test/trace/main.cc @@ -196,6 +196,7 @@ struct Test_tracing typedef Genode::String<64> String; String policy_label { }; String policy_module { }; + String policy_thread { }; Rom_dataspace_capability policy_module_rom_ds { }; @@ -232,6 +233,7 @@ struct Test_tracing Xml_node policy = config.xml().sub_node("trace_policy"); policy.attribute("label").value(policy_label); policy.attribute("module").value(policy_module); + policy.attribute("thread").value(policy_thread); Rom_connection policy_rom(env, policy_module.string()); policy_module_rom_ds = policy_rom.dataspace(); @@ -281,12 +283,20 @@ struct Test_tracing for_each_subject(subjects, num_subjects, print_info); + auto check_untraced = [this] (Trace::Subject_id id, Trace::Subject_info info) { + + if (info.state() != Trace::Subject_info::UNTRACED) + error("Subject ", id.id, " is not UNTRACED"); + }; + + for_each_subject(subjects, num_subjects, check_untraced); + /* enable tracing for test-thread */ auto enable_tracing = [this, &env] (Trace::Subject_id id, Trace::Subject_info info) { if ( info.session_label() != policy_label - || info.thread_name() != "test-thread") { + || info.thread_name() != policy_thread) { return; } @@ -320,7 +330,7 @@ struct Test_tracing log("passed Tracing test"); } else - error("Thread '", thread_name, "' not found for session ", policy_label); + error("Thread '", policy_thread, "' not found for session ", policy_label); } };