1570af302Sopenharmony_ci// commit: 2e6239dd064d201c6e1b0f589bae9ff27949d2eb 2011-02-19 2570af302Sopenharmony_ci// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12 3570af302Sopenharmony_ci// mkstemp should return -1 on bad template 4570af302Sopenharmony_ci#define _DEFAULT_SOURCE 1 5570af302Sopenharmony_ci#define _BSD_SOURCE 1 6570af302Sopenharmony_ci#include <stdlib.h> 7570af302Sopenharmony_ci#include <string.h> 8570af302Sopenharmony_ci#include <errno.h> 9570af302Sopenharmony_ci#include "test.h" 10570af302Sopenharmony_ci 11570af302Sopenharmony_ciint mkstemp(char *); 12570af302Sopenharmony_ci 13570af302Sopenharmony_ci#define S "/dev/null/fooXXXX" 14570af302Sopenharmony_ci 15570af302Sopenharmony_ciint main(void) 16570af302Sopenharmony_ci{ 17570af302Sopenharmony_ci char p[] = S; 18570af302Sopenharmony_ci int r; 19570af302Sopenharmony_ci 20570af302Sopenharmony_ci r = mkstemp(p); 21570af302Sopenharmony_ci if (r != -1) 22570af302Sopenharmony_ci t_error("mkstemp(" S ") did not fail\n"); 23570af302Sopenharmony_ci if (memcmp(p, S, sizeof p) != 0) 24570af302Sopenharmony_ci t_error("mkstemp(" S ") modified the template: %s\n", p); 25570af302Sopenharmony_ci if (r == -1 && errno != EINVAL) 26570af302Sopenharmony_ci t_error("mkstemp(" S ") failed with %d [%s] instead of %d [%s]\n", 27570af302Sopenharmony_ci errno, strerror(errno), EINVAL, strerror(EINVAL)); 28570af302Sopenharmony_ci return t_status; 29570af302Sopenharmony_ci} 30