commit d9b6c4384a9995d70c3bfa352d343a84c7491059
parent 33141db27c405bbec69efaa2808b502d091c36e8
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 29 May 2026 14:34:10 +0200
tests/libc: Add 0099-tmpnam
Diffstat:
3 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
@@ -97,3 +97,4 @@ test.log
0096-div
0097-fops
0098-tmpfil
+0099-tmpnam
diff --git a/tests/libc/execute/0099-tmpnam.c b/tests/libc/execute/0099-tmpnam.c
@@ -0,0 +1,46 @@
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+
+int
+test(void)
+{
+ int j, i, max;
+ char buf[32][L_tmpnam];
+
+ assert(TMP_MAX >= 25);
+
+ assert(tmpnam(NULL));
+
+ max = TMP_MAX - 1;
+ if (max > FOPEN_MAX - 3)
+ max = FOPEN_MAX - 3;
+ if (max > 32)
+ max = 32;
+
+ for (i = 0; i < max; ++i) {
+ assert(tmpnam(buf[i]));
+ for (j = 0; j < i; j++)
+ assert(strcmp(buf[i], buf[j]) != 0);
+ }
+
+ return 0;
+}
+
+int
+main(void)
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
@@ -95,3 +95,4 @@
0096-div
0097-fops
0098-tmpfil
+0099-tmpnam