| 1 |
#! /bin/sh -vx |
| 2 |
# $Id: kpseaccess.test 45809 2017-11-15 00:36:56Z karl $ |
| 3 |
# Copyright 2017 Karl Berry <[email protected]> |
| 4 |
# Copyright 2010 Peter Breitenlohner <[email protected]> |
| 5 |
# You may freely use, modify and/or distribute this file. |
| 6 |
|
| 7 |
ret=0 |
| 8 |
|
| 9 |
pass () { |
| 10 |
echo "***** unexpected success of './kpseaccess $@'" |
| 11 |
ret=77 |
| 12 |
} |
| 13 |
|
| 14 |
fail () { |
| 15 |
echo "***** unexpected failure of './kpseaccess $@'" |
| 16 |
ret=77 |
| 17 |
} |
| 18 |
|
| 19 |
./kpseaccess '' nonesuch && exit 1 |
| 20 |
./kpseaccess - nonesuch && exit 1 |
| 21 |
./kpseaccess r nonesuch && exit 1 |
| 22 |
./kpseaccess w nonesuch && exit 1 |
| 23 |
./kpseaccess x nonesuch && exit 1 |
| 24 |
|
| 25 |
./kpseaccess '' access.o || exit 1 |
| 26 |
./kpseaccess - access.o || exit 1 |
| 27 |
./kpseaccess rw access.o || exit 1 |
| 28 |
# From the access(3p) POSIX manpage: |
| 29 |
# If the process has appropriate privileges, an implementation may indicate |
| 30 |
# success for X_OK even if none of the execute file permission bits are set. |
| 31 |
./kpseaccess x access.o && pass x access.o |
| 32 |
|
| 33 |
# Testing write access to kpseaccess itself might fail with ETXTBSY. |
| 34 |
./kpseaccess rwx kpsewhich || { |
| 35 |
fail rwx kpsewhich |
| 36 |
./kpseaccess r kpsewhich || fail r kpsewhich |
| 37 |
./kpseaccess w kpsewhich || fail w kpsewhich |
| 38 |
./kpseaccess x kpsewhich || fail x kpsewhich |
| 39 |
} |
| 40 |
|
| 41 |
./kpseaccess r $srcdir/access.c || exit 1 |
| 42 |
./kpseaccess x $srcdir/access.c && pass x $srcdir/access.c |
| 43 |
|
| 44 |
if ./kpseaccess w $srcdir/access.c; then |
| 45 |
echo 'file "$srcdir/access.c" is writable' |
| 46 |
else |
| 47 |
echo 'file "$srcdir/access.c" is not writable' |
| 48 |
fi |
| 49 |
|
| 50 |
exit $ret |
| 51 |
|