2
0

02-test_ordinals.t 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. use strict;
  9. use OpenSSL::Test qw/:DEFAULT srctop_file/;
  10. setup("test_ordinals");
  11. plan tests => 2;
  12. ok(testordinals(srctop_file("util", "libcrypto.num")), "Test libcrypto.num");
  13. ok(testordinals(srctop_file("util", "libssl.num")), "Test libssl.num");
  14. sub testordinals
  15. {
  16. my $filename = shift;
  17. my $cnt = 0;
  18. my $ret = 1;
  19. my $qualifier = "";
  20. my $newqual;
  21. my $lastfunc = "";
  22. open(my $fh, '<', $filename);
  23. while (my $line = <$fh>) {
  24. my @tokens = split(/(?:\s+|\s*:\s*)/, $line);
  25. #Check the line looks sane
  26. if ($#tokens < 5 || $#tokens > 6) {
  27. print STDERR "Invalid line:\n$line\n";
  28. $ret = 0;
  29. last;
  30. }
  31. if ($tokens[3] eq "NOEXIST") {
  32. #Ignore this line
  33. next;
  34. }
  35. #Some ordinals can be repeated, e.g. if one is VMS and another is !VMS
  36. $newqual = $tokens[4];
  37. $newqual =~ s/!//g;
  38. if ($cnt > $tokens[1]
  39. || ($cnt == $tokens[1] && ($qualifier ne $newqual
  40. || $qualifier eq ""))) {
  41. print STDERR "Invalid ordinal detected: ".$tokens[1]."\n";
  42. $ret = 0;
  43. last;
  44. }
  45. $cnt = $tokens[1];
  46. $qualifier = $newqual;
  47. $lastfunc = $tokens[0];
  48. }
  49. close($fh);
  50. return $ret;
  51. }