summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/kpseaccess.test
blob: 5006bcf1afa2cc8305e3e7e51cb391cc47a66a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh

# Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.

ret=0

pass () {
  echo "***** unexpected success of './kpseaccess $@'"
  ret=77
}

fail () {
  echo "***** unexpected failure of './kpseaccess $@'"
  ret=77
}

./kpseaccess '' nonesuch && exit 1
./kpseaccess - nonesuch && exit 1
./kpseaccess r nonesuch && exit 1
./kpseaccess w nonesuch && exit 1
./kpseaccess x nonesuch && exit 1

./kpseaccess '' access.o || exit 1
./kpseaccess - access.o || exit 1
./kpseaccess rw access.o || exit 1
# From the access(3p) POSIX manpage:
#   If the process has appropriate privileges, an implementation may indicate
#   success for X_OK even if none of the execute file permission bits are set.
./kpseaccess x access.o && pass x access.o

# Testing write access to kpseaccess itself might fail with ETXTBSY.
./kpseaccess rwx kpsewhich || {
  fail rwx kpsewhich
  ./kpseaccess r kpsewhich || fail r kpsewhich
  ./kpseaccess w kpsewhich || fail w kpsewhich
  ./kpseaccess x kpsewhich || fail x kpsewhich
}

./kpseaccess r $srcdir/access.c || exit 1
./kpseaccess x $srcdir/access.c && pass x $srcdir/access.c

if ./kpseaccess w $srcdir/access.c; then
  echo 'file "$srcdir/access.c" is writable'
else
  echo 'file "$srcdir/access.c" is not writable'
fi

exit $ret