X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=blobdiff_plain;f=src%2Fregression%2Fmkstemp-failure.c;fp=src%2Fregression%2Fmkstemp-failure.c;h=762f1fcc7f690faf388343c5b62967951d82fc4f;hp=0000000000000000000000000000000000000000;hb=cfa23cc1bd01f5c44d7746b8b1839f84d5e1b6eb;hpb=b775d19f7ff58da3fe009d48742068cc92a274f2 diff --git a/src/regression/mkstemp-failure.c b/src/regression/mkstemp-failure.c new file mode 100644 index 0000000..762f1fc --- /dev/null +++ b/src/regression/mkstemp-failure.c @@ -0,0 +1,28 @@ +// commit: 2e6239dd064d201c6e1b0f589bae9ff27949d2eb 2011-02-19 +// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12 +// mkstemp should return -1 on bad template +#define _BSD_SOURCE 1 +#include +#include +#include +#include "test.h" + +int mkstemp(char *); + +#define S "/dev/null/fooXXXX" + +int main(void) +{ + char p[] = S; + int r; + + r = mkstemp(p); + if (r != -1) + t_error("mkstemp(" S ") did not fail\n"); + if (memcmp(p, S, sizeof p) != 0) + t_error("mkstemp(" S ") modified the template: %s\n", p); + if (r == -1 && errno != EINVAL) + t_error("mkstemp(" S ") failed with %d [%s] instead of %d [%s]\n", + errno, strerror(errno), EINVAL, strerror(EINVAL)); + return t_status; +}