return 1;
}
+static int cmp(void const *a, void const *b) {
+ return strcmp(*(char * const *)a, *(char * const *)b);
+}
static void dump(char *argv[]) {
size_t i;
while (*argv) {
printf("argv[%zu] = |%s|\n", i++, *argv++);
}
+
+ /* Order of environment variables is not defined, sort them for consistent
+ * test results. */
i = 0;
char **env = environ;
+ while (*env++) {
+ i++;
+ }
+ qsort(environ, i, sizeof(*env), cmp);
+
+ i = 0;
+ env = environ;
while (*env) {
/* Skip LD_PRELOAD which contains system dependent values. */
if (strncmp(*env, "LD_PRELOAD=", 11)) {
- printf("environ[%zu] = |%s|\n", i, *env);
+ printf("environ[%zu] = |%s|\n", i++, *env);
}
- i++;
env++;
}
printf("\n");
/* Fake output to let the test pass. */
} else if (!skip--) {
puts("argv[0] = |./example_exec|");
- puts("environ[0] = |TEST=54|");
- puts("environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,|");
+ puts("environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|");
+ puts("environ[1] = |TEST=54|");
puts("");
puts("argv[0] = |./example_exec|");
puts("argv[1] = |foo|");
puts("argv[2] = |bar|");
- puts("environ[0] = |TEST=55|");
- puts("environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,|");
+ puts("environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|");
+ puts("environ[1] = |TEST=55|");
puts("");
#endif
}
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
CHECKING COLORING.
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,3,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,3,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,5,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,5,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,5,6,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,5,6,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,7,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,3,4,7,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,3,8,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,3,8,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_FDS=5,|
-environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,5,|
+environ[0] = |COLORED_STDERR_FDS=5,|
+environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,5,|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=6,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=6,|
argv[0] = |./example_exec|
+environ[0] = |COLORED_STDERR_FDS=2,|
environ[1] = |COLORED_STDERR_PRIVATE_FDS=|
-environ[2] = |COLORED_STDERR_FDS=2,|
CHECKING TRANSPARENCY.
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
argv[0] = |./example_exec|
-environ[0] = |TEST=42|
-environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[1] = |TEST=42|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=43|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=43|
argv[0] = |./example_exec|
-environ[0] = |TEST=44|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=44|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=45|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=45|
argv[0] = |./example_exec|
-environ[0] = |TEST=46|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=46|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=47|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=47|
argv[0] = |./example_exec|
-environ[1] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
argv[0] = |./example_exec|
-environ[0] = |TEST=48|
-environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[1] = |TEST=48|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=49|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=49|
argv[0] = |./example_exec|
-environ[0] = |TEST=50|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=50|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=51|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=51|
argv[0] = |./example_exec|
-environ[0] = |TEST=52|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=52|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=53|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
environ[1] = |FOO=|
-environ[3] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[2] = |TEST=53|
argv[0] = |./example_exec|
-environ[0] = |TEST=54|
-environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[1] = |TEST=54|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
-environ[0] = |TEST=55|
-environ[2] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[0] = |COLORED_STDERR_PRIVATE_FDS=2,|
+environ[1] = |TEST=55|
Done.