1 /* $Id: setenv-t.c 7492 2006-03-19 23:07:34Z eagle $ */
2 /* setenv test suite. */
10 #include "inn/messages.h"
14 int test_setenv(const char *name, const char *value, int overwrite);
16 static const char test_var[] = "SETENV_TEST";
17 static const char test_value1[] = "Do not taunt Happy Fun Ball.";
18 static const char test_value2[] = "Do not use Happy Fun Ball on concrete.";
27 die("%s already in the environment!", test_var);
31 ok(1, test_setenv(test_var, test_value1, 0) == 0);
32 ok_string(2, test_value1, getenv(test_var));
33 ok(3, test_setenv(test_var, test_value2, 0) == 0);
34 ok_string(4, test_value1, getenv(test_var));
35 ok(5, test_setenv(test_var, test_value2, 1) == 0);
36 ok_string(6, test_value2, getenv(test_var));
37 ok(7, test_setenv(test_var, "", 1) == 0);
38 ok_string(8, "", getenv(test_var));
40 /* We're run by a shell script wrapper that sets resource limits such
41 that we can allocate one string of this size but not two. Note that
42 Linux doesn't support data limits, so skip if we get an unexpected
44 value = xmalloc(100 * 1024);
45 memset(value, 'A', 100 * 1024 - 1);
46 value[100 * 1024 - 1] = 0;
47 ok(9, test_setenv(test_var, value, 0) == 0);
48 ok_string(10, "", getenv(test_var));
49 status = test_setenv(test_var, value, 1);
51 puts("ok 11 # skip - no data limit support");
52 puts("ok 12 # skip - no data limit support");
54 ok(11, (status == -1) && (errno == ENOMEM));
55 ok_string(12, "", getenv(test_var));