|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +fini() { |
| 6 | + local retval="$?" |
| 7 | + |
| 8 | + rm -rf ${destdir} \ |
| 9 | + /usr/lib/libnss_ato*.so* \ |
| 10 | + /etc/libnss-ato.conf |
| 11 | + |
| 12 | + echo "" |
| 13 | + make clean |
| 14 | + |
| 15 | + if [ $retval -eq 0 ]; then |
| 16 | + echo -e "\nAll tests PASSED\n" |
| 17 | + else |
| 18 | + echo -e "\nOne or more tests FAILED\n" 1>&2 |
| 19 | + fi |
| 20 | + |
| 21 | + exit "$retval" |
| 22 | +} |
| 23 | + |
| 24 | +trap fini EXIT |
| 25 | + |
| 26 | +echo -e "\nBuild test ...\n" |
| 27 | +make |
| 28 | +echo -e "\nBuild test PASS ...\n" |
| 29 | + |
| 30 | +echo -e "\nInstall test ...\n" |
| 31 | + |
| 32 | +destdir="$PWD/tmp" |
| 33 | +make install DESTDIR="${destdir}" |
| 34 | + |
| 35 | +ls ${destdir}/usr/lib/libnss_ato*.so* |
| 36 | +test -s ${destdir}/etc/libnss-ato.conf |
| 37 | +test -s ${destdir}/usr/share/man/man3/libnss-ato.3 |
| 38 | + |
| 39 | +echo -e "\nInstall test PASS ...\n" |
| 40 | + |
| 41 | +echo -e "\nFunctionality tests ..." |
| 42 | + |
| 43 | +echo "Try with root user ..." |
| 44 | +./libnss_ato_test root |
| 45 | + |
| 46 | +echo -e "\nTry with non existent user without enabling libnss-ato ..." |
| 47 | + |
| 48 | +if ./libnss_ato_test test123; then |
| 49 | + echo "Passed with non existent user without enabling libnss-ato ..." 1>&2 |
| 50 | + exit 1 |
| 51 | +fi |
| 52 | + |
| 53 | +echo -e "\nFailed as expected ..." |
| 54 | + |
| 55 | +echo -e "\nEnable libnss-ato now ..." |
| 56 | + |
| 57 | +cp ${destdir}/usr/lib/libnss_ato*.so* /usr/lib/ |
| 58 | +cp ${destdir}/etc/libnss-ato.conf /etc/ |
| 59 | + |
| 60 | +ldconfig |
| 61 | + |
| 62 | +echo "t:x:1000:1000:Test User:/home/test:/bin/bash" >> /etc/libnss-ato.conf |
| 63 | + |
| 64 | +sed -ie '/^passwd:/ s/$/ ato/' /etc/nsswitch.conf |
| 65 | +sed -ie '/^shadow:/ s/$/ ato/' /etc/nsswitch.conf |
| 66 | + |
| 67 | +echo -e "\nTry with non existent user after enabling libnss-ato ..." |
| 68 | + |
| 69 | +if ! ./libnss_ato_test test123; then |
| 70 | + echo "Failed with non existent user after enabling libnss-ato ..." 1>&2 |
| 71 | + exit 1 |
| 72 | +fi |
| 73 | + |
| 74 | +echo -e "\nFunctionality tests PASS ...\n" |
| 75 | +exit 0 |
0 commit comments