regression: setenv-oom test
authorSzabolcs Nagy <nsz@port70.net>
Sat, 5 Oct 2013 14:04:45 +0000 (14:04 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Sat, 5 Oct 2013 14:04:45 +0000 (14:04 +0000)
src/regression/execle-env.c
src/regression/setenv-oom.c [new file with mode: 0644]

index d3a8b4e..21f296c 100644 (file)
@@ -1,3 +1,4 @@
+// commit 2b2aff37aced66e4a50a38a14607a9b1dc0ee001 2013-10-03
 // execle should pass env properly
 #include <string.h>
 #include <errno.h>
diff --git a/src/regression/setenv-oom.c b/src/regression/setenv-oom.c
new file mode 100644 (file)
index 0000000..d7e6162
--- /dev/null
@@ -0,0 +1,25 @@
+// commit 543787039098c121917cb5f3e129d84b61afa61b 2013-10-04
+// setenv should not crash on oom
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "test.h"
+
+int main(void)
+{
+       char buf[10000];
+
+       if (t_vmfill(0,0,0) < 0)
+               t_error("vmfill failed: %s\n", strerror(errno));
+
+       memset(buf, 'x', sizeof buf);
+       buf[sizeof buf - 1] = 0;
+
+       errno = 0;
+       if (setenv("TESTVAR", buf, 1) != -1)
+               t_error("setenv was successful\n");
+       if (errno != ENOMEM)
+               t_error("expected ENOMEM, got %s\n", strerror(errno));
+
+       return t_status;
+}