scc

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

commit 10686ff83b100fbf8f51b136fe5b351be6014226
parent 442f7a3a7ae3ad6412dbee2b688a85bef45a89f7
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Wed,  6 May 2026 20:58:19 +0200

tests/libc: Add 0097-fops

Diffstat:
Mtests/libc/execute/.gitignore | 1+
Atests/libc/execute/0097-fops.c | 39+++++++++++++++++++++++++++++++++++++++
Mtests/libc/execute/libc-tests.lst | 1+
3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore @@ -95,3 +95,4 @@ test.log 0094-bsearch 0095-abs 0096-div +0097-fops diff --git a/tests/libc/execute/0097-fops.c b/tests/libc/execute/0097-fops.c @@ -0,0 +1,39 @@ +#include <assert.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +/* +output: +testing +done +end: +*/ + +int +main(void) +{ + char buff[40], *s; + FILE *fp; + + puts("testing"); + fp = fopen("__NOT_A_FILE", "w"); + assert(fp); + fputs("Hello\n", fp); + fflush(fp); + assert(ferror(fp) == 0); + fclose(fp); + assert(rename("__NOT_A_FILE", "__NOT_OTHER_FILE") == 0); + + fp = fopen("__NOT_OTHER_FILE", "r"); + assert(fp); + s = fgets(buff, sizeof(buff), fp); + assert(s != NULL); + assert(strcmp(s, "Hello\n") == 0); + fclose(fp); + + assert(remove("__NOT_OTHER_FILE") == 0); + puts("done"); + + return 0; +} diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst @@ -93,3 +93,4 @@ 0094-bsearch 0095-abs 0096-div +0097-fops