Test temporal directories are removed at the end

This commit is contained in:
Rodrigo Arias 2023-11-16 12:03:28 +01:00
parent 3267ea873f
commit c424a3177d
3 changed files with 78 additions and 0 deletions

View File

@ -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")

View File

@ -0,0 +1,22 @@
/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdlib.h>
#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;
}

View File

@ -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
)