string test alignment fix by Mahesh Bodapati
[libc-test.git] / src / regression / setenv-oom.c
blob678031072feb2243ca39ef1d628c334883a83a4a
1 // commit 543787039098c121917cb5f3e129d84b61afa61b 2013-10-04
2 // setenv should not crash on oom
3 #include <stdlib.h>
4 #include <sys/resource.h>
5 #include <string.h>
6 #include <errno.h>
7 #include "test.h"
9 int main(void)
11 char buf[10000];
13 if (t_memfill() < 0)
14 t_error("memfill failed\n");
16 memset(buf, 'x', sizeof buf);
17 buf[sizeof buf - 1] = 0;
19 errno = 0;
20 if (setenv("TESTVAR", buf, 1) != -1)
21 t_error("setenv was successful\n");
22 if (errno != ENOMEM)
23 t_error("expected ENOMEM, got %s\n", strerror(errno));
25 return t_status;