shadow/tests/chage/02/run
Serge Hallyn b999d48941 Add tests from the old svn tree
We're losing the svn history (which we could probably keep if we tried
hard enough) but don't consider that worthwhile.

Note these tests are destructive, so run them only in a throwaway
environment like a chroot, container, or vm.

The tests/run.all script should be the one which launches all the tests.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-09-17 14:42:55 -05:00

51 lines
766 B
Bash
Executable File

#!/bin/sh
set -e
cd $(dirname $0)
# Rational:
# Test chage with bogus inputs
# no testsuite password
# root password: rootF00barbaz
# myuser password: myuserF00barbaz
save()
{
[ ! -d tmp ] && mkdir tmp
for i in passwd group shadow gshadow
do
[ -f /etc/$i ] && cp /etc/$i tmp/$i
[ -f /etc/$i- ] && cp /etc/$i- tmp/$i-
done
true
}
restore()
{
for i in passwd group shadow gshadow
do
[ -f tmp/$i ] && cp tmp/$i /etc/$i && rm tmp/$i
[ -f tmp/$i- ] && cp tmp/$i- /etc/$i- && rm tmp/$i-
done
rm -f tmp/out
rmdir tmp
}
save
# restore the files on exit
trap 'if [ "$?" != "0" ]; then echo "FAIL"; fi; restore' 0
for i in passwd group shadow gshadow
do
cp data/$i /etc
done
echo "interractive test"
./run.exp $(date "+%Y-%m-%d")
echo "OK"