| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************/ | ||
| 2 | /* Copyright 2009-2021 Barcelona Supercomputing Center */ | ||
| 3 | /* */ | ||
| 4 | /* This file is part of the DLB library. */ | ||
| 5 | /* */ | ||
| 6 | /* DLB is free software: you can redistribute it and/or modify */ | ||
| 7 | /* it under the terms of the GNU Lesser General Public License as published by */ | ||
| 8 | /* the Free Software Foundation, either version 3 of the License, or */ | ||
| 9 | /* (at your option) any later version. */ | ||
| 10 | /* */ | ||
| 11 | /* DLB is distributed in the hope that it will be useful, */ | ||
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
| 14 | /* GNU Lesser General Public License for more details. */ | ||
| 15 | /* */ | ||
| 16 | /* You should have received a copy of the GNU Lesser General Public License */ | ||
| 17 | /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */ | ||
| 18 | /*********************************************************************************/ | ||
| 19 | |||
| 20 | #include "LB_core/spd.h" | ||
| 21 | |||
| 22 | #include <stdlib.h> | ||
| 23 | #include <pthread.h> | ||
| 24 | #include <assert.h> | ||
| 25 | |||
| 26 | 1 | int main(int argc, char *argv[]) { | |
| 27 | |||
| 28 | subprocess_descriptor_t spd1, spd2; | ||
| 29 | 1 | spd1.id = 111; | |
| 30 | 1 | spd2.id = 222; | |
| 31 | |||
| 32 | 1 | spd_register(&spd1); | |
| 33 | 1 | spd_unregister(&spd1); | |
| 34 | 1 | spd_register(&spd2); | |
| 35 | 1 | spd_unregister(&spd2); | |
| 36 | |||
| 37 | 1 | spd_register(&spd1); | |
| 38 | 1 | spd_register(&spd2); | |
| 39 | |||
| 40 | 1 | const subprocess_descriptor_t **spds = spd_get_spds(); | |
| 41 | /* spds comes from a gtree, order is undetermined */ | ||
| 42 |
3/8✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
1 | assert( (spds[0]->id == spd1.id && spds[1]->id == spd2.id) |
| 43 | || (spds[0]->id == spd2.id && spds[1]->id == spd1.id) ); | ||
| 44 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( spds[2] == NULL ); |
| 45 | 1 | free(spds); | |
| 46 | |||
| 47 | 1 | pthread_t pthread = pthread_self(); | |
| 48 | 1 | spd_set_pthread(&spd1, pthread); | |
| 49 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( spd_get_pthread(&spd1) == pthread ); |
| 50 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( spd_get_pthread(&spd2) == 0 ); |
| 51 | 1 | spd_set_pthread(&spd2, pthread); | |
| 52 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( spd_get_pthread(&spd2) == pthread ); |
| 53 | |||
| 54 | 1 | spd_unregister(&spd2); | |
| 55 | 1 | spd_unregister(&spd1); | |
| 56 | |||
| 57 | 1 | return 0; | |
| 58 | } | ||
| 59 |