10 extern char **environ
;
18 t_error("environ is NULL\n");
19 if (clearenv() || (environ
&& *environ
))
20 t_error("clrearenv: %s\n", strerror(errno
));
22 t_error("putenv: %s\n", strerror(errno
));
23 if (strcmp(environ
[0],"TEST=1") != 0)
24 t_error("putenv failed: environ[0]: %s, wanted \"TEST=1\"\n", environ
[0]);
26 t_error("environ[1]: %p, wanted 0\n", s
);
27 if (!(s
=getenv("TEST")))
28 t_error("getenv(\"TEST\"): 0, wanted \"1\"\n");
29 if (strcmp(s
,"1") != 0)
30 t_error("getenv(\"TEST\"): \"%s\", wanted \"1\"\n", s
);
32 t_error("unsetenv: %s\n", strerror(errno
));
34 t_error("*environ: %p != 0\n", s
);
35 if ((s
=getenv("TEST")))
36 t_error("getenv(\"TEST\"): %p, wanted 0\n", s
);
38 if (setenv("TEST", "2", 0))
39 t_error("setenv: %s\n", strerror(errno
));
40 if (strcmp(s
=getenv("TEST"),"2") != 0)
41 t_error("getenv(\"TEST\"): \"%s\", wanted \"2\"\n", s
);
42 if (strcmp(environ
[0], "TEST=2") != 0)
43 t_error("setenv failed: environ[0]: %s, wanted \"TEST=2\"\n", environ
[0]);
45 if (setenv("TEST", "3", 0))
46 t_error("setenv: %s\n", strerror(errno
));
47 if (strcmp(s
=getenv("TEST"),"2") != 0)
48 t_error("getenv(\"TEST\"): \"%s\", wanted \"2\"\n", s
);
50 if (setenv("TEST", "3", 1))
51 t_error("setenv: %s\n", strerror(errno
));
52 if (strcmp(s
=getenv("TEST"),"3") != 0)
53 t_error("getenv(\"TEST\"): \"%s\", wanted \"3\"\n", s
);
56 if ((r
=setenv("","",0)) != -1 || errno
!= EINVAL
)
57 t_error("setenv(\"\",\"\",0): %d, errno: %d (%s), wanted -1, %d (EINVAL)\n", r
, errno
, strerror(errno
), EINVAL
);