2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-09-30 21:06:14 +08:00
|
|
|
#
|
2016-04-22 19:21:51 +08:00
|
|
|
# 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
|
2015-09-30 21:06:14 +08:00
|
|
|
|
|
|
|
use strict;
|
2016-01-30 08:05:33 +08:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
2015-09-30 21:06:14 +08:00
|
|
|
|
|
|
|
setup("test_ordinals");
|
|
|
|
|
|
|
|
plan tests => 2;
|
|
|
|
|
2016-03-03 19:42:01 +08:00
|
|
|
ok(testordinals(srctop_file("util", "libcrypto.num")), "Test libcrypto.num");
|
|
|
|
ok(testordinals(srctop_file("util", "libssl.num")), "Test libssl.num");
|
2015-09-30 21:06:14 +08:00
|
|
|
|
|
|
|
sub testordinals
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
my $cnt = 0;
|
|
|
|
my $ret = 1;
|
|
|
|
my $qualifier = "";
|
|
|
|
my $newqual;
|
|
|
|
my $lastfunc = "";
|
|
|
|
|
|
|
|
open(my $fh, '<', $filename);
|
|
|
|
while (my $line = <$fh>) {
|
2015-12-15 23:54:22 +08:00
|
|
|
my @tokens = split(/(?:\s+|\s*:\s*)/, $line);
|
2015-09-30 21:06:14 +08:00
|
|
|
#Check the line looks sane
|
2015-12-14 17:22:58 +08:00
|
|
|
if ($#tokens < 5 || $#tokens > 6) {
|
2015-09-30 21:06:14 +08:00
|
|
|
print STDERR "Invalid line:\n$line\n";
|
|
|
|
$ret = 0;
|
|
|
|
last;
|
|
|
|
}
|
2015-12-14 17:22:58 +08:00
|
|
|
if ($tokens[3] eq "NOEXIST") {
|
2015-09-30 21:06:14 +08:00
|
|
|
#Ignore this line
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
#Some ordinals can be repeated, e.g. if one is VMS and another is !VMS
|
2015-12-14 17:22:58 +08:00
|
|
|
$newqual = $tokens[4];
|
2015-09-30 21:06:14 +08:00
|
|
|
$newqual =~ s/!//g;
|
2015-12-15 23:54:22 +08:00
|
|
|
if ($cnt > $tokens[1]
|
|
|
|
|| ($cnt == $tokens[1] && ($qualifier ne $newqual
|
2016-01-14 04:51:41 +08:00
|
|
|
|| $qualifier eq ""))) {
|
2015-12-15 23:54:22 +08:00
|
|
|
print STDERR "Invalid ordinal detected: ".$tokens[1]."\n";
|
2015-09-30 21:06:14 +08:00
|
|
|
$ret = 0;
|
|
|
|
last;
|
|
|
|
}
|
2015-12-15 23:54:22 +08:00
|
|
|
$cnt = $tokens[1];
|
2015-09-30 21:06:14 +08:00
|
|
|
$qualifier = $newqual;
|
|
|
|
$lastfunc = $tokens[0];
|
|
|
|
}
|
|
|
|
close($fh);
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|