diff --git config/gen/crypto/digest_t.in config/gen/crypto/digest_t.in
index 5a3ae17..5357e29 100644
|
|
|
|
| 1 | | #! perl |
| 2 | | # Copyright (C) 2009, Parrot Foundation. |
| | 1 | #! parrot |
| | 2 | # Copyright (C) 2001-2009, Parrot Foundation. |
| 3 | 3 | # $Id$ |
| 4 | 4 | |
| 5 | | use strict; |
| 6 | | use warnings; |
| 7 | | use lib qw( . lib ../lib ../../lib ); |
| 8 | | use Test::More; |
| 9 | | use Parrot::Test; |
| 10 | | use Parrot::Config; |
| 11 | | |
| 12 | 5 | =head1 NAME |
| 13 | 6 | |
| 14 | 7 | t/dynpmc/@TEMP_md_file@.t - test the @TEMP_md_name@ PMC (part of digest_group) |
| … |
… |
|
| 23 | 16 | |
| 24 | 17 | =cut |
| 25 | 18 | |
| 26 | | if ( !$PConfig{has_crypto} ) { |
| 27 | | plan skip_all => "No crypto library available"; |
| 28 | | } |
| 29 | | elsif ( $PConfig{openssl_version} lt '@TEMP_md_skip@' ) { |
| 30 | | plan skip_all => "Too old library"; |
| 31 | | } |
| 32 | | else { |
| 33 | | plan tests => 2; |
| 34 | | } |
| | 19 | .sub main :main |
| | 20 | .include 'test_more.pir' |
| | 21 | .include 'iglobals.pasm' |
| | 22 | .local pmc config_hash, interp |
| | 23 | |
| | 24 | plan(2) |
| | 25 | interp = getinterp |
| | 26 | config_hash = interp[.IGLOBALS_CONFIG_HASH] |
| | 27 | $S0 = config_hash['has_crypto'] |
| | 28 | $S1 = config_hash['openssl_version'] |
| | 29 | unless $S0 goto no_crypto |
| | 30 | if $S1 < '0.9' goto old_openssl |
| | 31 | |
| | 32 | test_typeof() |
| | 33 | test_digest() |
| | 34 | .return() |
| | 35 | no_crypto: |
| | 36 | skip(2, 'No crypto library available') |
| | 37 | .return() |
| | 38 | old_openssl: |
| | 39 | skip(2, 'Too old openssl library, needs at least 0.9') |
| | 40 | .end |
| | 41 | |
| 35 | 42 | |
| 36 | | pir_output_is( << 'CODE', << 'OUTPUT', '@TEMP_md_name@ typeof' ); |
| 37 | | .sub test :main |
| | 43 | .sub test_typeof |
| 38 | 44 | $P0 = loadlib 'digest_group' |
| 39 | 45 | .local pmc md |
| 40 | 46 | md = new '@TEMP_md_name@' |
| 41 | 47 | $S0 = typeof md |
| 42 | | say $S0 |
| | 48 | is($S0, '@TEMP_md_name@', '@TEMP_md_name@ typeof') |
| 43 | 49 | .end |
| 44 | | CODE |
| 45 | | @TEMP_md_name@ |
| 46 | | OUTPUT |
| 47 | 50 | |
| 48 | | pir_output_like( << 'CODE', << 'OUTPUT', '@TEMP_md_name@ digest' ); |
| 49 | | .sub test :main |
| | 51 | .sub test_digest |
| 50 | 52 | $P0 = loadlib 'digest_group' |
| 51 | 53 | .local pmc md |
| 52 | 54 | md = new '@TEMP_md_name@' |
| … |
… |
|
| 57 | 59 | $P0 = split '', $S0 |
| 58 | 60 | new $P1, 'FixedPMCArray' |
| 59 | 61 | set $P1, 1 |
| | 62 | $S3 = '' |
| 60 | 63 | L1: |
| 61 | 64 | unless $P0 goto L2 |
| 62 | 65 | $S1 = shift $P0 |
| 63 | 66 | $I1 = ord $S1 |
| 64 | 67 | $P1[0] = $I1 |
| 65 | 68 | $S2 = sprintf '%02x', $P1 |
| 66 | | print $S2 |
| | 69 | $S3 .= $S2 |
| 67 | 70 | goto L1 |
| 68 | 71 | L2: |
| 69 | | print "\n" |
| | 72 | like($S3, '@TEMP_md_result@', '@TEMP_md_name@ digest') |
| 70 | 73 | .end |
| 71 | | CODE |
| 72 | | /^@TEMP_md_result@$/ |
| 73 | | OUTPUT |
| 74 | 74 | |
| 75 | 75 | # Local Variables: |
| 76 | 76 | # mode: cperl |
| 77 | 77 | # cperl-indent-level: 4 |
| 78 | 78 | # fill-column: 100 |
| 79 | 79 | # End: |
| 80 | | # vim: expandtab shiftwidth=4: |
| | 80 | # vim: expandtab shiftwidth=4 filetype=pir: |