test: process input/output, args, and environment test

This commit is contained in:
2026-06-20 15:29:32 +01:00
parent c41131eac8
commit c29c687076
+18 -31
View File
@@ -1,40 +1,27 @@
#include <stdarg.h>
#include <fx/diagnostics/process.h>
#include <stdio.h>
static int another_function(int a, double b, int c)
int main(int argc, const char **argv)
{
printf("a=%d, b=%lf, c=%d\n", a, b, c);
return 2;
printf("%d args:\n", argc);
for (int i = 0; i < argc; i++) {
printf("%s\n", argv[i]);
}
static int test_function(int a, int b, int c, ...)
{
va_list args;
va_start(args, c);
int d = va_arg(args, int);
int e = va_arg(args, int);
int f = va_arg(args, int);
int g = va_arg(args, int);
int h = va_arg(args, int);
int i = va_arg(args, int);
int j = va_arg(args, int);
printf("a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d, h=%d, i=%d, j=%d\n",
a,
b,
c,
d,
e,
f,
g,
h,
i,
j);
return a + b + c + d + e;
printf("environment:\n");
fx_process *self = fx_process_get_self();
const fx_hashtable *env = fx_process_get_environment(self);
fx_object_to_string(env, fx_stdout, NULL);
printf("\n");
printf("read from stdin...\n");
char line[128];
if (fgets(line, sizeof line, stdin)) {
printf("read: %s\n", line);
} else {
printf("read failed\n");
}
int main(void)
{
test_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
another_function(1, 2.5, 5);
return 0;
}