Skip to content

Commit

Permalink
re-enable native_pbc
Browse files Browse the repository at this point in the history
use new t/native_pbc/testdata templates to generate pbc's,
change string to use binary and utf8 encodings,
update mk_native_pbc.
TODO: little-endian pbc files missing, preparing a 8_le qemu image to generate them.
  • Loading branch information
Reini Urban committed Aug 23, 2012
1 parent d20f712 commit 7fd17b9
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 51 deletions.
4 changes: 2 additions & 2 deletions t/native_pbc/header.t
Expand Up @@ -6,8 +6,8 @@ use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;

use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
#use Parrot::Test tests => 9;
#use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
use Parrot::Test tests => 9;

use File::Temp;
use Parrot::Config;
Expand Down
7 changes: 5 additions & 2 deletions t/native_pbc/integer.t
Expand Up @@ -8,8 +8,8 @@ use Test::More;
use Parrot::Config;
use Parrot::BuildUtil;

use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
#use Parrot::Test tests => 7;
#use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
use Parrot::Test tests => 7;

=head1 NAME
Expand Down Expand Up @@ -53,6 +53,9 @@ native pbcs.
_8 (4_le) i386 32 bit opcode_t, 4 byte intval, 4 byte single float
(linux-gcc-i386 or cygwin with --floatval="float")
_9 (4_be) big-endian 32 bit opcode_t, 4 byte intval, 4 byte single float
(darwin or debian/ppc with --floatval="float")
=cut

=begin comment
Expand Down
Binary file modified t/native_pbc/integer_1.pbc
Binary file not shown.
Binary file modified t/native_pbc/integer_2.pbc
Binary file not shown.
Binary file modified t/native_pbc/integer_4.pbc
Binary file not shown.
Binary file modified t/native_pbc/integer_5.pbc
Binary file not shown.
12 changes: 6 additions & 6 deletions t/native_pbc/number.t
Expand Up @@ -8,8 +8,8 @@ use Test::More;
use Parrot::Config;
use Parrot::BuildUtil;

use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
#use Parrot::Test tests => 7;
#use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
use Parrot::Test tests => 7;

=head1 NAME
Expand Down Expand Up @@ -54,7 +54,7 @@ native pbcs.
(linux-gcc-i386 or cygwin with --floatval="float")
_9 (4_be) big-endian 32 bit opcode_t, 4 byte intval, 4 byte single float
(darwin/ppc with --floatval="float")
(darwin or debian/ppc with --floatval="float")
=cut

Expand All @@ -66,7 +66,7 @@ native pbcs.
# If your wordsize/floattype/endianess is not covered here
# please add it:
$ ./parrot -o n.pbc t/op/number_1.pasm
$ ./parrot -o n.pbc t/native_pbc/testdata/number.pasm
$ make pbc_dump
$ ./pbc_dump -h n.pbc
$ mv n.pbc t/native_pbc/number_$(N).pbc
Expand Down Expand Up @@ -275,7 +275,7 @@ test_pbc_number(3, "(8_be) PPC BE 32 bit opcode_t, 4 byte intval, 8 byte double"
# wordsize = 8 (interpreter's wordsize/INTVAL = 8/8)
# byteorder = 0 (interpreter's byteorder = 0)
# floattype = 0 (interpreter's NUMVAL_SIZE = 8)
# parrot-version 0.9.1, bytecode-version 3.38
# parrot-version 4.6.0, bytecode-version 12.0
# UUID type = 0, UUID size = 0
# no endianize, no opcode, no numval transform
# dirformat = 1
Expand All @@ -287,7 +287,7 @@ test_pbc_number(4, "(8_le) x86_64 64 bit opcode_t, 8 byte intval, 8 byte double"
# wordsize = 8 (interpreter's wordsize/INTVAL = 8/8)
# byteorder = 0 (interpreter's byteorder = 0)
# floattype = 2 (interpreter's NUMVAL_SIZE = 16)
# parrot-version 0.9.1, bytecode-version 3.38
# parrot-version 4.6.0, bytecode-version 12.0
# UUID type = 0, UUID size = 0
# no endianize, no opcode, no numval transform
# dirformat = 1
Expand Down
Binary file modified t/native_pbc/number_1.pbc
Binary file not shown.
Binary file modified t/native_pbc/number_4.pbc
Binary file not shown.
Binary file modified t/native_pbc/number_5.pbc
Binary file not shown.
29 changes: 18 additions & 11 deletions t/native_pbc/string.t
Expand Up @@ -8,8 +8,8 @@ use Test::More;
use Parrot::Config;
use Parrot::BuildUtil;

use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
#use Parrot::Test tests => 6;
#use Parrot::Test skip_all => 'pending robust testing strategy, GH #394';
use Parrot::Test tests => 6;

=head1 NAME
Expand All @@ -23,8 +23,8 @@ t/native_pbc/string.t - PBC string tests
Tests word-size/endian-ness for different architectures.
We test 4+8 byte opcode_t with le and be.
Foreign encodings (TODO) and charsets are tested witin F<t/op/strings.t>
We test 4+8 byte opcode_t with le and be, binary and utf8 encoding.
More foreign encodings (TODO) and charsets are tested within F<t/op/strings.t>
and F<t/op/strings_cs.t>
These tests usually only work on updated native pbc test files.
Expand All @@ -40,12 +40,13 @@ native pbcs.
_5 (skipped) x86_64 16 bit long double 64 bit opcode_t
_6 big-endian 64 bit opcode_t, 8 byte double (Sparc64/Solaris, MIPS irix)
_7 (skipped) big-endian 64 bit opcode_t, 16 byte long double
_8 (skipped) i386 32 bit opcode_t, 32 bit intval, 4-byte float --floatval=float
=cut

=begin comment
The PBC is generated from t/op/string_133.pasm for different architectures.
The PBC is generated from t/native_pbc/testdata/string.pasm for different architectures.
For adding tests, see the comments in t/native_pbc/number.t
Expand Down Expand Up @@ -73,17 +74,21 @@ my $bc = ($bc_major . "." . $bc_minor);
my $arch = this_arch();
# all should pass
my $todo = {};
my $nn = "not needed";
my $skip = {
2 => "dummy",
5 => "dummy"
2 => $nn,
5 => $nn,
7 => $nn,
8 => $nn
};

my $output = << 'END_OUTPUT';
# 4th string as utf8 "Ärger"
my $output = "
%Ec
Dw
\xC2\x80
ABCX
X
END_OUTPUT
\xC3\x84rger
";

# test_pbc_string(1, "i386 8-byte double float, 32 bit opcode_t");
sub test_pbc_string {
Expand Down Expand Up @@ -151,6 +156,8 @@ test_pbc_string(3, "PPC BE 32 bit opcode_t, 4 byte intval");
test_pbc_string(4, "i86_64 64 bit opcode_t, 8 byte intval");
test_pbc_string(5, "dummy" );
test_pbc_string(6, "big-endian 64 bit opcode_t, 8 byte intval");
#test_pbc_number(7, "(16_be) big-endian 64 bit opcode_t, 8 byte intval, 16 byte long double");
#test_pbc_number(8, "(4_le) i386 32 bit opcode_t, 4 byte intval, 4 byte single float");

# Local Variables:
# mode: cperl
Expand Down
Binary file modified t/native_pbc/string_1.pbc
Binary file not shown.
Binary file removed t/native_pbc/string_2.pbc
Binary file not shown.
Binary file modified t/native_pbc/string_4.pbc
Binary file not shown.
Binary file removed t/native_pbc/string_5.pbc
Binary file not shown.
10 changes: 10 additions & 0 deletions t/native_pbc/testdata/integer.pasm
@@ -0,0 +1,10 @@
# Copyright (C) 2012, Parrot Foundation.

print 0x10203040
end

# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
13 changes: 9 additions & 4 deletions t/native_pbc/testdata/string.pasm
@@ -1,14 +1,19 @@
# Copyright (C) 2009, Parrot Foundation.
# Copyright (C) 2012, Parrot Foundation.

set S1, "abc"
set S2, "EE"
concat S0, S1, S2
set S1, binary:"%Ec"
set S2, binary:"\xC2\x80"
set S3, binary:"ABCX"
set S4, utf8:"\xC4rger"
print S0
print "\n"
print S1
print "\n"
print S2
print "\n"
print S3
print "\n"
print S4
print "\n"
end

# Local Variables:
Expand Down
46 changes: 20 additions & 26 deletions tools/dev/mk_native_pbc
Expand Up @@ -2,29 +2,29 @@

# sh tools/dev/mk_native_pbc [--noconf]
#
# generate t/native_pbc/*_*.pbc
# Generate/update t/native_pbc/*_*.pbc
# This should only be run on known systems to regenerate the native pbcs.
# Better do not try that on mingw, use cygwin instead.
#
# NOTE: For _2/_5/_8 this will need a compiler with long double support
# NOTE2: Installing ccache speeds this process up considerably
# NOTE: For _2/_5/_8 this will need a compiler with long double support.
# NOTE2: Installing ccache speeds this process up considerably.

# _1 i386 32 bit opcode_t, 32 bit intval (linux-gcc-ix86, freebsd-gcc, cygwin)
# _2 i386 32 bit opcode_t, 32 bit intval, 12 bit long double (linux-gcc-ix86)
# _3 PPC BE 32 bit opcode_t, 32 bit intval (darwin-ppc)
# _4 x86_64 double float 64 bit opcode_t (linux-gcc-x86_64, solaris-cc-64int)
# _5 x86_64 16 byte long double 64 bit opcode_t (linux-gcc-x86_64, solaris-cc-64int)
# _6 big-endian 64-bit (sparc, irix or similar)
# _7 i386 32 bit opcode_t, 32 bit intval, 4-byte float --floatval=float
# _8 big-endian 64-bit 16-byte long-double (sparc64, irix, mips or similar)
# _7 big-endian 64-bit 16-byte long-double (sparc64, irix, mips or similar)
# _8 (skipped) i386 32 bit opcode_t, 32 bit intval, 4-byte float --floatval=float
# _9 (skipped) big-endian 32 bit opcode_t, 4 byte intval, 4 byte single float
# (darwin or debian/ppc with --floatval="float")


#tests:
#parrot -o i.pbc -a - <<EOF
# print 0x10203040
# end
# EOF
# t/op/number_1.pasm
# t/op/string_133.pasm
# t/native_pbc/testdata/integer.pasm
# t/native_pbc/testdata/number.pasm
# t/native_pbc/testdata/string.pasm

# check 32/64 bit, endianess, hugefloat
N=
Expand Down Expand Up @@ -122,20 +122,16 @@ fi
tail myconfig
make -s || exit 1

./parrot -o t/native_pbc/integer_${N}.pbc -a - <<EOF
print 0x10203040
end
EOF
[ $? -le 0 ] && echo "t/native_pbc/integer_${N}.pbc updated"
./parrot -o t/native_pbc/number_${N}.pbc t/native_pbc/testdata/number.pasm && echo "t/native_pbc/number_${N}.pbc updated"
./parrot -o t/native_pbc/string_${N}.pbc t/native_pbc/testdata/string.pasm && echo "t/native_pbc/string_${N}.pbc updated"
for T in integer number string
do
./parrot -o t/native_pbc/${T}_${N}.pbc t/native_pbc/testdata/${T}.pasm && \
echo "t/native_pbc/${T}_${N}.pbc updated"
done

make pbc_dump$exe
./pbc_dump -h t/native_pbc/number_${N}.pbc

perl t/harness t/native_pbc/integer.t && \
perl t/harness t/native_pbc/number.t && \
perl t/harness t/native_pbc/string.t
perl t/harness t/native_pbc/integer.t t/native_pbc/number.t t/native_pbc/string.t

if [ "$enable_long_double" = "1" ]; then
if [ "$1" = "--noconf" ]; then
Expand All @@ -153,14 +149,12 @@ if [ "$enable_long_double" = "1" ]; then
#if [ "numvalsize" = "12" ]; then echo "Only 12 byte double. Sorry"; exit; fi
# 1+2, 4+5, 6+7
M=$((N+1))
[ -e t/op/number_1.pasm ] || perl t/harness t/op/number.t
./parrot -o t/native_pbc/number_${M}.pbc t/op/number_1.pasm && echo "t/native_pbc/number_${M}.pbc updated"
./parrot -o t/native_pbc/number_${M}.pbc t/native_pbc/testdata/number.pasm \
&& echo "t/native_pbc/number_${M}.pbc updated"
make pbc_dump$exe
./pbc_dump -h t/native_pbc/number_${M}.pbc

perl t/harness t/native_pbc/integer.t && \
perl t/harness t/native_pbc/number.t && \
perl t/harness t/native_pbc/string.t
perl t/harness t/native_pbc/integer.t t/native_pbc/number.t t/native_pbc/string.t
fi

echo "You should run these commands to update the PBC files in your repo:"
Expand Down

0 comments on commit 7fd17b9

Please sign in to comment.