From 019528ee6a6327cd3b5dccbecd21dc26c4d25ef6 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 16 Jun 2017 16:27:56 +0200 Subject: [PATCH] Disable lock tests on platforms without priorities The implementations of the lock and C++ guards tests depend on thread-execution priorities, which produces false negatives of the whole thread test on platforms without priority support. --- repos/base/run/thread.run | 29 ++++++++++++++++++----------- repos/base/src/test/thread/main.cc | 16 ++++++++++++---- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/repos/base/run/thread.run b/repos/base/run/thread.run index 21720e2af6..54b96bcb26 100644 --- a/repos/base/run/thread.run +++ b/repos/base/run/thread.run @@ -7,13 +7,25 @@ create_boot_directory # supported. # proc pause_resume_supported { } { - if {[have_spec pistachio]} { return 0 } - if {[have_spec linux]} { return 0 } - if {[have_spec fiasco]} { return 0 } - return 1; + if {[have_spec pistachio]} { return false } + if {[have_spec linux]} { return false } + if {[have_spec fiasco]} { return false } + return true } -set config { +# +# We skip the lock and C++ guard tests on kernels without priority support (as +# it is needed for the test implementation). +# +proc prio_supported { } { + if {[have_spec hw]} { return false } + if {[have_spec sel4]} { return false } + if {[have_spec linux]} { return false } + if {[have_spec fiasco]} { return false } + return true +} + +append config { @@ -27,12 +39,7 @@ set config { - } - -append_if [pause_resume_supported] config { } - -append config { - + } diff --git a/repos/base/src/test/thread/main.cc b/repos/base/src/test/thread/main.cc index 5c819cdc11..ab02eb48ab 100644 --- a/repos/base/src/test/thread/main.cc +++ b/repos/base/src/test/thread/main.cc @@ -21,6 +21,7 @@ #include #include #include +#include using namespace Genode; @@ -407,6 +408,12 @@ static void test_locks(Genode::Env &env) Lock_helper l5(env, "lock_low5", cpu_l, lock, lock_is_free, SYNC_STARTUP); l5.start(); + log(" spin for some time"); + for (unsigned volatile i = 0; i < 8000000; ++i) memory_barrier(); + log(" still spinning"); + for (unsigned volatile i = 0; i < 8000000; ++i) memory_barrier(); + log(" spinning done"); + lock.lock(); log(" I'm the lock holder - still alive"); lock_is_free = true; @@ -648,10 +655,11 @@ void Component::construct(Env &env) test_stack_alignment(env); test_main_thread(); test_cpu_session(env); - test_locks(env); - test_cxa_guards(env); - - if (config.xml().has_sub_node("pause_resume")) + if (config.xml().attribute_value("prio", false)) { + test_locks(env); + test_cxa_guards(env); + } + if (config.xml().attribute_value("pause_resume", false)) test_pause_resume(env); test_create_as_many_threads(env);