summaryrefslogtreecommitdiffstats
path: root/pw/tests
diff options
context:
space:
mode:
authorBrad Davis <brd@FreeBSD.org>2015-02-24 22:22:06 +0000
committerBrad Davis <brd@FreeBSD.org>2015-02-24 22:22:06 +0000
commit9fc68690c69af5dd6a2440e749f34c62c59f9e81 (patch)
tree6de3a98e576fc93d3ba17a71b0bdd4c5e4a906de /pw/tests
parentd56b8ff0b4d62be404984f87a6b71509cd426875 (diff)
downloadpw-darwin-9fc68690c69af5dd6a2440e749f34c62c59f9e81.tar.gz
pw-darwin-9fc68690c69af5dd6a2440e749f34c62c59f9e81.tar.zst
pw-darwin-9fc68690c69af5dd6a2440e749f34c62c59f9e81.zip
Fix a race condition by allowing up to 5 seconds of difference between the time stamps.
PR: 197861 Approved by: will
Diffstat (limited to 'pw/tests')
-rwxr-xr-xpw/tests/pw_useradd.sh12
1 files changed, 8 insertions, 4 deletions
diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh
index 1934bbc..48612ed 100755
--- a/pw/tests/pw_useradd.sh
+++ b/pw/tests/pw_useradd.sh
@@ -114,9 +114,11 @@ user_add_account_expiration_date_relative_body() {
populate_etc_skel
EPOCH=`date -j -v+13m "+%s"`
+ BUF=`expr $EPOCH + 5`
atf_check -s exit:0 ${PW} useradd test -e +13o
- atf_check -s exit:0 -o match:"^test:\*:.*::0:${EPOCH}:User &:.*" \
- ${PW} usershow test
+ TIME=`${PW} usershow test | awk -F ':' '{print $7}'`
+ [ ! -z $TIME -a $TIME -ge $EPOCH -a $TIME -lt $BUF ] || \
+ atf_fail "Expiration time($TIME) was not within $EPOCH - $BUF seconds."
}
# Test add user with password expiration as an epoch date
@@ -160,9 +162,11 @@ user_add_password_expiration_date_relative_body() {
populate_etc_skel
EPOCH=`date -j -v+13m "+%s"`
+ BUF=`expr $EPOCH + 5`
atf_check -s exit:0 ${PW} useradd test -p +13o
- atf_check -s exit:0 -o match:"^test:\*:.*::${EPOCH}:0:User &:.*" \
- ${PW} usershow test
+ TIME=`${PW} usershow test | awk -F ':' '{print $6}'`
+ [ ! -z $TIME -a $TIME -ge $EPOCH -a $TIME -lt $BUF ] || \
+ atf_fail "Expiration time($TIME) was not within $EPOCH - $BUF seconds."
}
atf_init_test_cases() {