Use simple test (without expect) for usage checking.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
Usage: expiry [options]
|
||||
|
||||
Options:
|
||||
-c, --check check the user's password expiration
|
||||
-f, --force force password change if the user's password
|
||||
is expired
|
||||
-h, --help display this help message and exit
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/sh
|
||||
send "if \[ \$(id -u) -eq 0 \]; then PS1='# '; else PS1='$ '; fi\r"
|
||||
expect "# "
|
||||
|
||||
send "expiry\r"
|
||||
expect "Usage: expiry {-f|-c}"
|
||||
expect "# "
|
||||
send "echo \$?\r"
|
||||
expect "10"
|
||||
expect "# "
|
||||
send "exit\r"
|
||||
puts "OK\n"
|
||||
exit 0
|
||||
@@ -16,7 +16,24 @@ trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
./expiry.exp
|
||||
echo -n "Call expiry without any option (expiry)..."
|
||||
expiry 2>tmp/usage.out && exit 1 || {
|
||||
status=$?
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
echo -n "Check returned status ($status)..."
|
||||
test "$status" = "2"
|
||||
echo "OK"
|
||||
|
||||
echo "expiry reported:"
|
||||
echo "======================================================================="
|
||||
cat tmp/usage.out
|
||||
echo "======================================================================="
|
||||
echo -n "Check the usage message..."
|
||||
diff -au data/usage.out tmp/usage.out
|
||||
echo "usage message OK."
|
||||
rm -f tmp/usage.out
|
||||
|
||||
echo -n "Check the passwd file..."
|
||||
../../common/compare_file.pl config/etc/passwd /etc/passwd
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
expiry: invalid option -- 'Z'
|
||||
Usage: expiry [options]
|
||||
|
||||
Options:
|
||||
-c, --check check the user's password expiration
|
||||
-f, --force force password change if the user's password
|
||||
is expired
|
||||
-h, --help display this help message and exit
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/sh
|
||||
send "if \[ \$(id -u) -eq 0 \]; then PS1='# '; else PS1='$ '; fi\r"
|
||||
expect "# "
|
||||
|
||||
send "expiry -Z\r"
|
||||
expect "Usage: expiry {-f|-c}"
|
||||
expect "# "
|
||||
send "echo \$?\r"
|
||||
expect "10"
|
||||
expect "# "
|
||||
send "exit\r"
|
||||
puts "OK\n"
|
||||
exit 0
|
||||
@@ -6,8 +6,7 @@ cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
log_start "$0" "expiry provides an Usage message if no options are given"
|
||||
log_start "$0" "expiry provides an Usage message if an invalid option is given"
|
||||
|
||||
save_config
|
||||
|
||||
@@ -16,7 +15,24 @@ trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
./expiry.exp
|
||||
echo -n "Call expiry with an invalid option (expiry -Z)..."
|
||||
expiry -Z 2>tmp/usage.out && exit 1 || {
|
||||
status=$?
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
echo -n "Check returned status ($status)..."
|
||||
test "$status" = "2"
|
||||
echo "OK"
|
||||
|
||||
echo "expiry reported:"
|
||||
echo "======================================================================="
|
||||
cat tmp/usage.out
|
||||
echo "======================================================================="
|
||||
echo -n "Check the usage message..."
|
||||
diff -au data/usage.out tmp/usage.out
|
||||
echo "usage message OK."
|
||||
rm -f tmp/usage.out
|
||||
|
||||
echo -n "Check the passwd file..."
|
||||
../../common/compare_file.pl config/etc/passwd /etc/passwd
|
||||
|
||||
Reference in New Issue
Block a user