summaryrefslogtreecommitdiffstats
path: root/botan/wrappers/perl-xs/t/testutl.pl
diff options
context:
space:
mode:
Diffstat (limited to 'botan/wrappers/perl-xs/t/testutl.pl')
-rw-r--r--botan/wrappers/perl-xs/t/testutl.pl26
1 files changed, 26 insertions, 0 deletions
diff --git a/botan/wrappers/perl-xs/t/testutl.pl b/botan/wrappers/perl-xs/t/testutl.pl
new file mode 100644
index 0000000..add6f6a
--- /dev/null
+++ b/botan/wrappers/perl-xs/t/testutl.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+sub random_message_ok
+{
+ my ($pipe, $iter, $chunkmax) = @_;
+ $iter = 100 unless defined $iter;
+ $chunkmax = 300 unless defined $chunkmax;
+ eval {
+ my $input = '';
+ $pipe->start_msg();
+ for(my $i = 0; $i < $iter; $i++)
+ {
+ my $chunk = '';
+ my $chunklen = int(rand($chunkmax));
+ $chunk .= pack("C", int(rand(256))) while $chunklen--;
+ $input .= $chunk;
+ $pipe->write($chunk);
+ }
+ $pipe->end_msg();
+ my $msg_num = $pipe->message_count() -1;
+ my $output = $pipe->read(0xFFFFFFFF, $msg_num);
+ return $input eq $output;
+ };
+}
+
+1;