[TT# 1592][t] Improve test for open opcode delegation. All tests in the file pass...
[parrot.git] / t / op / sysinfo.t
blob2604432165d98ead508f02053695d5437db149f4
1 #!perl
2 # Copyright (C) 2008-2010, Parrot Foundation.
3 # $Id$
5 # initial work by Brad Gilbert b2gills <at> gmail <dot> com
7 use strict;
8 use warnings;
9 use lib qw( . lib ../lib ../../lib );
11 use Test::More;
12 use Config;
14 use Parrot::Test tests => 14;
15 use Parrot::Config;
18 =head1 NAME
20 t/op/sysinfo.t - System Info
22 =head1 SYNOPSIS
24         % prove t/op/sysinfo.t
26 =head1 DESCRIPTION
28 Tests for basic system information.
30 =over 4
32 =item 1 The size of a platform integer
34 =item 2 The size of a platform float
36 =item 3 The size of a platform pointer. (Largest possible data pointer)
38 =item 4 The OS name
40 =item 5 The OS version string
42 =item 6 The OS version number string
44 =item 7 The CPU architecture
46 =item 8 The CPU model
48 =item 9, 10 The min and max INTVAL values
50 =back
52 =cut
55 my @setup = (
56     { pconfig_key => 'intvalsize',
57       pasm_key    => 1,
58       pir_key     => 'SYSINFO_PARROT_INTSIZE',
59       desc        => 'integer size',
60       reg_type    => 'I',
61     },
62     { pconfig_key => 'doublesize',
63       pasm_key    => 2,
64       pir_key     => 'SYSINFO_PARROT_FLOATSIZE',
65       desc        => 'float size',
66       reg_type    => 'I',
67     },
68     { pconfig_key => 'ptrsize',
69       pasm_key    => 3,
70       pir_key     => 'SYSINFO_PARROT_POINTERSIZE',
71       desc        => 'pointer size',
72       reg_type    => 'I',
73     },
74     { pconfig_key => 'osname',
75       pasm_key    => 4,
76       pir_key     => 'SYSINFO_PARROT_OS',
77       desc        => 'osname',
78       reg_type    => 'S',
79     },
80     { pconfig_key => 'cpuarch',
81       pasm_key    => 7,
82       pir_key     => 'SYSINFO_CPU_ARCH',
83       desc        => 'CPU Arch Family',
84       reg_type    => 'S',
85     },
88 foreach ( @setup ) {
89     if ( $_->{reg_type} eq 'I' ) {
90         pasm_output_is( <<"CODE", $PConfig{$_->{pconfig_key}}, "PASM sysinfo  $_->{desc}" );
91    sysinfo_i_ic I1, $_->{pasm_key}
92    print I1
93 end
94 CODE
95         pir_output_is( <<"CODE", $PConfig{$_->{pconfig_key}}, "PIR sysinfo  $_->{desc}" );
96 .include 'sysinfo.pasm'
97 .sub main :main
98     \$I0 = sysinfo .$_->{pir_key}
99     print \$I0
100 .end
101 CODE
102     }
103     else {
104         pasm_output_is( <<"CODE", $PConfig{$_->{pconfig_key}}, "sysinfo $_->{desc}" );
105    sysinfo_s_ic S1, $_->{pasm_key}
106    print S1
108 CODE
109         pir_output_is( <<"CODE", $PConfig{$_->{pconfig_key}}, "PIR sysinfo  $_->{desc}" );
110 .include 'sysinfo.pasm'
111 .sub main :main
112     \$S0 = sysinfo .$_->{pir_key}
113     print \$S0
114 .end
115 CODE
116     }
119 SKIP:
121     $PConfig{osname} eq 'MSWin32'
122         or skip "Tests only meaningful on Win32", 2;
123     SKIP:
124     {
125         eval { require Win32; } or
126             skip "requires package Win32 for these tests", 2;
128         my $osname = Win32::GetOSName();
129         $osname = 'WinXP' if $osname =~ m/^WinXP/;
130         TODO: {
131             local $TODO = "Not Currently Implemented";
132             pasm_output_is( <<'CODE', $osname, "sysinfo OS version string" );
133     sysinfo_s_ic S1, 5
134     print S1
136 CODE
138             my ( $osvername, $major, $minor, $id ) = Win32::GetOSVersion();
140             pasm_output_is( <<'CODE', "$major.$minor", "sysinfo OS version number string" );
141     sysinfo_s_ic S1, 6
142     print S1
144 CODE
145         } # END todo block
146     } # END inner SKIP block
147 } # END outer SKIP block
149 SKIP:
151     skip "Requires a lot of work to find out the correct answer", 1;
153     pasm_output_is( <<'CODE', $PConfig{archname}, "sysinfo CPU Model" );
154    sysinfo_s_ic S1, 8
155    print S1
157 CODE
160 # 9, 10
162 SKIP:
164     skip 'Testing only in some known platforms', 1
165         unless $PConfig{osname} eq 'linux';
167     pir_output_like( <<'CODE', '/^-[1-9][0-9]*\n[1-9][0-9]*\n$/', 'INTVAL min and max values');
168 .include 'sysinfo.pasm'
169 .sub main :main
170     $I0 = sysinfo .SYSINFO_PARROT_INTMIN
171     say $I0
172     $I0 = sysinfo .SYSINFO_PARROT_INTMAX
173     say $I0
174 .end
175 CODE
178 # Local Variables:
179 #   mode: cperl
180 #   cperl-indent-level: 4
181 #   fill-column: 100
182 # End:
183 # vim: expandtab shiftwidth=4: