]>
Commit | Line | Data |
---|---|---|
596d6b7e RS |
1 | #! /usr/bin/env perl |
2 | # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. | |
5530d518 | 3 | # |
909f1a2e | 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
596d6b7e RS |
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 | |
5530d518 MC |
8 | |
9 | use strict; | |
42e0ccdf | 10 | use OpenSSL::Test qw/:DEFAULT srctop_file/; |
5530d518 MC |
11 | |
12 | setup("test_ordinals"); | |
13 | ||
14 | plan tests => 2; | |
15 | ||
6928b617 RL |
16 | ok(testordinals(srctop_file("util", "libcrypto.num")), "Test libcrypto.num"); |
17 | ok(testordinals(srctop_file("util", "libssl.num")), "Test libssl.num"); | |
5530d518 MC |
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>) { | |
ea09088e | 30 | my @tokens = split(/(?:\s+|\s*:\s*)/, $line); |
5530d518 | 31 | #Check the line looks sane |
e863d920 | 32 | if ($#tokens < 5 || $#tokens > 6) { |
5530d518 MC |
33 | print STDERR "Invalid line:\n$line\n"; |
34 | $ret = 0; | |
35 | last; | |
36 | } | |
e863d920 | 37 | if ($tokens[3] eq "NOEXIST") { |
5530d518 MC |
38 | #Ignore this line |
39 | next; | |
40 | } | |
41 | #Some ordinals can be repeated, e.g. if one is VMS and another is !VMS | |
e863d920 | 42 | $newqual = $tokens[4]; |
5530d518 | 43 | $newqual =~ s/!//g; |
6af1b118 RL |
44 | my $number = $tokens[1]; |
45 | $number = $cnt + 1 if $number eq '?'; | |
46 | $number = $cnt if $number eq '?+'; | |
47 | if ($cnt > $number | |
48 | || ($cnt == $number && ($qualifier ne $newqual | |
6b95a378 | 49 | || $qualifier eq ""))) { |
ea09088e | 50 | print STDERR "Invalid ordinal detected: ".$tokens[1]."\n"; |
5530d518 MC |
51 | $ret = 0; |
52 | last; | |
53 | } | |
ea09088e | 54 | $cnt = $tokens[1]; |
5530d518 MC |
55 | $qualifier = $newqual; |
56 | $lastfunc = $tokens[0]; | |
57 | } | |
58 | close($fh); | |
59 | ||
60 | return $ret; | |
61 | } |