From c424a3177dace500f8dce2be92af82b0f211ae3d Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 16 Nov 2023 12:03:28 +0100 Subject: [PATCH] Test temporal directories are removed at the end --- test/emu/ovni/CMakeLists.txt | 1 + test/emu/ovni/tmpdir-metadata.c | 22 ++++++++++ test/emu/ovni/tmpdir-metadata.driver.sh | 55 +++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 test/emu/ovni/tmpdir-metadata.c create mode 100644 test/emu/ovni/tmpdir-metadata.driver.sh diff --git a/test/emu/ovni/CMakeLists.txt b/test/emu/ovni/CMakeLists.txt index 1841254..879df11 100644 --- a/test/emu/ovni/CMakeLists.txt +++ b/test/emu/ovni/CMakeLists.txt @@ -23,3 +23,4 @@ test_emu(require-compat.c REGEX "loading trace in compatibility mode") test_emu(require-repeated.c) test_emu(thread-crash.c SHOULD_FAIL REGEX "incomplete stream") test_emu(flush-tmpdir.c MP DRIVER "flush-tmpdir.driver.sh") +test_emu(tmpdir-metadata.c MP DRIVER "tmpdir-metadata.driver.sh") diff --git a/test/emu/ovni/tmpdir-metadata.c b/test/emu/ovni/tmpdir-metadata.c new file mode 100644 index 0000000..f63637c --- /dev/null +++ b/test/emu/ovni/tmpdir-metadata.c @@ -0,0 +1,22 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" + +int +main(void) +{ + ovni_version_check(); + ovni_proc_init(1, "node.1", 123); + ovni_thread_init(123); + + ovni_add_cpu(0, 0); + instr_require("ovni"); + + instr_thread_execute(0, -1, 0); + instr_end(); + + return 0; +} diff --git a/test/emu/ovni/tmpdir-metadata.driver.sh b/test/emu/ovni/tmpdir-metadata.driver.sh new file mode 100644 index 0000000..9c7a8f2 --- /dev/null +++ b/test/emu/ovni/tmpdir-metadata.driver.sh @@ -0,0 +1,55 @@ +target=$OVNI_TEST_BIN + +# Ensure move all files to the final place, including the process metadata, the +# thread streams and metadata files. + +test_files() { + dst="$1" + test -e "$dst" + test -e "$dst/loom.node.1" + test -e "$dst/loom.node.1/proc.123" + test -e "$dst/loom.node.1/proc.123/metadata.json" + test -e "$dst/loom.node.1/proc.123/thread.123.json" + test -e "$dst/loom.node.1/proc.123/thread.123.obs" +} + +test_no_files() { + dst="$1" + test '!' -e "$dst" + test '!' -e "$dst/loom.node.1" + test '!' -e "$dst/loom.node.1/proc.123" + test '!' -e "$dst/loom.node.1/proc.123/metadata.json" + test '!' -e "$dst/loom.node.1/proc.123/thread.123.json" + test '!' -e "$dst/loom.node.1/proc.123/thread.123.obs" +} + +# Test setting OVNI_TMPDIR +( + mkdir tmp + export OVNI_TMPDIR=tmp + $target + test_files "ovni" + test_no_files "tmp" + ovniemu ovni +) + +# Test without tmpdir created +( + rm -f tmp + export OVNI_TMPDIR=tmp + $target + test_files "ovni" + test_no_files "tmp" + ovniemu ovni +) + +# Also with OVNI_TRACEDIR +( + mkdir tmp + export OVNI_TMPDIR=tmp + export OVNI_TRACEDIR="a/b" + $target + test_files "a/b" + test_no_files "tmp" + ovniemu ovni +)