• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // commit: 2e6239dd064d201c6e1b0f589bae9ff27949d2eb 2011-02-19
2 // commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12
3 // mkstemp should return -1 on bad template
4 #define _DEFAULT_SOURCE 1
5 #define _BSD_SOURCE 1
6 #include <stdlib.h>
7 #include <string.h>
8 #include <errno.h>
9 #include "test.h"
10 
11 int mkstemp(char *);
12 
13 #define S "/dev/null/fooXXXX"
14 
main(void)15 int main(void)
16 {
17 	char p[] = S;
18 	int r;
19 
20 	r = mkstemp(p);
21 	if (r != -1)
22 		t_error("mkstemp(" S ") did not fail\n");
23 	if (memcmp(p, S, sizeof p) != 0)
24 		t_error("mkstemp(" S ") modified the template: %s\n", p);
25 	if (r == -1 && errno != EINVAL)
26 		t_error("mkstemp(" S ") failed with %d [%s] instead of %d [%s]\n",
27 			errno, strerror(errno), EINVAL, strerror(EINVAL));
28 	return t_status;
29 }
30