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
+20 -33
View File
@@ -1,40 +1,27 @@
#include <stdarg.h> #include <fx/diagnostics/process.h>
#include <stdio.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); printf("%d args:\n", argc);
return 2;
}
static int test_function(int a, int b, int c, ...) for (int i = 0; i < argc; i++) {
{ printf("%s\n", argv[i]);
va_list args; }
va_start(args, c);
int d = va_arg(args, int); printf("environment:\n");
int e = va_arg(args, int); fx_process *self = fx_process_get_self();
int f = va_arg(args, int); const fx_hashtable *env = fx_process_get_environment(self);
int g = va_arg(args, int); fx_object_to_string(env, fx_stdout, NULL);
int h = va_arg(args, int); printf("\n");
int i = va_arg(args, int);
int j = va_arg(args, int); printf("read from stdin...\n");
printf("a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d, h=%d, i=%d, j=%d\n", char line[128];
a, if (fgets(line, sizeof line, stdin)) {
b, printf("read: %s\n", line);
c, } else {
d, printf("read failed\n");
e, }
f,
g,
h,
i,
j);
return a + b + c + d + e;
}
int main(void)
{
test_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
another_function(1, 2.5, 5);
return 0; return 0;
} }