From f22d9084ba1b80b15bd1ad7d8cb8520d4f500241 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Tue, 21 Mar 2023 16:43:49 +0100 Subject: [PATCH] Ensure all looms have at least one CPU --- src/emu/system.c | 8 ++++++++ test/emu/ovni/CMakeLists.txt | 3 ++- test/emu/ovni/no-cpus.c | 13 +++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/emu/ovni/no-cpus.c diff --git a/src/emu/system.c b/src/emu/system.c index 07914a4..02c7df0 100644 --- a/src/emu/system.c +++ b/src/emu/system.c @@ -183,6 +183,14 @@ create_system(struct system *sys, struct trace *trace) stream_data_set(s, lpt); } + /* Ensure all looms have at least one CPU */ + for (struct loom *l = sys->looms; l; l = l->next) { + if (l->ncpus == 0) { + err("loom %s has no physical CPUs", l->id); + return -1; + } + } + return 0; } diff --git a/test/emu/ovni/CMakeLists.txt b/test/emu/ovni/CMakeLists.txt index 323d209..053755a 100644 --- a/test/emu/ovni/CMakeLists.txt +++ b/test/emu/ovni/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Barcelona Supercomputing Center (BSC) +# Copyright (c) 2022-2023 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later # Only run performance sensitive tests on Release builds @@ -16,3 +16,4 @@ ovni_test(mp-simple.c MP) ovni_test(version-good.c) ovni_test(version-bad.c SHOULD_FAIL REGEX "version mismatch") ovni_test(clockgate.c MP SHOULD_FAIL REGEX "detected large clock gate") +ovni_test(no-cpus.c SHOULD_FAIL REGEX "loom .* has no physical CPUs") diff --git a/test/emu/ovni/no-cpus.c b/test/emu/ovni/no-cpus.c new file mode 100644 index 0000000..1d446a2 --- /dev/null +++ b/test/emu/ovni/no-cpus.c @@ -0,0 +1,13 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include "instr_ovni.h" + +int +main(void) +{ + instr_start(0, 0); + instr_end(); + + return 0; +}