1#! /usr/bin/perl 2# $OpenBSD: check-sig,v 1.4 2019/05/09 20:26:33 espie Exp $ 3# Written by Marc Espie 4# Public domain 5 6use Test::Simple tests => 11; 7use OpenBSD::PackingList; 8use OpenBSD::State; 9sub mycode 10{ 11 my ($fh, $cont) = @_; 12 while (<$fh>) { 13 return if m/^__END__/; 14 &$cont($_); 15 } 16} 17 18my @sig; 19my $fh = \*DATA; 20for my $i (1..7) { 21 push(@sig, OpenBSD::PackingList->read($fh, \&mycode)->signature); 22} 23 24my $s = OpenBSD::State->new; 25 26ok($sig[0]->compare($sig[0], $s) == 0, "self compare"); 27ok($sig[3]->compare($sig[3], $s) == 0, "self compare"); 28ok($sig[5]->compare($sig[5], $s) == 0, "self compare"); 29ok(!defined($sig[0]->compare($sig[3], $s)), "non comparable"); 30ok($sig[0]->compare($sig[1], $s) < 0, "depend"); 31ok($sig[0]->compare($sig[2], $s) < 0, "pkgname"); 32ok($sig[1]->compare($sig[0], $s) > 0, "other way"); 33ok($sig[3]->compare($sig[4], $s) < 0, "lib"); 34ok($sig[3]->compare($sig[5], $s) < 0, "depend"); 35ok(!defined($sig[0]->compare($sig[6], $s)), "non comparable"); 36ok(!defined($sig[6]->compare($sig[0], $s)), "non comparable"); 37 38__DATA__ 39@name foo-1.0 40@depend test/x:x-*:x-1.0 41file 42__END__ #1 43@name foo-1.0 44@depend test/x:x-*:x-2.0 45file 46__END__ #2 47@name foo-2.0 48@depend test/x:x-*:x-2.0 49file 50__END__ #3 51@name bar-1.0 52@depend test/x:x-*:x-1.0 53@wantlib a.1.5 54__END__ #4 55@name bar-1.0 56@depend test/x:x-*:x-1.0 57@wantlib a.2.0 58__END__ #5 59@name bar-1.0 60@depend test/x:x-*:x-2.0 61@wantlib a.1.5 62__END__ #6 63@name foo-1.0 64@depend test/x:x-*:x-1.0 65@depend test/y:y-*:y-2.0 66