summaryrefslogtreecommitdiff
path: root/regress/check-perms/spec
blob: ae7deb88d4bb917d96af0564cde7087dc74e0d3a (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
51
52
53
54
55
56
57
58
#! /bin/sh
# $NetBSD: spec,v 1.1 2019/09/19 23:53:36 rillig Exp $
set -eu

do_cleanup() {
	$TEST_MAKE deinstall clean
}

do_make() {
	echo "Running test case $*"

	#$TEST_MAKE "$@" show-all-check-perms

	$TEST_MAKE "$@" deinstall clean install 1>"$TEST_OUTFILE" 2>&1 \
	&& TEST_EXITSTATUS=0 || TEST_EXITSTATUS=$?
}

test_no_developer_no_autofix() {
	do_make PKG_DEVELOPER=no CHECK_PERMS_AUTOFIX=no

	exit_status 0
}

test_no_developer_autofix() {
	do_make PKG_DEVELOPER=no CHECK_PERMS_AUTOFIX=yes

	# FIXME: The permissions must be fixed even though PKG_DEVELOPER=no.
	exit_status 0
	output_prohibit "^error: .*: world-writable file"
}

test_developer_no_autofix() {
	do_make PKG_DEVELOPER=yes CHECK_PERMS_AUTOFIX=no

	exit_status 1
	output_require "^warning: .*/demo-file: too small to be a valid executable file"
	output_require "^warning: .*/demo-file: group-writable file"
	output_require "^error: .*/demo-file: world-writable file"
}

test_developer_autofix() {
	do_make PKG_DEVELOPER=yes CHECK_PERMS_AUTOFIX=yes

	# FIXME: Since all permission problems have been fixed, the exit status must be 0.
	# This needs to be fixed in checkperms upstream.
	exit_status 1
	output_require "^warning: .*/demo-file: too small to be a valid executable file"
	output_require "^warning: .*/demo-file: group-writable file"
	output_require "^error: .*/demo-file: world-writable file"
	output_require "^note: .*/demo-file: fixed permissions from 0777 to 0644"
}

do_test() {
	test_no_developer_no_autofix
	test_no_developer_autofix
	test_developer_no_autofix
	test_developer_autofix
}