Fixed startssl protocol errors. count_lines function always returns at least 1

For now I fixed this with a wc -l command, I hope @drwetter can fix the count_lines
function for me
This commit is contained in:
Frank Breedijk 2016-07-25 11:45:24 +02:00
parent 69d244748f
commit 06b1a12b3b
2 changed files with 9 additions and 7 deletions

View File

@ -17,9 +17,9 @@ my $socketout = `./testssl.sh -c -t smtp --jsonfile tmp.json --color 0 smtp-rela
my $socket = json('tmp.json');
like($socketout, qr/Running client simulations via sockets/, "Tests ran via sockets"); $tests++;
my $i = 0;
foreach my $o ( @$openssl ) {
my $s = $$socket[$i];
my $i = 1; # Need to start counting at 1
foreach my $s ( @$socket ) {
my $o = $$openssl[$i];
if ( $o->{id} =~ /^client_/ ) {
pass("Comparing $o->{id}"); $tests++;
cmp_ok($o->{id}, "eq", $s->{id}, "Id's match"); $tests++;

View File

@ -2042,12 +2042,12 @@ run_client_simulation() {
outln
if "$using_sockets"; then
pr_headlineln " Running client simulations via sockets "
pr_headlineln " Running client simulations via sockets (experimental) "
else
pr_headlineln " Running client simulations (experimental) "
pr_headlineln " Running client simulations via openssl (experimental) "
outln
pr_warningln " Depending on your openssl client and the server side this may yield to false values"
fileout "client_simulation" "WARNING" "Depending on your openssl client and the server side this may yield to false values"
fileout "client_simulation_openssl" "WARNING" "Running simulations via openssl, depending on your openssl client and the server side this may yield to false values"
fi
outln
@ -2055,7 +2055,9 @@ run_client_simulation() {
for name in "${short[@]}"; do
# Make sure we run client simulations for those clients that support it
if $do_all_simulations || ${current[i]} ; then
if $do_all_simulations || [[ $(count_lines "$(echo "${service[i]}" | grep "$client_service")") -eq 1 || "${service[i]}" == "ANY" ]]; then
# if $do_all_simulations || [[ $(count_lines "$(echo "${service[i]}" | grep "$client_service")") -eq 1 || "${service[i]}" == "ANY" ]]; then
# I know @drwetter hates wc -l, but in this case wc -l and count_lines give different results
if $do_all_simulations || [[ $(echo "${service[i]}" | grep "$client_service" |wc -l ) -eq 1 || "${service[i]}" == "ANY" ]]; then
#FIXME: printf formatting would look better, especially if we want a wide option here
out " ${names[i]} "
if $using_sockets && [[ -n "${handshakebytes[i]}" ]]; then