Directory: | ./ |
---|---|
File: | TESTS/TEST_SIGNAL_CATCHER/main.cpp |
Date: | 2025-05-16 18:34:22 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 20 | 20 | 100.0% |
Branches: | 12 | 13 | 92.3% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | |||
2 | /*************************************** | ||
3 | Auteur : Pierre Aubert | ||
4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
5 | Licence : CeCILL-C | ||
6 | ****************************************/ | ||
7 | |||
8 | #include <unistd.h> | ||
9 | #include <iostream> | ||
10 | #include <fstream> | ||
11 | |||
12 | #include "SignalCatcher.h" | ||
13 | |||
14 | ///Check Signal Catcher | ||
15 | /** @return true on success, false otherwise | ||
16 | */ | ||
17 | 1 | bool testSignalCatch(){ | |
18 | 1 | phoenix_addSignalCatcher(SIGQUIT); | |
19 | |||
20 | 1 | bool isSignalRecived(false); | |
21 | 1 | size_t delay(10lu); | |
22 |
3/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
3 | for(size_t i(0lu); i < delay && !isSignalRecived; ++i){ |
23 | 2 | std::cout << "Waiting for signal : i = " << i << std::endl; | |
24 | 2 | isSignalRecived = phoenix_isSignalRecived(SIGQUIT); | |
25 | 2 | usleep(10000000); | |
26 | } | ||
27 | |||
28 | 1 | std::cout << "testSignalCatch : isSignalRecived = " << isSignalRecived << std::endl; | |
29 | 1 | return isSignalRecived; | |
30 | } | ||
31 | |||
32 | 1 | int main(int argc, char **argv){ | |
33 | 1 | bool b(true); | |
34 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= testSignalCatch(); |
35 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | std::cout << "final : b = " << b << std::endl; |
36 |
1/1✓ Branch 1 taken 1 times.
|
1 | std::ofstream fs; |
37 |
1/1✓ Branch 1 taken 1 times.
|
1 | fs.open("test_phoenix_thread_signal_catcher.log"); |
38 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << b << std::endl; |
39 |
1/1✓ Branch 1 taken 1 times.
|
1 | fs.close(); |
40 | 1 | return b - 1; | |
41 | 1 | } | |
42 | |||
43 | |||
44 | |||
45 | |||
46 |