Blob Blame History Raw
// commit: 69ecbd0f3188be97f91cc0d6415836d23e88f7fc 2011-02-19
// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12
// mkdtemp should return -1 on bad template
#define _BSD_SOURCE 1
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "test.h"

char *mkdtemp(char *);

#define S "/dev/null/fooXXXX"

int main(void)
{
	char p[] = S;
	char *r;

	r = mkdtemp(p);
	if (r)
		t_error("mkdtemp(" S ") did not fail\n");
	if (memcmp(p, S, sizeof p) != 0)
		t_error("mkdtemp(" S ") modified the template: %s\n", p);
	if (r == 0 && errno != EINVAL)
		t_error("mkdtemp(" S ") failed with %d [%s] instead of %d [%s]\n",
			errno, strerror(errno), EINVAL, strerror(EINVAL));
	return t_status;
}