Don't rely on temporary directories
Use the current test directory instead.
This commit is contained in:
parent
c257405060
commit
74557ab348
@ -10,19 +10,12 @@
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
char dir[] = "/tmp/ovni.trace.XXXXXX";
|
if (cfg_generate(".") != 0)
|
||||||
if (mkdtemp(dir) == NULL)
|
|
||||||
die("mkdtemp failed:");
|
|
||||||
|
|
||||||
if (cfg_generate(dir) != 0)
|
|
||||||
die("cfg_generate failed");
|
die("cfg_generate failed");
|
||||||
|
|
||||||
/* Check that one configuration file is present */
|
/* Check that one configuration file is present */
|
||||||
char cfg[PATH_MAX];
|
|
||||||
sprintf(cfg, "%s/cfg/cpu/ovni/pid.cfg", dir);
|
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(cfg, &st) != 0)
|
if (stat("cfg/cpu/ovni/pid.cfg", &st) != 0)
|
||||||
die("stat failed");
|
die("stat failed");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -278,11 +278,7 @@ test_same_type(const char *path)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* Create temporary trace file */
|
char fname[] = "ovni.prv";
|
||||||
char fname[] = "/tmp/ovni.prv.XXXXXX";
|
|
||||||
int fd = mkstemp(fname);
|
|
||||||
if (fd < 0)
|
|
||||||
die("mkstemp failed:");
|
|
||||||
|
|
||||||
test_emit(fname);
|
test_emit(fname);
|
||||||
test_dup(fname);
|
test_dup(fname);
|
||||||
@ -290,7 +286,5 @@ int main(void)
|
|||||||
test_emitdup(fname);
|
test_emitdup(fname);
|
||||||
test_same_type(fname);
|
test_same_type(fname);
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "emu/stream.h"
|
#include "emu/stream.h"
|
||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
#include "unittest.h"
|
#include "unittest.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_ok(char *fname)
|
test_ok(void)
|
||||||
{
|
{
|
||||||
|
const char *fname = "stream-ok.obs";
|
||||||
FILE *f = fopen(fname, "w");
|
FILE *f = fopen(fname, "w");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
@ -29,8 +31,7 @@ test_ok(char *fname)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
struct stream stream;
|
struct stream stream;
|
||||||
const char *relpath = &fname[5];
|
OK(stream_load(&stream, ".", fname));
|
||||||
OK(stream_load(&stream, "/tmp", relpath));
|
|
||||||
|
|
||||||
if (stream.active)
|
if (stream.active)
|
||||||
die("stream is active");
|
die("stream is active");
|
||||||
@ -39,8 +40,9 @@ test_ok(char *fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_bad(char *fname)
|
test_bad(void)
|
||||||
{
|
{
|
||||||
|
const char *fname = "stream-bad.obs";
|
||||||
FILE *f = fopen(fname, "w");
|
FILE *f = fopen(fname, "w");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
@ -57,24 +59,15 @@ test_bad(char *fname)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
struct stream stream;
|
struct stream stream;
|
||||||
const char *relpath = &fname[5];
|
ERR(stream_load(&stream, ".", fname));
|
||||||
ERR(stream_load(&stream, "/tmp", relpath));
|
|
||||||
|
|
||||||
err("OK");
|
err("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* Create temporary trace file */
|
test_ok();
|
||||||
char fname[] = "/tmp/ovni.stream.XXXXXX";
|
test_bad();
|
||||||
int fd = mkstemp(fname);
|
|
||||||
if (fd < 0)
|
|
||||||
die("mkstemp failed:");
|
|
||||||
|
|
||||||
test_ok(fname);
|
|
||||||
test_bad(fname);
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user