From c783764d0b34f56bd8933b68c17ac9325a3be64b Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 3 Apr 2020 15:51:36 +0200 Subject: [PATCH] Region-map attach/detach stress depot_autopilot test Issue #3715 --- repos/base/recipes/pkg/test-rm_stress/README | 1 + .../base/recipes/pkg/test-rm_stress/archives | 2 + repos/base/recipes/pkg/test-rm_stress/hash | 1 + repos/base/recipes/pkg/test-rm_stress/runtime | 29 ++++++++ .../recipes/src/test-rm_stress/content.mk | 2 + repos/base/recipes/src/test-rm_stress/hash | 1 + .../base/recipes/src/test-rm_stress/used_apis | 1 + repos/base/src/test/rm_stress/main.cc | 70 +++++++++++++++++++ repos/base/src/test/rm_stress/target.mk | 3 + repos/gems/run/depot_autopilot.run | 1 + 10 files changed, 111 insertions(+) create mode 100644 repos/base/recipes/pkg/test-rm_stress/README create mode 100644 repos/base/recipes/pkg/test-rm_stress/archives create mode 100644 repos/base/recipes/pkg/test-rm_stress/hash create mode 100644 repos/base/recipes/pkg/test-rm_stress/runtime create mode 100644 repos/base/recipes/src/test-rm_stress/content.mk create mode 100644 repos/base/recipes/src/test-rm_stress/hash create mode 100644 repos/base/recipes/src/test-rm_stress/used_apis create mode 100644 repos/base/src/test/rm_stress/main.cc create mode 100644 repos/base/src/test/rm_stress/target.mk diff --git a/repos/base/recipes/pkg/test-rm_stress/README b/repos/base/recipes/pkg/test-rm_stress/README new file mode 100644 index 000000000..c7dddfaac --- /dev/null +++ b/repos/base/recipes/pkg/test-rm_stress/README @@ -0,0 +1 @@ +Scenario that stresses region-map attachments diff --git a/repos/base/recipes/pkg/test-rm_stress/archives b/repos/base/recipes/pkg/test-rm_stress/archives new file mode 100644 index 000000000..4683afc27 --- /dev/null +++ b/repos/base/recipes/pkg/test-rm_stress/archives @@ -0,0 +1,2 @@ +_/src/init +_/src/test-rm_stress diff --git a/repos/base/recipes/pkg/test-rm_stress/hash b/repos/base/recipes/pkg/test-rm_stress/hash new file mode 100644 index 000000000..5ea347ff7 --- /dev/null +++ b/repos/base/recipes/pkg/test-rm_stress/hash @@ -0,0 +1 @@ +2020-04-02 d6b3e6026d373f74858d7a1b4759aeb431e43afc diff --git a/repos/base/recipes/pkg/test-rm_stress/runtime b/repos/base/recipes/pkg/test-rm_stress/runtime new file mode 100644 index 000000000..4097dbb75 --- /dev/null +++ b/repos/base/recipes/pkg/test-rm_stress/runtime @@ -0,0 +1,29 @@ + + + + + child "test-rm_stress" exited with exit value 0 + child "test-rm_stress" exited with exit value -1 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/repos/base/recipes/src/test-rm_stress/content.mk b/repos/base/recipes/src/test-rm_stress/content.mk new file mode 100644 index 000000000..0cb35455b --- /dev/null +++ b/repos/base/recipes/src/test-rm_stress/content.mk @@ -0,0 +1,2 @@ +SRC_DIR = src/test/rm_stress +include $(GENODE_DIR)/repos/base/recipes/src/content.inc diff --git a/repos/base/recipes/src/test-rm_stress/hash b/repos/base/recipes/src/test-rm_stress/hash new file mode 100644 index 000000000..75b2a9703 --- /dev/null +++ b/repos/base/recipes/src/test-rm_stress/hash @@ -0,0 +1 @@ +2020-04-02 39f4647992e33fba4b5aea0d490285e4cee797b1 diff --git a/repos/base/recipes/src/test-rm_stress/used_apis b/repos/base/recipes/src/test-rm_stress/used_apis new file mode 100644 index 000000000..df967b96a --- /dev/null +++ b/repos/base/recipes/src/test-rm_stress/used_apis @@ -0,0 +1 @@ +base diff --git a/repos/base/src/test/rm_stress/main.cc b/repos/base/src/test/rm_stress/main.cc new file mode 100644 index 000000000..7b66fac0c --- /dev/null +++ b/repos/base/src/test/rm_stress/main.cc @@ -0,0 +1,70 @@ +/* + * \brief Test program for stressing region-map attachments + * \author Christian Helmuth + * \date 2020-04-03 + */ + +/* + * Copyright (C) 2020 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +/* Genode includes */ +#include +#include +#include + + +using namespace Genode; + +struct X : Genode::Hex +{ + template + explicit X(T value) : Genode::Hex(value, OMIT_PREFIX, PAD) { } +}; + + +struct Page : Attached_ram_dataspace +{ + unsigned char const color; + + Page(Env &env, unsigned char color) + : + Attached_ram_dataspace(env.ram(), env.rm(), 0x1000), + color(color) + { + memset(local_addr(), color, size()); + + log("new page @ ", local_addr(), " with color ", X(*local_addr())); + } +}; + + +void Component::construct(Env &env) +{ + log("--- region-map attachment stress test ---"); + + Page page[] = { { env, 0xaa }, { env, 0x55 } }; + + enum { ROUNDS = 10000 }; + + for (unsigned r = 0; r < ROUNDS; ++r) { + for (unsigned i = 0; i < sizeof(page)/sizeof(*page); ++i) { + off_t const offset = 0; + + unsigned char volatile const *v = + env.rm().attach(page[i].cap(), page[i].size(), offset); + + if (page[i].color != *v) { + error("value @ ", v, " ", X(*v), " != ", X(page[i].color), " in round ", r); + env.parent().exit(-1); + } + + env.rm().detach(Region_map::Local_addr(v)); + } + } + + env.parent().exit(0); +} diff --git a/repos/base/src/test/rm_stress/target.mk b/repos/base/src/test/rm_stress/target.mk new file mode 100644 index 000000000..179e69521 --- /dev/null +++ b/repos/base/src/test/rm_stress/target.mk @@ -0,0 +1,3 @@ +TARGET = test-rm_stress +SRC_CC = main.cc +LIBS = base diff --git a/repos/gems/run/depot_autopilot.run b/repos/gems/run/depot_autopilot.run index 5a36ac806..9b033a10d 100644 --- a/repos/gems/run/depot_autopilot.run +++ b/repos/gems/run/depot_autopilot.run @@ -707,6 +707,7 @@ set default_test_pkgs { test-rm_fault test-rm_fault_no_nox test-rm_nested + test-rm_stress test-rom_block test-rom_filter test-rust