Commit Graph

7 Commits

Author SHA1 Message Date
Joel Brobecker
2a0e09842e daemon_utest: Stop using testcase.enable_unit_test
For some reason that I was unable to determine, trying to cover
the case failure to fork during the second fork causes an error
when running the testsuite with coverage, such as:

     $ ./coverage.sh -j16 --enable-color tests/LC28-010__daemon_utest

We get a crash during the execution of the at_exit handling when
the coverage framework tries to create a file in the root ("/")
directory, presumably to save the coverage information. I couldn't
figure out why this was happening, nor could I find a fix. Since
the code we're trying is not expected to change much over time,
and the second fork error handling is only about damage control,
I gave up on the idea. Instead, I commented out the corresponding
testing code, so as for it to be available should we try to solve
that mystery again, and I added a "pragma nocover" in run_in_daemon.

This had the side-effect of dropping one call to syslog that was
contributing to full coverage. This commit simply extends the unit
test to include a call to that function as well.

TN: U627-007
Change-Id: Iaacfd174747ff43a921f5d17e3a74900ad96a78e
2021-06-30 07:25:43 -07:00
Joel Brobecker
31bb4e4867 flush stdout and stderr before forking
This commit makes sure that the stdout and stderr output has been
flushed so that no output is left buffered by the time we call os.fork.
Otherwise, if there was any output still buffered, we would be getting
the same output printed multiple times, once by the parent process,
and once by each child process.

Found while working on the transition to Python 3.x (U530-006).

TN: U619-004
Change-Id: I9c38bfc410041e58de2a8f5d7d340f7bff599df4
2021-06-19 11:44:56 -07:00
Joel Brobecker
a075b1653e reformat all the code using black
Change-Id: Idbc70777233ab2d40ab59765abb9cbbeeb88ec63
2021-04-18 14:59:01 +04:00
Joel Brobecker
53d4420d91 hooks/daemon.py: Allow parsing with Python-3 version of flake8
This commit changes a couple of exception handlers to avoid using
a syntax which is no longer valid in Python 2.x, using a syntax
which is valid in both Python 2.x and Python 3.x insteadl.

This is good preparation for the transition to Python 3.x, and
this also makes sure the current version of this module now passes
AdaCore's internal style checker.

Change-Id: I80bd4ab61eb7bc3caa23a900cbdce66748f670b6
2020-11-23 12:27:21 +04:00
Simon Marchi
a2909b2c8d Convert print statements to print function
In preparation for the transition to Python 3, convert to using the
print function.  The special import

    from __future__ import print_function

in Python 2.7 makes "print" become the function and not the statement.
In Python 3, it has no effect.  Once the transition is done and we
exclusively use Python 3, we can simply remove the imports.

The testsuite shows no regressions.
2020-11-22 19:29:38 -05:00
Joel Brobecker
db98d5096a daemon.py: fix style violations 2013-12-26 14:32:37 +04:00
Joel Brobecker
2c74534672 Create a daemon to send all emails.
This allows the main script to return without having to wait
for all emails to be sent, especially since there is a delay
of several seconds being introduced between each email being
sent.

For LC28-010.
2012-12-29 18:41:02 +04:00