summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-11-25 12:01:20 +0000
committerNiels Thykier <niels@thykier.net>2017-11-25 12:01:20 +0000
commit6c634c8067ac6426da5c76b0be4b2b7dce2f3ecb (patch)
treec22420a1015981d1d24dbd001fba1e7ea4da75b0 /t
parent42ff99daf0182bb959f372500ab0d97b48e80a70 (diff)
downloaddebhelper-6c634c8067ac6426da5c76b0be4b2b7dce2f3ecb.tar.gz
dh_installdeb: Basic validation of {rm,mv}_conffile
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 't')
-rwxr-xr-xt/maintscript.t36
1 files changed, 35 insertions, 1 deletions
diff --git a/t/maintscript.t b/t/maintscript.t
index a69c99c7..4460f2c6 100755
--- a/t/maintscript.t
+++ b/t/maintscript.t
@@ -10,7 +10,7 @@ use Test::DH;
use Debian::Debhelper::Dh_Lib qw(!dirname);
if (uid_0_test_is_ok()) {
- plan(tests => 1);
+ plan(tests => 2);
} else {
plan skip_all => 'fakeroot required';
}
@@ -38,3 +38,37 @@ EOF
}
});
+sub test_maintscript_syntax {
+ my ($contents) = @_;
+ my @scripts = map { ("debian/debhelper.${_}.debhelper", "debian/$_") } qw{postinst preinst prerm postrm};
+ my $file = 'debian/maintscript';
+
+
+ open(my $fd, ">", $file) or die("open($file): $!");
+ print {$fd} <<EOF;
+${contents}
+EOF
+ close($fd) or die("close($file): $!\n");
+
+ my $res = run_dh_tool( { 'needs_root' => 1, 'quiet' => 1 }, 'dh_installdeb');
+
+ remove_tree('debian/debhelper', 'debian/tmp', 'debian/.debhelper');
+ rm_files(@scripts);
+
+ return $res;
+}
+
+# Negative tests
+each_compat_from_and_above_subtest(12, sub {
+ ok(!test_maintscript_syntax('rm_conffile foo 1.0~'), "rm_conffile absolute path check");
+ ok(!test_maintscript_syntax('rm_conffile /foo 1.0\~'), "rm_conffile version check");
+ ok(!test_maintscript_syntax('rm_conffile /foo 1.0~ some_pkg'), "rm_conffile package name check");
+ ok(!test_maintscript_syntax('rm_conffile /foo 1.0~ some-pkg --'), "rm_conffile separator check");
+
+ ok(!test_maintscript_syntax('mv_conffile foo /bar 1.0~'), "mv_conffile absolute (current) path check");
+ ok(!test_maintscript_syntax('mv_conffile /foo bar 1.0~'), "mv_conffile absolute (current) path check");
+ ok(!test_maintscript_syntax('mv_conffile /foo /bar 1.0\~'), "mv_conffile version check");
+ ok(!test_maintscript_syntax('mv_conffile /foo /bar 1.0~ some_pkg'), "mv_conffile package name check");
+ ok(!test_maintscript_syntax('mv_conffile /foo /bar 1.0~ some-pkg -- '), "mv_conffile separator check ");
+});
+