ovni/test/emu/ovni/thread-free-isready.c
Rodrigo Arias 0439399f05 Fix ovni_thread_isready() after ovni_thread_free()
Until now, the value returned by ovni_thread_isready() was still
non-zero when the thread stream was destroyed in ovni_thread_free()
This was making it impossible to detect when a stream was destroyed.

This change makes it return 0 after ovni_thread_free() by using a new
finished flag. The flag keeps track on then the stream is destroyed,
preventing double initialization of a free stream.
2023-12-19 17:30:20 +01:00

28 lines
570 B
C

/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <ovni.h>
#include "instr.h"
/* Check the behavior of ovni_thread_isready(), which should only be 1
* after ovni_thread_init() and before ovni_thread_free(). */
int
main(void)
{
if (ovni_thread_isready())
die("thread must not be ready before init");
instr_start(0, 1);
if (!ovni_thread_isready())
die("thread must be ready after init");
instr_end();
if (ovni_thread_isready())
die("thread must not be ready after free");
return 0;
}