2020-01-13 17:36:40 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
2021-09-03 23:37:37 +02:00
|
|
|
# Basics: is there a syntax error where already bash hiccups on?
|
2020-01-13 17:36:40 +01:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Test::More;
|
2021-11-15 13:25:08 +01:00
|
|
|
use File::stat;
|
2020-01-13 17:36:40 +01:00
|
|
|
|
|
|
|
my $tests = 0;
|
|
|
|
my $fileout="";
|
2020-01-22 18:30:33 +01:00
|
|
|
my $prg="./testssl.sh";
|
|
|
|
my $out="";
|
|
|
|
|
|
|
|
# Try to detect remainders from debugging:
|
|
|
|
my $debug_regexp='^(\s)*set (-|\+)x';
|
2020-01-13 17:36:40 +01:00
|
|
|
# Blacklists we use to trigger an error:
|
|
|
|
my $error_regexp1='(syntax|parse) (e|E)rror';
|
|
|
|
my $error_regexp2='testssl.sh: line';
|
|
|
|
my $error_regexp3='bash: warning';
|
|
|
|
my $error_regexp4='command not found';
|
|
|
|
my $error_regexp5='(syntax error|unexpected token)';
|
|
|
|
|
|
|
|
printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no error ...";
|
2021-11-15 13:25:08 +01:00
|
|
|
my $info = stat($prg);
|
|
|
|
my $retMode = $info->mode;
|
|
|
|
|
|
|
|
is($retMode & 0400, 0400, "Checking \"./testssl.sh\" for read permission");
|
|
|
|
$tests++;
|
|
|
|
|
|
|
|
is($retMode & 0100, 0100, "Checking \"./testssl.sh\" for execute permission");
|
|
|
|
$tests++;
|
|
|
|
|
2020-01-22 18:30:33 +01:00
|
|
|
$fileout = `timeout 10 bash $prg 2>&1`;
|
2020-01-13 17:36:40 +01:00
|
|
|
my $retval=$?;
|
|
|
|
|
2020-01-14 18:44:11 +01:00
|
|
|
unlike($fileout, qr/$error_regexp1/, "regex 1");
|
2020-01-13 17:36:40 +01:00
|
|
|
$tests++;
|
|
|
|
|
2020-01-14 18:44:11 +01:00
|
|
|
unlike($fileout, qr/$error_regexp2/, "regex 2");
|
2020-01-13 17:36:40 +01:00
|
|
|
$tests++;
|
|
|
|
|
2020-01-14 18:44:11 +01:00
|
|
|
unlike($fileout, qr/$error_regexp3/, "regex 3");
|
2020-01-13 17:36:40 +01:00
|
|
|
$tests++;
|
|
|
|
|
2020-01-14 18:44:11 +01:00
|
|
|
unlike($fileout, qr/$error_regexp4/, "regex 4");
|
2020-01-13 17:36:40 +01:00
|
|
|
$tests++;
|
|
|
|
|
2020-01-14 18:44:11 +01:00
|
|
|
unlike($fileout, qr/$error_regexp5/, "regex 5");
|
2020-01-13 17:36:40 +01:00
|
|
|
$tests++;
|
|
|
|
|
|
|
|
is($retval, 0, "return value should be equal zero: \"$retval\"");
|
|
|
|
$tests++;
|
|
|
|
|
2020-01-22 18:30:33 +01:00
|
|
|
$out=`grep -E "$debug_regexp" $prg`;
|
|
|
|
unlike($out, qr/$debug_regexp/, "Debug RegEx");
|
|
|
|
$tests++;
|
|
|
|
|
2020-01-14 18:44:11 +01:00
|
|
|
printf "\n";
|
2020-01-13 17:36:40 +01:00
|
|
|
done_testing($tests);
|
|
|
|
|
|
|
|
|
2021-05-31 22:39:22 +02:00
|
|
|
# vim:ts=5:sw=5:expandtab
|
|
|
|
|