X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=test%2Frecipes%2Ftconversion.pl;h=e5fa9dec879e1097c86eea8d13740c2c4a9860f7;hb=48c1e15ceb2252e65ba63f93a7bf39c1d368f38f;hp=94039e932b255e93c3aa585ce0329f51761c95dc;hpb=904ae3342600fe1dae3e0835a784c73b7c237106;p=oweals%2Fopenssl.git diff --git a/test/recipes/tconversion.pl b/test/recipes/tconversion.pl index 94039e932b..e5fa9dec87 100644 --- a/test/recipes/tconversion.pl +++ b/test/recipes/tconversion.pl @@ -1,17 +1,24 @@ -#! /usr/bin/perl +#! /usr/bin/env perl +# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy +# in the file LICENSE in the source distribution or at +# https://www.openssl.org/source/license.html + use strict; use warnings; use File::Compare qw/compare_text/; use File::Copy; -use Test::More; use lib 'testlib'; -use OpenSSL::Test qw/:DEFAULT top_file/; +use OpenSSL::Test qw/:DEFAULT/; my %conversionforms = ( + # Default conversion forms. Other series may be added with + # specific test types as key. "*" => [ "d", "p" ], - x509 => [ "d", "n", "p" ], ); sub tconversion { my $testtype = shift; @@ -53,8 +60,9 @@ sub tconversion { ok(run(app([@cmd, "-in", "$testtype-fff.p", "-inform", "p", - "-outform", $to], - stdout => "$testtype-f.$to")), "p -> $to"); + "-out", "$testtype-f.$to", + "-outform", $to])), + "p -> $to"); } foreach my $to (@conversionforms) { @@ -62,20 +70,21 @@ sub tconversion { ok(run(app([@cmd, "-in", "$testtype-f.$from", "-inform", $from, - "-outform", $to], - stdout => "$testtype-ff.$from$to")), "$from -> $to"); + "-out", "$testtype-ff.$from$to", + "-outform", $to])), + "$from -> $to"); } } if ($testtype ne "p7d") { - is(compare_text("$testtype-fff.p", "$testtype-f.p"), 0, + is(cmp_text("$testtype-fff.p", "$testtype-f.p"), 0, 'comparing orig to p'); } foreach my $to (@conversionforms) { next if $to eq "d"; foreach my $from (@conversionforms) { - is(compare_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0, + is(cmp_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0, "comparing $to to $from$to"); } } @@ -85,4 +94,12 @@ sub tconversion { unlink glob "$testtype-fff.*"; } +sub cmp_text { + return compare_text(@_, sub { + $_[0] =~ s/\R//g; + $_[1] =~ s/\R//g; + return $_[0] ne $_[1]; + }); +} + 1;