commit 630099c016f0cb6c231f10e78b77926ae57bdfaf
parent e11ab93848714e96d346795e2cc4be2c86dce19c
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 1 May 2026 18:56:31 +0200
tests/libc: Add 0092-getenv
Diffstat:
9 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/include/scc/bits/darwin/sys/stdlib.h b/include/scc/bits/darwin/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/dragonfly/sys/stdlib.h b/include/scc/bits/dragonfly/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/freebsd/sys/stdlib.h b/include/scc/bits/freebsd/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/linux/sys/stdlib.h b/include/scc/bits/linux/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/netbsd/sys/stdlib.h b/include/scc/bits/netbsd/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/include/scc/bits/openbsd/sys/stdlib.h b/include/scc/bits/openbsd/sys/stdlib.h
@@ -1,2 +1,3 @@
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+#define __SCC_PUTENV__
diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
@@ -90,3 +90,4 @@ test.log
0089-stroull
0090-rand
0091-atexit
+0092-getenv
diff --git a/tests/libc/execute/0092-getenv.c b/tests/libc/execute/0092-getenv.c
@@ -0,0 +1,32 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int putenv(char *);
+
+int
+main(void)
+{
+ char *s;
+
+ puts("testing");
+ s = getenv("THIS_CANNOT_BE_A_ENV_CAR");
+ assert(s == NULL);
+
+#if defined(__unix__) || defined(__SCC_PUTENV__)
+ putenv("AVAR=avalue");
+ s = getenv("AVAR");
+ assert(strcmp(s, "avalue") == 0);
+#endif
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
@@ -88,3 +88,4 @@
0089-stroull
0090-rand
0091-atexit
+0092-getenv