|
| 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