Don't rely on temporary directories

Use the current test directory instead.
This commit is contained in:
Rodrigo Arias 2023-07-25 16:26:31 +02:00
parent c257405060
commit 74557ab348
3 changed files with 12 additions and 32 deletions

View File

@ -10,19 +10,12 @@
int main(void)
{
char dir[] = "/tmp/ovni.trace.XXXXXX";
if (mkdtemp(dir) == NULL)
die("mkdtemp failed:");
if (cfg_generate(dir) != 0)
if (cfg_generate(".") != 0)
die("cfg_generate failed");
/* Check that one configuration file is present */
char cfg[PATH_MAX];
sprintf(cfg, "%s/cfg/cpu/ovni/pid.cfg", dir);
struct stat st;
if (stat(cfg, &st) != 0)
if (stat("cfg/cpu/ovni/pid.cfg", &st) != 0)
die("stat failed");
return 0;

View File

@ -278,11 +278,7 @@ test_same_type(const char *path)
int main(void)
{
/* Create temporary trace file */
char fname[] = "/tmp/ovni.prv.XXXXXX";
int fd = mkstemp(fname);
if (fd < 0)
die("mkstemp failed:");
char fname[] = "ovni.prv";
test_emit(fname);
test_dup(fname);
@ -290,7 +286,5 @@ int main(void)
test_emitdup(fname);
test_same_type(fname);
close(fd);
return 0;
}

View File

@ -5,14 +5,16 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "common.h"
#include "emu/stream.h"
#include "ovni.h"
#include "unittest.h"
static void
test_ok(char *fname)
test_ok(void)
{
const char *fname = "stream-ok.obs";
FILE *f = fopen(fname, "w");
if (f == NULL)
@ -29,8 +31,7 @@ test_ok(char *fname)
fclose(f);
struct stream stream;
const char *relpath = &fname[5];
OK(stream_load(&stream, "/tmp", relpath));
OK(stream_load(&stream, ".", fname));
if (stream.active)
die("stream is active");
@ -39,8 +40,9 @@ test_ok(char *fname)
}
static void
test_bad(char *fname)
test_bad(void)
{
const char *fname = "stream-bad.obs";
FILE *f = fopen(fname, "w");
if (f == NULL)
@ -57,24 +59,15 @@ test_bad(char *fname)
fclose(f);
struct stream stream;
const char *relpath = &fname[5];
ERR(stream_load(&stream, "/tmp", relpath));
ERR(stream_load(&stream, ".", fname));
err("OK");
}
int main(void)
{
/* Create temporary trace file */
char fname[] = "/tmp/ovni.stream.XXXXXX";
int fd = mkstemp(fname);
if (fd < 0)
die("mkstemp failed:");
test_ok(fname);
test_bad(fname);
close(fd);
test_ok();
test_bad();
return 0;
}