#!/usr/bin/env perl
# This file was generated by makeTestfile.pl

use strict;
use Cwd 'abs_path';
use File::Basename;
my $tool = basename($0);

$ENV{HARNESS_ACTIVE} = 1 if scalar @ARGV && shift eq '-tap';
$ENV{TOP} = abs_path($ENV{TOP}) if exists $ENV{TOP};

# The timeout value below can be set in the Makefile that builds
# this test script. Add this line and adjust the value (in seconds):
#   initHookTest.t: export EPICS_UNITTEST_TIMEOUT=500
my $timeout = $ENV{EPICS_UNITTEST_TIMEOUT} // 500;

my $pid = fork();
die "$tool: Can't fork for './initHookTest': $!\n"
    unless defined $pid;

if ($pid) {
    # Parent process
    $SIG{ALRM} = sub {
        # Time's up, kill the child
        kill 9, $pid;
        print "\n#### Test stopped by $tool after $timeout seconds\n";
        die "$tool: Timed out './initHookTest' after $timeout seconds\n";
    };

    alarm $timeout;
    waitpid $pid, 0;
    alarm 0;
    exit $? >> 8;
}
else {
    # Child process
    exec './initHookTest'
        or die "$tool: Can't run './initHookTest': $!\n";
}
