in reply to mocking or trapping system calls

When I work on code that makes expensive calls to external programs, I mock the dynamic data with cat. I make a static copy of real output (e.g. $ du / > du.txt ) and then I change $binary in my script.

my $du = '/bin/du'; defined $DEBUG and $du = '/bin/cat ./du.txt';

Perhaps something like that could work for you.