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