diff options
Diffstat (limited to 'usr/klibc/tests/setenvtest.c')
-rw-r--r-- | usr/klibc/tests/setenvtest.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/usr/klibc/tests/setenvtest.c b/usr/klibc/tests/setenvtest.c new file mode 100644 index 0000000..1b07199 --- /dev/null +++ b/usr/klibc/tests/setenvtest.c @@ -0,0 +1,39 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + /* Set SETENV */ + setenv("SETENV", "setenv", 1); + + /* Set PUTENV */ + putenv("PUTENV=putenv"); + + /* Print the results... */ + printf("SETENV = %s\n", getenv("SETENV")); + printf("PUTENV = %s\n", getenv("PUTENV")); + + /* Override tests */ + setenv("SETENV", "setenv_good", 1); + putenv("PUTENV=putenv_good"); + printf("SETENV = %s\n", getenv("SETENV")); + printf("PUTENV = %s\n", getenv("PUTENV")); + + /* Non-override test */ + setenv("SETENV", "setenv_bad", 0); + setenv("NEWENV", "newenv_good", 0); + printf("SETENV = %s\n", getenv("SETENV")); + printf("NEWENV = %s\n", getenv("NEWENV")); + + /* Undef test */ + unsetenv("SETENV"); + unsetenv("NEWENV"); + printf("SETENV = %s\n", getenv("SETENV")); + printf("NEWENV = %s\n", getenv("NEWENV")); + + return 0; +} |