Fix unit-stream test
This commit is contained in:
parent
d115ecad64
commit
8f4aa59148
@ -15,7 +15,7 @@ unit_test(cpu.c)
|
|||||||
unit_test(loom.c)
|
unit_test(loom.c)
|
||||||
unit_test(mux.c)
|
unit_test(mux.c)
|
||||||
unit_test(prv.c)
|
unit_test(prv.c)
|
||||||
#unit_test(stream.c) #FIXME
|
unit_test(stream.c)
|
||||||
unit_test(task.c)
|
unit_test(task.c)
|
||||||
unit_test(value.c)
|
unit_test(value.c)
|
||||||
unit_test(version.c)
|
unit_test(version.c)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
|
/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -11,10 +11,27 @@
|
|||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
#include "unittest.h"
|
#include "unittest.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_dummy_json(const char *path)
|
||||||
|
{
|
||||||
|
const char *json = "{ \"version\" : 3 }";
|
||||||
|
FILE *f = fopen(path, "w");
|
||||||
|
|
||||||
|
if (f == NULL)
|
||||||
|
die("fopen json failed:");
|
||||||
|
|
||||||
|
if (fwrite(json, strlen(json), 1, f) != 1)
|
||||||
|
die("fwrite json failed:");
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_ok(void)
|
test_ok(void)
|
||||||
{
|
{
|
||||||
const char *fname = "stream-ok.obs";
|
OK(mkdir("ok", 0755));
|
||||||
|
|
||||||
|
const char *fname = "ok/stream.obs";
|
||||||
FILE *f = fopen(fname, "w");
|
FILE *f = fopen(fname, "w");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
@ -30,8 +47,10 @@ test_ok(void)
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
write_dummy_json("ok/stream.json");
|
||||||
|
|
||||||
struct stream stream;
|
struct stream stream;
|
||||||
OK(stream_load(&stream, ".", fname));
|
OK(stream_load(&stream, ".", "ok"));
|
||||||
|
|
||||||
if (stream.active)
|
if (stream.active)
|
||||||
die("stream is active");
|
die("stream is active");
|
||||||
@ -42,7 +61,9 @@ test_ok(void)
|
|||||||
static void
|
static void
|
||||||
test_bad(void)
|
test_bad(void)
|
||||||
{
|
{
|
||||||
const char *fname = "stream-bad.obs";
|
OK(mkdir("bad", 0755));
|
||||||
|
|
||||||
|
const char *fname = "bad/stream.obs";
|
||||||
FILE *f = fopen(fname, "w");
|
FILE *f = fopen(fname, "w");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
@ -58,8 +79,10 @@ test_bad(void)
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
write_dummy_json("bad/stream.json");
|
||||||
|
|
||||||
struct stream stream;
|
struct stream stream;
|
||||||
ERR(stream_load(&stream, ".", fname));
|
ERR(stream_load(&stream, ".", "bad"));
|
||||||
|
|
||||||
err("OK");
|
err("OK");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user