"Fossies" - the Fresh Open Source Software Archive

Member "openssl-1.1.1b/test/recipes/02-test_ordinals.t" (26 Feb 2019, 1688 Bytes) of package /linux/misc/openssl-1.1.1b.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /usr/bin/env perl
    2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
    3 #
    4 # Licensed under the OpenSSL license (the "License").  You may not use
    5 # this file except in compliance with the License.  You can obtain a copy
    6 # in the file LICENSE in the source distribution or at
    7 # https://www.openssl.org/source/license.html
    8 
    9 use strict;
   10 use OpenSSL::Test qw/:DEFAULT srctop_file/;
   11 
   12 setup("test_ordinals");
   13 
   14 plan tests => 2;
   15 
   16 ok(testordinals(srctop_file("util", "libcrypto.num")), "Test libcrypto.num");
   17 ok(testordinals(srctop_file("util", "libssl.num")), "Test libssl.num");
   18 
   19 sub testordinals
   20 {
   21     my $filename = shift;
   22     my $cnt = 0;
   23     my $ret = 1;
   24     my $qualifier = "";
   25     my $newqual;
   26     my $lastfunc = "";
   27 
   28     open(my $fh, '<', $filename);
   29     while (my $line = <$fh>) {
   30         my @tokens = split(/(?:\s+|\s*:\s*)/, $line);
   31         #Check the line looks sane
   32         if ($#tokens < 5 || $#tokens > 6) {
   33             print STDERR "Invalid line:\n$line\n";
   34             $ret = 0;
   35             last;
   36         }
   37         if ($tokens[3] eq "NOEXIST") {
   38             #Ignore this line
   39             next;
   40         }
   41         #Some ordinals can be repeated, e.g. if one is VMS and another is !VMS
   42         $newqual = $tokens[4];
   43         $newqual =~ s/!//g;
   44         if ($cnt > $tokens[1]
   45                 || ($cnt == $tokens[1] && ($qualifier ne $newqual
   46                                            || $qualifier eq ""))) {
   47             print STDERR "Invalid ordinal detected: ".$tokens[1]."\n";
   48             $ret = 0;
   49             last;
   50         }
   51         $cnt = $tokens[1];
   52         $qualifier = $newqual;
   53         $lastfunc = $tokens[0];
   54     }
   55     close($fh);
   56 
   57     return $ret;
   58 }