Skip to content

Commit d7da22d

Browse files
committed
Finalize check
* use system with @Args so that we can query the return value * code style improved for readability * diff shows the filtered difference * ok instead of cmp_ok to show not the whole content of vars
1 parent 4df0d9e commit d7da22d

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

t/61_diff_testsslsh.t

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
# Baseline diff test against testssl.sh (csv output)
44
#
55
# We don't use a full run yet and only the certificate section.
6-
# There we would need to blacklist at least:
6+
# There we would need to blacklist more, like:
77
# cert_serialNumber, cert_fingerprintSHA1, cert_fingerprintSHA256, cert
88
# cert_expirationStatus, cert_notBefore, cert_notAfter, cert_caIssuers, intermediate_cert
99
#
10-
# help is appreciated here
1110

1211
use strict;
1312
use Test::More;
@@ -16,55 +15,54 @@ use Text::Diff;
1615

1716
my $tests = 0;
1817
my $prg="./testssl.sh";
19-
my $master_socket_csv="./t/baseline_data/default_testssl.csvfile";
20-
my $socket_csv="tmp.csv";
21-
my $check2run="-p -s -P --fs -h -U -c -q --ip=one --color 0 --csvfile $socket_csv";
22-
#my $check2run="-p --color 0 --csvfile $socket_csv";
18+
my $baseline_csv="./t/baseline_data/default_testssl.csvfile";
19+
my $cat_csv="tmp.csv";
20+
my $check2run="-p -s -P --fs -h -U -c -q --ip=one --color 0 --csvfile $cat_csv";
2321
my $uri="testssl.sh";
2422
my $diff="";
2523

2624
die "Unable to open $prg" unless -f $prg;
27-
die "Unable to open $master_socket_csv" unless -f $master_socket_csv;
28-
25+
die "Unable to open $baseline_csv" unless -f $baseline_csv;
2926

3027
# Provide proper start conditions
31-
unlink "tmp.csv";
28+
unlink $cat_csv;
3229

33-
# Title
34-
printf "\n%s\n", "Diff unit test IPv4 against \"$uri\"";
30+
my @args=("$prg", "$check2run", "$uri", "2>&1");
3531

3632
#1 run
37-
`$prg $check2run $uri 2>&1`;
38-
39-
$diff = diff $socket_csv, $master_socket_csv;
33+
printf "\n%s\n", "Diff unit test (IPv4) against \"$uri\"";
34+
printf "@args\n";
35+
system("@args") == 0
36+
or die ("FAILED: \"@args\" ");
4037

41-
$socket_csv=`cat tmp.csv`;
42-
$master_socket_csv=`cat $master_socket_csv`;
38+
$cat_csv=`cat $cat_csv`;
39+
$baseline_csv=`cat $baseline_csv`;
4340

4441
# Filter for changes that are allowed to occur
45-
$socket_csv=~ s/HTTP_clock_skew.*\n//g;
46-
$master_socket_csv=~ s/HTTP_clock_skew.*\n//g;
42+
$cat_csv =~ s/HTTP_clock_skew.*\n//g;
43+
$baseline_csv =~ s/HTTP_clock_skew.*\n//g;
44+
45+
# HTTP time
46+
$cat_csv =~ s/HTTP_headerTime.*\n//g;
47+
$baseline_csv =~ s/HTTP_headerTime.*\n//g;
4748

4849
# DROWN
49-
$socket_csv=~ s/censys.io.*\n//g;
50-
$master_socket_csv=~ s/censys.io.*\n//g;
50+
$cat_csv =~ s/censys.io.*\n//g;
51+
$baseline_csv =~ s/censys.io.*\n//g;
5152

52-
# HTTP time
53-
$socket_csv=~ s/HTTP_headerTime.*\n//g;
54-
$master_socket_csv=~ s/HTTP_headerTime.*\n//g;
53+
$diff = diff \$cat_csv, \$baseline_csv;
5554

56-
# Compare the differences to the master file -- and print differences if there were detected.
55+
# Compare the differences to the baseline file -- and print differences if there were detected.
5756
#
58-
cmp_ok($socket_csv, "eq", $master_socket_csv, "Check whether CSV output matches master file from $uri") or
57+
ok($cat_csv eq $baseline_csv, "Check whether CSV output matches baseline file from $uri") or
5958
diag ("\n%s\n", "$diff");
6059

61-
$tests++;
62-
6360
unlink "tmp.csv";
6461

62+
$tests++;
6563
done_testing($tests);
6664
printf "\n";
6765

6866

69-
# vim:ts=5:sw=5:expandtab
67+
# vim:ts=5:sw=5:expandtab
7068

0 commit comments

Comments
 (0)