summaryrefslogtreecommitdiffstats
path: root/tools/regression/environ
diff options
context:
space:
mode:
authorscf <scf@FreeBSD.org>2008-04-23 00:45:48 +0000
committerscf <scf@FreeBSD.org>2008-04-23 00:45:48 +0000
commite3c15650b08e098db24738aa1cd64372ffcb7d45 (patch)
tree927961012ab3927bb03e75245d7290cfadc10bca /tools/regression/environ
parent8d647da1edcc4aad93660da8a41dc09f628eb53c (diff)
downloadFreeBSD-src-e3c15650b08e098db24738aa1cd64372ffcb7d45.zip
FreeBSD-src-e3c15650b08e098db24738aa1cd64372ffcb7d45.tar.gz
Differentiate in the tests against getenv() between an empty string and a
NULL by having the test program return *NULL* for NULL's (no existing variable) instead of an empty string (variable with empty value).
Diffstat (limited to 'tools/regression/environ')
-rw-r--r--tools/regression/environ/envctl.c2
-rw-r--r--tools/regression/environ/envtest.t25
2 files changed, 15 insertions, 12 deletions
diff --git a/tools/regression/environ/envctl.c b/tools/regression/environ/envctl.c
index a63270d..c433fa0 100644
--- a/tools/regression/environ/envctl.c
+++ b/tools/regression/environ/envctl.c
@@ -126,7 +126,7 @@ main(int argc, char **argv)
case 'G':
case 'g':
value = getenv(arg == 'g' ? optarg : NULL);
- printf("%s%s", value == NULL ? "" : value, eol);
+ printf("%s%s", value == NULL ? "*NULL*" : value, eol);
break;
case 'p':
diff --git a/tools/regression/environ/envtest.t b/tools/regression/environ/envtest.t
index 2b2c548..d3243d3 100644
--- a/tools/regression/environ/envtest.t
+++ b/tools/regression/environ/envtest.t
@@ -68,6 +68,9 @@ check_result()
# Regression tests
#
+# How NULL will be returned by program.
+readonly NULL="\*NULL\*"
+
# Setup environment for tests.
readonly BAR="bar"
readonly NEWBAR="newbar"
@@ -79,16 +82,16 @@ run_test -g FOO
check_result "${FOO}"
run_test -c -g FOO
-check_result ""
+check_result "${NULL}"
run_test -g FOOBAR
-check_result ""
+check_result "${NULL}"
run_test -c -g FOOBAR
-check_result ""
+check_result "${NULL}"
run_test -G
-check_result ""
+check_result "${NULL}"
# Sets.
@@ -138,10 +141,10 @@ check_result "0 0 ${BAR} 0 0 ${NEWBAR}"
# Unsets.
run_test -u FOO -g FOO
-check_result "0 0"
+check_result "0 0 ${NULL}"
run_test -c -u FOO -g FOO
-check_result "0 0"
+check_result "0 0 ${NULL}"
run_test -U
check_result "-1 22"
@@ -153,11 +156,11 @@ run_test -u "=${BAR}"
check_result "-1 22"
run_test -c -s FOO ${NEWBAR} 1 -g FOO -u FOO -g FOO
-check_result "0 0 ${NEWBAR} 0 0"
+check_result "0 0 ${NEWBAR} 0 0 ${NULL}"
run_test -c -u FOO -s FOO ${BAR} 1 -g FOO -u FOO -g FOO -c -u FOO\
-s FOO ${NEWBAR} 1 -g FOO
-check_result "0 0 0 0 ${BAR} 0 0 0 0 0 0 ${NEWBAR}"
+check_result "0 0 0 0 ${BAR} 0 0 ${NULL} 0 0 0 0 ${NEWBAR}"
# Puts.
@@ -189,7 +192,7 @@ run_test -s FOO ${NEWBAR} 1 -p FOO=${BAR} -u FOO
check_result "0 0 0 0 0 0"
run_test -s FOO ${NEWBAR} 1 -p FOO=${BAR} -c -g FOO -p FOO=${NEWBAR} -g FOO
-check_result "0 0 0 0 0 0 ${NEWBAR}"
+check_result "0 0 0 0 ${NULL} 0 0 ${NEWBAR}"
run_test -c -p FOO=${BAR} -g FOO -c -p FOO=${NEWBAR} -g FOO
check_result "0 0 ${BAR} 0 0 ${NEWBAR}"
@@ -197,7 +200,7 @@ check_result "0 0 ${BAR} 0 0 ${NEWBAR}"
# environ replacements.
run_test -r -g FOO -s FOO ${BAR} 1 -g FOO -u FOO -g FOO
-check_result "${BAR} 0 0 ${BAR} 0 0"
+check_result "${BAR} 0 0 ${BAR} 0 0 ${NULL}"
run_test -r -g FOO -u FOO -g FOO -s FOO ${BAR} 1 -g FOO
-check_result "${BAR} 0 0 0 0 ${BAR}"
+check_result "${BAR} 0 0 ${NULL} 0 0 ${BAR}"
OpenPOWER on IntegriCloud