Blame src/regression/mkstemp-failure.c

Szabolcs Nagy cfa23c
// commit: 2e6239dd064d201c6e1b0f589bae9ff27949d2eb 2011-02-19
Szabolcs Nagy cfa23c
// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12
Szabolcs Nagy cfa23c
// mkstemp 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
int mkstemp(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
	int r;
Szabolcs Nagy cfa23c
Szabolcs Nagy cfa23c
	r = mkstemp(p);
Szabolcs Nagy cfa23c
	if (r != -1)
Szabolcs Nagy cfa23c
		t_error("mkstemp(" S ") did not fail\n");
Szabolcs Nagy cfa23c
	if (memcmp(p, S, sizeof p) != 0)
Szabolcs Nagy cfa23c
		t_error("mkstemp(" S ") modified the template: %s\n", p);
Szabolcs Nagy cfa23c
	if (r == -1 && errno != EINVAL)
Szabolcs Nagy cfa23c
		t_error("mkstemp(" 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
}