Help language development. Donate to The Perl Foundation

Linux::Cpuinfo zef:jonathanstowe last updated on 2022-08-07


use v6;

use Test;

use Linux::Cpuinfo;

if $* eq 'linux' {
    ok(my $ci =, "new Linux::Cpuinfo - no args");
    isa-ok($ci, Linux::Cpuinfo, "and it is the right sort of object");
    ok($ci.num-cpus > 0, "got some CPUs");

    my $count_cpus = 0;
    for $ci.cpus -> $cpu {
        isa-ok($cpu, Linux::Cpuinfo::Cpu, "the CPU is the right type of object");
        is($cpu.^name, 'Linux::Cpuinfo::Cpu::' ~ $, "and the right sub-type");

        for $cpu.fields.keys -> $field {
            ok($cpu.can($field), "and the object has a $field method");
    is($ci.num-cpus, $count_cpus, "and we saw as many cpus as we expected");
else {
    # Of course we don't actualy know how many tests we will have
    plan 228;
    skip-rest "not Linux won't test";

# vim: expandtab shiftwidth=4 ft=raku