File: 20_test.t

package info (click to toggle)
libunix-processors-perl 2.046-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 109; makefile: 3
file content (63 lines) | stat: -rwxr-xr-x 1,450 bytes parent folder | download | duplicates (2)
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 -w
# DESCRIPTION: Perl ExtUtils: Type 'make test' to test this package
#
# Copyright 1999-2017 by Wilson Snyder.  This program is free software;
# you can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.

use strict;
use Test;

BEGIN { plan tests => 9 }
BEGIN { require "./t/test_utils.pl"; }

use Unix::Processors;
ok(1);

######################### End of black magic.

# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):

# 2: Constructor
my $procs = new Unix::Processors();
ok ($procs);

# 3: Max online
my $online = $procs->max_online;
print "Cpu threads online: $online\n";
ok($online);

# 4: Max physical
my $phys = $procs->max_physical;
print "Physical cpu cores: $phys\n";
ok($phys);

# 5: Max socket
my $socks = $procs->max_socket;
print "Physical cpu sockets: $socks\n";
ok($socks);

# 6: Max speed
my $clock = $procs->max_clock;
print "Cpu frequency: $clock\n";
ok($online);

# 7: Procs state
my $proclist = $procs->processors;
ok($proclist);

# 8: Procs owner
my $ok=1;
foreach my $proc (@{$procs->processors}) {
    $ok = 0 if (!$proc->state || !$proc->type);
    printf +("Id %s  State %s  Clock %s  Type %s\n",
	     $proc->id, $proc->state, $proc->clock, $proc->type);
}
ok($ok);

# 9: Destructor
undef $procs;
ok(1);