summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/pkg_add/check-sig
blob: 56059214f90086b00fe73c29d4192b1f75447184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/perl
# $OpenBSD: check-sig,v 1.2 2010/01/10 12:41:20 espie Exp $
# Written by Marc Espie
# Public domain

use Test::Simple tests => 11;
use OpenBSD::PackingList;
sub mycode
{
	my ($fh, $cont) = @_;
	my $_;
	while (<$fh>) {
		return if m/^__END__/;
		&$cont($_);
	}
}

my @sig;
my $fh = \*DATA;
for my $i (1..7) {
	push(@sig, OpenBSD::PackingList->read($fh, \&mycode)->signature);
}

ok($sig[0]->compare($sig[0]) == 0, "self compare");
ok($sig[3]->compare($sig[3]) == 0, "self compare");
ok($sig[5]->compare($sig[5]) == 0, "self compare");
ok(!defined($sig[0]->compare($sig[3])), "non comparable");
ok($sig[0]->compare($sig[1]) < 0, "depend");
ok($sig[0]->compare($sig[2]) < 0, "pkgname");
ok($sig[1]->compare($sig[0]) > 0, "other way");
ok($sig[3]->compare($sig[4]) < 0, "lib");
ok($sig[3]->compare($sig[5]) < 0, "depend");
ok(!defined($sig[0]->compare($sig[6])), "non comparable");
ok(!defined($sig[6]->compare($sig[0])), "non comparable");

__DATA__
@name foo-1.0
@depend test/x:x-*:x-1.0
file
__END__ #1
@name foo-1.0
@depend test/x:x-*:x-2.0
file
__END__ #2
@name foo-2.0
@depend test/x:x-*:x-2.0
file
__END__ #3
@name bar-1.0
@depend test/x:x-*:x-1.0
@wantlib a.1.5
__END__ #4
@name bar-1.0
@depend test/x:x-*:x-1.0
@wantlib a.2.0
__END__ #5
@name bar-1.0
@depend test/x:x-*:x-2.0
@wantlib a.1.5
__END__ #6
@name foo-1.0
@depend test/x:x-*:x-1.0
@depend test/y:y-*:y-2.0