5 confdir=${dir:-$(dirname "$0")}
6 maindir=${dir:-$(dirname "$0")}
7 while [ ! -r "$confdir/conf" -a "$confdir" != / ]; do
8 confdir=$(cd $confdir/..; pwd)
10 while [ "$maindir" != / ]; do
11 if [ -f "$maindir/pjdfstest" -a -x "$maindir/pjdfstest" ]; then
14 maindir=$(cd $maindir/../; pwd)
16 fstest="${maindir}/pjdfstest"
17 if ! . ${confdir}/conf; then
18 echo "not ok - could not source configuration file"
21 if [ ! -x $fstest ]; then
22 echo "not ok - could not find pjdfstest app"
33 echo "not ok ${ntest} not root"
43 r=`${fstest} $* 2>/dev/null | tail -1`
44 echo "${r}" | ${GREP} -Eq '^'${e}'$'
46 if [ -z "${todomsg}" ]; then
49 echo "ok ${ntest} # TODO ${todomsg}"
52 if [ -z "${todomsg}" ]; then
53 echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}"
55 echo "not ok ${ntest} # TODO ${todomsg}"
69 r=`jail -s ${s} / pjdfstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 2>/dev/null" 2>/dev/null | tail -1`
70 echo "${r}" | ${GREP} -Eq '^'${e}'$'
72 if [ -z "${todomsg}" ]; then
75 echo "ok ${ntest} # TODO ${todomsg}"
78 if [ -z "${todomsg}" ]; then
79 echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}"
81 echo "not ok ${ntest} # TODO ${todomsg}"
91 if [ -z "${todomsg}" ]; then
94 echo "ok ${ntest} # TODO ${todomsg}"
97 if [ -z "${todomsg}" ]; then
98 echo "not ok ${ntest}"
100 echo "not ok ${ntest} # TODO ${todomsg}"
109 if [ "${os}" = "${1}" -o "${os}:${fs}" = "${1}" ]; then
116 echo "pjdfstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`"
125 namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`"
126 name="${name}${namepart}"
127 curlen=`printf "%s" "${name}" | wc -c`
128 [ ${curlen} -lt ${len} ] || break
130 name=`echo "${name}" | cut -b -${len}`
131 printf "%s" "${name}"
136 # Maximum number of bytes in a filename (not including terminating null).
139 name_max=`${fstest} pathconf . _PC_NAME_MAX`
140 namegen_len ${name_max}
145 # Maximum number of bytes in a pathname, including the terminating null character.
148 name_max=`${fstest} pathconf . _PC_NAME_MAX`
149 complen=$((name_max/2))
150 path_max=`${fstest} pathconf . _PC_PATH_MAX`
151 # "...including the terminating null character."
152 path_max=$((path_max-1))
156 name="${name}`namegen_len ${complen}`/"
157 curlen=`printf "%s" "${name}" | wc -c`
158 [ ${curlen} -lt ${path_max} ] || break
160 name=`echo "${name}" | cut -b -${path_max}`
161 name=`echo "${name}" | sed -E 's@/$@x@'`
162 printf "%s" "${name}"
176 if [ "${os}" != "FreeBSD" ]; then
181 if [ "${os}" != "FreeBSD" ]; then
186 if [ "${os}" != "FreeBSD" -o "${fs}" != "UFS" ]; then
191 if [ "${os}" != "FreeBSD" ]; then
217 if supported ${1}; then
223 if [ "${os}" = "FreeBSD" ]; then
226 df $1 | tail -1 | awk '{ print $6 }'
231 mount -p | awk '$2 == "'$(mountpoint .)'" { print $4 }' | sed -e 's/,/ /g'
236 if mount_options | grep -q nfsv4acls; then
244 if mount_options | grep -q noexec; then
252 if mount_options | grep -q nosuid; then
281 # create_file <type> <name>
282 # create_file <type> <name> <mode>
283 # create_file <type> <name> <uid> <gid>
284 # create_file <type> <name> <mode> <uid> <gid>
294 expect 0 create ${name} 0644
297 expect 0 mkdir ${name} 0755
300 expect 0 mkfifo ${name} 0644
303 expect 0 mknod ${name} b 0644 1 2
306 expect 0 mknod ${name} c 0644 1 2
309 expect 0 bind ${name}
312 expect 0 symlink test ${name}
315 if [ -n "${3}" -a -n "${4}" -a -n "${5}" ]; then
316 if [ "${type}" = symlink ]; then
317 expect 0 lchmod ${name} ${3}
319 expect 0 chmod ${name} ${3}
321 expect 0 lchown ${name} ${4} ${5}
322 elif [ -n "${3}" -a -n "${4}" ]; then
323 expect 0 lchown ${name} ${3} ${4}
324 elif [ -n "${3}" ]; then
325 if [ "${type}" = symlink ]; then
326 expect 0 lchmod ${name} ${3}
328 expect 0 chmod ${name} ${3}
333 # Tests for whether or not a filesystem is mounted with a particular option
334 # with -o, e.g. `mount -o noexec`.
337 # - mount_option - noatime, noexec, etc.
340 # - 0 if mounted with the option.
347 local mount_option_search=$1
349 # XXX: mountpoint is defined in .../tests/sys/pjdfstest/tests/conf
350 for mount_opt in $(mount -d -p | awk '$2 == "'$mountpoint'" { print $4 }'); do
351 if [ "$mount_opt" = "$mount_option_search" ]; then
358 # Filesystem must be mounted with -o exec
361 if has_mount_option noexec; then
362 echo "1..0 # SKIP filesystem mounted with -o noexec"