scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit e11ab93848714e96d346795e2cc4be2c86dce19c
parent f31dacb5f419d4e082230bd8366c97585e5c9b16
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Fri,  1 May 2026 13:21:02 +0200

tests/libc: Add 0091-atexit

Diffstat:
Mtests/libc/execute/.gitignore | 1+
Atests/libc/execute/0091-atexit.c | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtests/libc/execute/libc-tests.lst | 1+
3 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore @@ -89,3 +89,4 @@ test.log 0088-stroul 0089-stroull 0090-rand +0091-atexit diff --git a/tests/libc/execute/0091-atexit.c b/tests/libc/execute/0091-atexit.c @@ -0,0 +1,96 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +/* +output: +testing +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun1 +fun2 +fun3 +done +end: +*/ + +static void +fun1(void) +{ + puts("fun1"); +} + +static void +fun2(void) +{ + puts("fun2"); +} + +static void +fun3(void) +{ + puts("fun3"); + puts("done"); + fflush(stdout); + _Exit(0); +} + +static void +fun4(void) +{ + puts("fun4"); +} + +int +main(void) +{ + int i, r; + + puts("testing"); + r = atexit(fun4); + assert(r == 0); + + r = atexit(fun3); + assert(r == 0); + + r = atexit(fun2); + assert(r == 0); + + + for (i = 0; i < 29; i++) { + r = atexit(fun1); + assert(r == 0); + } + exit(EXIT_SUCCESS); + + printf("failed"); + exit(EXIT_FAILURE); + + return 1; +} diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst @@ -87,3 +87,4 @@ 0088-stroul 0089-stroull 0090-rand +0091-atexit