1#! /usr/bin/perl -w
2#
3#
4# RCSIDENT("$SiLK: rwpollexec-set-noarchive.pl be00e4ce901e 2016-02-25 18:50:11Z mthomas $")
5
6use strict;
7use SiLKTests;
8use File::Temp ();
9
10
11# set envvar to run app under valgrind when SK_TESTS_VALGRIND is set
12check_silk_app('rwpollexec');
13
14# prefix any existing PYTHONPATH with the proper directories
15check_python_bin();
16
17# create our tempdir
18my $tmpdir = make_tempdir();
19
20# work around issue on OS X when System Integrity Protection enabled
21rwpollexec_use_alternate_shell($tmpdir);
22
23# the command that wraps rwpollexec
24my $rwpollexec_py = "$SiLKTests::PYTHON $srcdir/tests/rwpollexec-daemon.py";
25my $cmd = join " ", ("$rwpollexec_py",
26                     ($ENV{SK_TESTS_VERBOSE} ? "--verbose" : ()),
27                     ($ENV{SK_TESTS_LOG_DEBUG} ? "--log-level=debug" : ()),
28                     "--return 0",
29                     "--return 1",
30                     "--signal 9",
31                     "--term 0",
32                     "--term 1",
33                     "--hang",
34                     "--return 0",
35                     "--return 250",
36                     "--signal 3",
37                     "--term 0",
38                     "--term 127",
39                     "--hang",
40                     "--basedir=$tmpdir",
41                     "--no-archive",
42                     "--",
43                     "--flat-archive",
44                     "--polling-interval=3",
45                     "--command \"$rwpollexec_py --exec %s\"",
46                     "--timeout TERM,3",
47                     "--timeout KILL,5"
48    );
49
50my @expected_archive = qw();
51my @expected_error   = qw(1 2 4 5 7 8 10 11);
52
53# run it and check the MD5 hash of its output
54check_md5_output('ba7517a640382f4281b605f572bdaaa6', $cmd);
55
56
57# the following directories should be empty
58verify_empty_dirs($tmpdir, qw(incoming));
59
60# verify files are in the archive directory
61verify_directory_files("$tmpdir/archive", @expected_archive);
62
63# verify files are in the error directory
64verify_directory_files("$tmpdir/error", @expected_error);
65
66