* Author: Daniel Stone <daniel@fooishbar.org>
*/
+#include "config.h"
+
#include "test.h"
#include "context.h"
-#include <unistd.h>
#include <sys/stat.h>
-#include <dirent.h>
+#include <sys/types.h>
/* keeps a cache of all makedir/maketmpdir directories so we can free and
* rmdir them in one go, see unmakedirs() */
static const char *makedir(const char *parent, const char *path)
{
- char *dirname;
- int err;
-
- err = asprintf(&dirname, "%s/%s", parent, path);
- assert(err >= 0);
- err = mkdir(dirname, 0777);
- assert(err == 0);
-
+ char *dirname = test_makedir(parent, path);
dirnames[ndirs++] = dirname;
-
return dirname;
}
static const char *maketmpdir(void)
{
- const char *template = "/tmp/xkbcommon-test.XXXXXX";
- char *tmpdir = strdup(template);
-
- tmpdir = mkdtemp(tmpdir);
- assert(tmpdir != NULL);
-
+ char *tmpdir = test_maketempdir("xkbcommon-test.XXXXXX");
dirnames[ndirs++] = tmpdir;
-
return tmpdir;
}
const char *xkbdir = DFLT_XKB_CONFIG_ROOT;
const char *context_path;
int nincludes;
- DIR *dir;
/* quick and dirty check that the default directory exists.
* It may not on a vanilla test box if we just run the test
* suite, so where it's not there just skip this test. */
- dir = opendir(xkbdir);
- if (!dir)
+ struct stat stat_buf;
+ int err = stat(xkbdir, &stat_buf);
+ if (err != 0)
+ return;
+ if (!S_ISDIR(stat_buf.st_mode))
return;
- closedir(dir);
buffer_env("XKB_CONFIG_ROOT");
buffer_env("HOME");