Skip to content

Commit a6a11c6

Browse files
committed
regress/check-perms: add test for broken CHECK_PERMS_AUTOFIX
The variable CHECK_PERMS_AUTOFIX has been existing since 2006 but is not used in any package. This may be because it is not helpful in any way. When a package sets this variables to yes, the permission errors are not silently fixed, but the build still fails instead. This behavior is not useful in any way and thus needs to be fixed. See https://mail-index.netbsd.org/tech-pkg/2019/08/thread1.html#021828
1 parent cd72df5 commit a6a11c6

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

regress/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: Makefile,v 1.24 2019/07/17 18:34:16 rillig Exp $
1+
# $NetBSD: Makefile,v 1.25 2019/09/19 23:53:36 rillig Exp $
22
#
33
# See https://www.netbsd.org/docs/pkgsrc/regression.html for more
44
# information about these tests.
@@ -11,6 +11,7 @@ SUBDIR+= bootstrap-install-sh
1111
SUBDIR+= buildlink-libtool
1212
SUBDIR+= buildlink-transform
1313
SUBDIR+= buildlink-unwrap
14+
SUBDIR+= check-perms
1415
SUBDIR+= check-portability
1516
SUBDIR+= compiler
1617
SUBDIR+= env-vars

regress/check-perms/DESCR

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Regression test for mk/check/check-perms.mk.

regress/check-perms/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# $NetBSD: Makefile,v 1.1 2019/09/19 23:53:36 rillig Exp $
2+
3+
DISTNAME= check-perms-1.0
4+
CATEGORIES= regress
5+
MASTER_SITES= # none
6+
DISTFILES= # none
7+
8+
MAINTAINER= [email protected]
9+
COMMENT= Ensures that wrong file permissions are fixed
10+
LICENSE= 2-clause-bsd
11+
12+
NO_CHECKSUM= yes
13+
WRKSRC= ${WRKDIR}
14+
BUILD_DIRS= # none
15+
AUTO_MKDIRS= yes
16+
17+
USE_TOOLS+= pax
18+
19+
do-extract:
20+
cd ${WRKSRC} && > demo-file && chmod 777 demo-file
21+
22+
do-install:
23+
cd ${WRKSRC} && pax -wr -pp demo-file ${DESTDIR}${PREFIX}/share/regress-check-perms/
24+
25+
.include "../../mk/bsd.pkg.mk"

regress/check-perms/PLIST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@comment $NetBSD: PLIST,v 1.1 2019/09/19 23:53:36 rillig Exp $
2+
share/regress-check-perms/demo-file

regress/check-perms/spec

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#! /bin/sh
2+
# $NetBSD: spec,v 1.1 2019/09/19 23:53:36 rillig Exp $
3+
set -eu
4+
5+
do_cleanup() {
6+
$TEST_MAKE deinstall clean
7+
}
8+
9+
do_make() {
10+
echo "Running test case $*"
11+
12+
#$TEST_MAKE "$@" show-all-check-perms
13+
14+
$TEST_MAKE "$@" deinstall clean install 1>"$TEST_OUTFILE" 2>&1 \
15+
&& TEST_EXITSTATUS=0 || TEST_EXITSTATUS=$?
16+
}
17+
18+
test_no_developer_no_autofix() {
19+
do_make PKG_DEVELOPER=no CHECK_PERMS_AUTOFIX=no
20+
21+
exit_status 0
22+
}
23+
24+
test_no_developer_autofix() {
25+
do_make PKG_DEVELOPER=no CHECK_PERMS_AUTOFIX=yes
26+
27+
# FIXME: The permissions must be fixed even though PKG_DEVELOPER=no.
28+
exit_status 0
29+
output_prohibit "^error: .*: world-writable file"
30+
}
31+
32+
test_developer_no_autofix() {
33+
do_make PKG_DEVELOPER=yes CHECK_PERMS_AUTOFIX=no
34+
35+
exit_status 1
36+
output_require "^warning: .*/demo-file: too small to be a valid executable file"
37+
output_require "^warning: .*/demo-file: group-writable file"
38+
output_require "^error: .*/demo-file: world-writable file"
39+
}
40+
41+
test_developer_autofix() {
42+
do_make PKG_DEVELOPER=yes CHECK_PERMS_AUTOFIX=yes
43+
44+
# FIXME: Since all permission problems have been fixed, the exit status must be 0.
45+
# This needs to be fixed in checkperms upstream.
46+
exit_status 1
47+
output_require "^warning: .*/demo-file: too small to be a valid executable file"
48+
output_require "^warning: .*/demo-file: group-writable file"
49+
output_require "^error: .*/demo-file: world-writable file"
50+
output_require "^note: .*/demo-file: fixed permissions from 0777 to 0644"
51+
}
52+
53+
do_test() {
54+
test_no_developer_no_autofix
55+
test_no_developer_autofix
56+
test_developer_no_autofix
57+
test_developer_autofix
58+
}

0 commit comments

Comments
 (0)