mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
test: new test, verify behavior of global environment variables
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
38db52aa4e
commit
d70d86e9fe
3 files changed
+72
-1
No files matched your search
+14
-1
@@ -38,6 +38,15 @@ static void verify_env(char *arg)
|
||||
errx(1, "Mismatch, environment '%s' vs expected value '%s'", env, value);
|
||||
}
|
||||
|
||||
static void verify_noenv(char *key)
|
||||
{
|
||||
char *val;
|
||||
|
||||
val = getenv(key);
|
||||
if (val)
|
||||
errx(1, "Error, key %s is set in environment to '%s'", key, val);
|
||||
}
|
||||
|
||||
static void sig(int signo)
|
||||
{
|
||||
warnx("We got signal %d ...", signo);
|
||||
@@ -73,6 +82,7 @@ static int usage(int rc)
|
||||
"\n"
|
||||
" -h Show help text (this)\n"
|
||||
" -e K:V Verify K environment variable is V value\n"
|
||||
" -E K Verify K is not set in the environment\n"
|
||||
" -n Run in foreground\n"
|
||||
" -p Create PID file despite running in foreground\n"
|
||||
" -P FILE Create PID file using FILE\n"
|
||||
@@ -93,13 +103,16 @@ int main(int argc, char *argv[])
|
||||
char *pidfn = NULL;
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "e:hnpP:")) != EOF) {
|
||||
while ((c = getopt(argc, argv, "e:E:hnpP:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
return usage(0);
|
||||
case 'e':
|
||||
verify_env(optarg);
|
||||
break;
|
||||
case 'E':
|
||||
verify_noenv(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
do_background = 0;
|
||||
do_pidfile--;
|
||||
|
||||
Reference in new issue
Block a user