1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use lib 't/lib';
6
7use Test::Deep;
8use Test::Exception;
9use Test::More;
10use Test::NoWarnings;
11
12use FusionInventory::Agent::Inventory;
13use FusionInventory::Agent::Task::Inventory::BSD::Softwares;
14
15my %pkg_info_tests = (
16    'sample1' => [
17        {
18            NAME     => 'GeoIP',
19            COMMENTS => 'Find the country that any IP address or hostname originates',
20            VERSION  => '1.4.8_1'
21        },
22        {
23            NAME     => 'ImageMagick',
24            COMMENTS => 'Image processing tools',
25            VERSION  => '6.7.0.10_1'
26        },
27        {
28            NAME     => 'ORBit2',
29            COMMENTS => 'High-performance CORBA ORB with support for the C language',
30            VERSION  => '2.14.19'
31        },
32        {
33            NAME     => 'Ocsinventory-Agent',
34            COMMENTS => 'Keep track of the computers configuration and software',
35            VERSION  => '1.1.2.1_1,1'
36        },
37        {
38            NAME     => 'Ocsinventory-Agent',
39            COMMENTS => 'Keep track of the computers configuration and software',
40            VERSION  => '2.0,1'
41        },
42        {
43            NAME     => 'OpenEXR',
44            COMMENTS => 'A high dynamic-range (HDR) image file format',
45            VERSION  => '1.6.1_3'
46        },
47        {
48            NAME     => 'a2ps-a4',
49            COMMENTS => 'Formats an ascii file for printing on a postscript printer',
50            VERSION  => '4.13b_4'
51        },
52        {
53            NAME     => 'aalib',
54            COMMENTS => 'An ascii art library',
55            VERSION  => '1.4.r5_6'
56        },
57        {
58            NAME     => 'acidrip',
59            COMMENTS => 'GTK2::Perl wrapper for MPlayer and MEncoder for ripping DVD',
60            VERSION  => '0.14_8'
61        },
62        {
63            NAME     => 'acroread8',
64            COMMENTS => 'Adobe Reader for view, print, and search PDF documents (ENU',
65            VERSION  => '8.1.7_3'
66        },
67        {
68            NAME     => 'acroreadwrapper',
69            COMMENTS => 'Wrapper script for Adobe Reader',
70            VERSION  => '0.0.20110920'
71        },
72        {
73            NAME     => 'alsa-lib',
74            COMMENTS => 'ALSA compatibility library',
75            VERSION  => '1.0.23'
76        },
77        {
78            NAME     => 'ap22-mod_perl2',
79            COMMENTS => 'Embeds a Perl interpreter in the Apache2 server',
80            VERSION  => '2.0.5_1,3'
81        },
82        {
83            NAME     => 'apache',
84            COMMENTS => 'Version 2.2.x of Apache web server with prefork MPM.',
85            VERSION  => '2.2.19'
86        },
87        {
88            NAME     => 'apache-ant',
89            COMMENTS => 'Java- and XML-based build tool, conceptually similar to mak',
90            VERSION  => '1.8.2'
91        },
92        {
93            NAME     => 'appres',
94            COMMENTS => 'Program to list application\'s resources',
95            VERSION  => '1.0.3'
96        },
97        {
98            NAME     => 'apr-ipv6-devrandom-gdbm-db42',
99            COMMENTS => 'Apache Portability Library',
100            VERSION  => '1.4.5.1.3.12'
101        },
102        {
103            NAME     => 'aspell',
104            COMMENTS => 'Spelling checker with better suggestion logic than ispell',
105            VERSION  => '0.60.6.1'
106        },
107        {
108            NAME     => 'atk',
109            COMMENTS => 'A GNOME accessibility toolkit (ATK)',
110            VERSION  => '2.0.1'
111        },
112        {
113            NAME     => 'atkmm',
114            COMMENTS => 'C++ wrapper for ATK API library',
115            VERSION  => '2.22.5'
116        },
117        {
118            NAME     => 'attica',
119            COMMENTS => 'Collaboration Services API library',
120            VERSION  => '0.2.80,1'
121        },
122        {
123            NAME     => 'atunes',
124            COMMENTS => 'A full-featured audio player and manager developed in Java',
125            VERSION  => '2.0.1'
126        },
127        {
128            NAME     => 'audacity',
129            COMMENTS => 'Audacity is a GUI editor for digital audio waveforms',
130            VERSION  => '1.2.4b_9'
131        },
132        {
133            NAME     => 'autoconf',
134            COMMENTS => 'Automatically configure source code on many Un*x platforms ',
135            VERSION  => '2.13.000227_6'
136        },
137        {
138            NAME     => 'autoconf',
139            COMMENTS => 'Automatically configure source code on many Un*x platforms ',
140            VERSION  => '2.68'
141        },
142        {
143            NAME     => 'autoconf-wrapper',
144            COMMENTS => 'Wrapper script for GNU autoconf',
145            VERSION  => '20101119'
146        },
147        {
148            NAME     => 'automake',
149            COMMENTS => 'GNU Standards-compliant Makefile generator (1.11)',
150            VERSION  => '1.11.1'
151        },
152        {
153            NAME     => 'automake',
154            COMMENTS => 'GNU Standards-compliant Makefile generator (1.4)',
155            VERSION  => '1.4.6_6'
156        },
157        {
158            NAME     => 'automake-wrapper',
159            COMMENTS => 'Wrapper script for GNU automake',
160            VERSION  => '20101119'
161        },
162        {
163            NAME     => 'automoc4',
164            COMMENTS => 'Automatic moc for Qt 4 packages',
165            VERSION  => '0.9.88_1'
166        },
167        {
168            NAME     => 'avahi-app',
169            COMMENTS => 'Service discovery on a local network',
170            VERSION  => '0.6.29'
171        },
172        {
173            NAME     => 'b43-fwcutter',
174            COMMENTS => 'Extracts firmware for Broadcom Wireless adapters',
175            VERSION  => '012'
176        },
177        {
178            NAME     => 'babl',
179            COMMENTS => 'Dynamic pixel format conversion library',
180            VERSION  => '0.1.4'
181        },
182        {
183            NAME     => 'bash',
184            COMMENTS => 'The GNU Project\'s Bourne Again SHell',
185            VERSION  => '4.1.11'
186        }
187    ],
188    'sample2' => [
189        {
190            NAME     => 'GentiumBasic',
191            COMMENTS => 'Gentium Basic and Gentium Book Basic TrueType fonts',
192            VERSION  => '110_1'
193        },
194        {
195            NAME     => 'GeoIP',
196            COMMENTS => 'Find the country that any IP address or hostname originates from',
197            VERSION  => '1.4.8_4'
198        },
199        {
200            NAME     => 'ImageMagick',
201            COMMENTS => 'Image processing tools',
202            VERSION  => '6.8.9.4_1,1'
203        },
204        {
205            NAME     => 'ORBit2',
206            COMMENTS => 'High-performance CORBA ORB with support for the C language',
207            VERSION  => '2.14.19_1'
208        },
209        {
210            NAME     => 'OpenEXR',
211            COMMENTS => 'High dynamic-range (HDR) image file format',
212            VERSION  => '2.1.0_3'
213        },
214        {
215            NAME     => 'a2ps',
216            COMMENTS => 'Formats an ASCII file for printing on a postscript printer',
217            VERSION  => '4.13b_5'
218        },
219        {
220            NAME     => 'aalib',
221            COMMENTS => 'ASCII art library',
222            VERSION  => '1.4.r5_10'
223        },
224        {
225            NAME     => 'adns',
226            COMMENTS => 'Easy to use asynchronous-capable DNS client library and utilities',
227            VERSION  => '1.4_1'
228        },
229        {
230            NAME     => 'alsa-lib',
231            COMMENTS => 'ALSA compatibility library',
232            VERSION  => '1.0.27.2_2'
233        },
234        {
235            NAME     => 'alsa-plugins',
236            COMMENTS => 'ALSA compatibility library plugins',
237            VERSION  => '1.0.27_2'
238        },
239        {
240            NAME     => 'apache-ant',
241            COMMENTS => 'Java- and XML-based build tool, conceptually similar to make',
242            VERSION  => '1.9.3'
243        },
244        {
245            NAME     => 'apache22',
246            COMMENTS => 'Version 2.2.x of Apache web server with prefork MPM.',
247            VERSION  => '2.2.27_2'
248        },
249        {
250            NAME     => 'appres',
251            COMMENTS => 'Program to list application\'s resources',
252            VERSION  => '1.0.4'
253        },
254        {
255            NAME     => 'apr',
256            COMMENTS => 'Apache Portability Library',
257            VERSION  => '1.5.1.1.5.3_2'
258        },
259        {
260            NAME     => 'arandr',
261            COMMENTS => 'Another XRandR GUI',
262            VERSION  => '0.1.7.1_2'
263        },
264        {
265            NAME     => 'asciidoc',
266            COMMENTS => 'Text document format for writing short documents and man pages',
267            VERSION  => '8.6.9_3'
268        },
269        {
270            NAME     => 'aspell',
271            COMMENTS => 'Spelling checker with better suggestion logic than ispell',
272            VERSION  => '0.60.6.1_4'
273        },
274        {
275            NAME     => 'at-spi2-atk',
276            COMMENTS => 'Assisted Technology Provider module for GTK+',
277            VERSION  => '2.8.0'
278        },
279        {
280            NAME     => 'at-spi2-core',
281            COMMENTS => 'Assistive Technology Service Provider Interface',
282            VERSION  => '2.8.0'
283        },
284        {
285            NAME     => 'atk',
286            COMMENTS => 'GNOME accessibility toolkit (ATK)',
287            VERSION  => '2.8.0'
288        },
289        {
290            NAME     => 'atkmm',
291            COMMENTS => 'C++ wrapper for ATK API library',
292            VERSION  => '2.22.6'
293        },
294        {
295            NAME     => 'atop',
296            COMMENTS => 'ASCII Monitor for system resources and process activity',
297            VERSION  => '2.0.2.b3'
298        },
299        {
300            NAME     => 'autoconf',
301            COMMENTS => 'Automatically configure source code on many Un*x platforms',
302            VERSION  => '2.69'
303        },
304        {
305            NAME     => 'autoconf-wrapper',
306            COMMENTS => 'Wrapper script for GNU autoconf',
307            VERSION  => '20131203'
308        },
309        {
310            NAME     => 'autoconf213',
311            COMMENTS => 'Automatically configure source code on many Un*x platforms (legacy 2.13)',
312            VERSION  => '2.13.000227_6'
313        },
314        {
315            NAME     => 'automake',
316            COMMENTS => 'GNU Standards-compliant Makefile generator',
317            VERSION  => '1.14'
318        },
319        {
320            NAME     => 'automake-wrapper',
321            COMMENTS => 'Wrapper script for GNU automake',
322            VERSION  => '20131203'
323        },
324        {
325            NAME     => 'automake14',
326            COMMENTS => 'GNU Standards-compliant Makefile generator (legacy 1.4)',
327            VERSION  => '1.4.6_6'
328        },
329        {
330            NAME     => 'automoc4',
331            COMMENTS => 'Automatic moc for Qt 4 packages',
332            VERSION  => '0.9.88_3'
333        },
334        {
335            NAME     => 'avahi-app',
336            COMMENTS => 'Service discovery on a local network',
337            VERSION  => '0.6.31_2'
338        },
339        {
340            NAME     => 'avahi-sharp',
341            COMMENTS => 'Mono bindings for Avahi service discovery',
342            VERSION  => '0.6.31'
343        },
344        {
345            NAME     => 'babl',
346            COMMENTS => 'Dynamic pixel format conversion library',
347            VERSION  => '0.1.10_1'
348        },
349        {
350            NAME     => 'bash',
351            COMMENTS => 'The GNU Project\'s Bourne Again SHell',
352            VERSION  => '4.3.18_2'
353        }
354    ]
355);
356
357plan tests => (2 * scalar keys %pkg_info_tests) + 1;
358
359my $inventory = FusionInventory::Agent::Inventory->new();
360
361foreach my $test (keys %pkg_info_tests) {
362    my $file = "resources/bsd/pkg_info/$test";
363    my $softwares = FusionInventory::Agent::Task::Inventory::BSD::Softwares::_getPackagesList(file => $file);
364    cmp_deeply($softwares, $pkg_info_tests{$test}, "$test: parsing");
365    lives_ok {
366        $inventory->addEntry(section => 'SOFTWARES', entry => $_)
367            foreach @$softwares;
368    } "$test: registering";
369}
370