1#!/bin/sh 2 3# running this script intermittently yields 4# 5# Magic number checking on storable file failed at ... 6# 7# but it is difficult to trigger this error 100% reliably 8# as would be needed to turn this script into an actual test 9 10perl -I. -x t/st_concurrency st_shared & 11perl -I. -x t/st_concurrency st_shared & 12perl -I. -x t/st_concurrency st_shared & 13perl -I. -x t/st_concurrency st_shared & 14wait && exec rm st_shared 15 16#!perl 17use strict; use warnings; 18 19use Memoize::Storable; 20use Fcntl 'LOCK_EX'; 21 22sub rand32 () { int rand 1<<32 } 23 24# the script locks itself to increase the likelihood of the error: 25# after releasing the lock, the first process writes to the file 26# just as another process acquires the lock and starts to read it 27# (but this still does not trigger the error reliably) 28 29open my $fh, $0 or die $!; 30flock $fh, LOCK_EX or die $!; 31 32tie my %cache => 'Memoize::Storable', $ARGV[0]; 33$cache{(rand32)} = rand32; 34 35close $fh; 36# vim: ft=perl 37