summaryrefslogtreecommitdiff
path: root/src/bin/evil/evil_test_mkstemp.c
blob: a716b726aa12e51eb56d8de858c97569dec9709d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */

#include <string.h>

#include <Evil.h>

#include "evil_suite.h"
#include "evil_test_mkstemp.h"


static int
test_mkstemp_test(void)
{
   char  _template[PATH_MAX];
#ifdef _WIN32_WCE
   char  cwd[PATH_MAX];
#endif
   int   fd;

#ifdef _WIN32_WCE
   if (!getcwd(cwd, PATH_MAX))
     return 0;
   _snprintf(_template, PATH_MAX, "%s\\%s", cwd, "file_XXXXXX");
#else
   _snprintf(_template, PATH_MAX, "%s", "file_XXXXXX");
#endif

   fd = mkstemp(_template);

   if (fd < 0)
     return 0;

   return 1;
}

static int
test_mkstemp_run(suite *s)
{
   int res;

   res = test_mkstemp_test();

   return res;
}

int
test_mkstemp(suite *s)
{

   return test_mkstemp_run(s);
}