Blame src/regression/mkdtemp-failure.c

Szabolcs Nagy cfa23c
// commit: 69ecbd0f3188be97f91cc0d6415836d23e88f7fc 2011-02-19
Szabolcs Nagy cfa23c
// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12
Szabolcs Nagy cfa23c
// mkdtemp should return -1 on bad template
Szabolcs Nagy cfa23c
#define _BSD_SOURCE 1
Szabolcs Nagy cfa23c
#include <stdlib.h>
Szabolcs Nagy cfa23c
#include <string.h>
Szabolcs Nagy cfa23c
#include <errno.h>
Szabolcs Nagy cfa23c
#include "test.h"
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
char *mkdtemp(char *);
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
#define S "/dev/null/fooXXXX"
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
int main(void)
Szabolcs Nagy cfa23c
{
Szabolcs Nagy cfa23c
	char p[] = S;
Szabolcs Nagy cfa23c
	char *r;
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
	r = mkdtemp(p);
Szabolcs Nagy cfa23c
	if (r)
Szabolcs Nagy cfa23c
		t_error("mkdtemp(" S ") did not fail\n");
Szabolcs Nagy cfa23c
	if (memcmp(p, S, sizeof p) != 0)
Szabolcs Nagy cfa23c
		t_error("mkdtemp(" S ") modified the template: %s\n", p);
Szabolcs Nagy cfa23c
	if (r == 0 && errno != EINVAL)
Szabolcs Nagy cfa23c
		t_error("mkdtemp(" S ") failed with %d [%s] instead of %d [%s]\n",
Szabolcs Nagy cfa23c
			errno, strerror(errno), EINVAL, strerror(EINVAL));
Szabolcs Nagy cfa23c
	return t_status;
Szabolcs Nagy cfa23c
}