| 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 "unique_shmem.h" | ||
| 21 | |||
| 22 | #include "LB_core/DLB_kernel.h" | ||
| 23 | #include "LB_core/spd.h" | ||
| 24 | #include "LB_comm/shmem_cpuinfo.h" | ||
| 25 | #include "LB_comm/shmem_procinfo.h" | ||
| 26 | /* #include "apis/dlb_talp.h" */ | ||
| 27 | #include "apis/dlb_errors.h" | ||
| 28 | #include "support/mask_utils.h" | ||
| 29 | #include "support/options.h" | ||
| 30 | |||
| 31 | #include <sched.h> | ||
| 32 | #include <string.h> | ||
| 33 | /* #include <unistd.h> */ | ||
| 34 | #include <stdio.h> | ||
| 35 | #include <assert.h> | ||
| 36 | |||
| 37 | /* Test DROM inheritance */ | ||
| 38 | |||
| 39 | |||
| 40 | 1 | int main(int argc, char *argv[]) { | |
| 41 | |||
| 42 | enum { SHMEM_SIZE_MULTIPLIER = 1 }; | ||
| 43 | |||
| 44 | enum { SYS_SIZE = 4 }; | ||
| 45 | 1 | mu_testing_set_sys_size(SYS_SIZE); | |
| 46 | |||
| 47 | 1 | char options[64] = "--drom --shm-key="; | |
| 48 | 1 | strcat(options, SHMEM_KEY); | |
| 49 | |||
| 50 | /* parent process */ | ||
| 51 | cpu_set_t process_mask; | ||
| 52 | 1 | mu_parse_mask("0-3", &process_mask); | |
| 53 | 1 | subprocess_descriptor_t spd = {.id = 111}; | |
| 54 | 1 | options_init(&spd.options, options); | |
| 55 | 1 | memcpy(&spd.process_mask, &process_mask, sizeof(cpu_set_t)); | |
| 56 | |||
| 57 | char children_options[80]; | ||
| 58 | 1 | snprintf(children_options, 80, "--drom --preinit-pid=%d --shm-key=%s", spd.id, SHMEM_KEY); | |
| 59 | |||
| 60 | /* child 0 */ | ||
| 61 | cpu_set_t child0_mask; | ||
| 62 | 1 | mu_parse_mask("0", &child0_mask); | |
| 63 | 1 | subprocess_descriptor_t child0_spd = {.id = 1110}; | |
| 64 | |||
| 65 | /* child 1 */ | ||
| 66 | cpu_set_t child1_mask; | ||
| 67 | 1 | mu_parse_mask("1", &child1_mask); | |
| 68 | 1 | subprocess_descriptor_t child1_spd = {.id = 1111}; | |
| 69 | |||
| 70 | /* child 2 */ | ||
| 71 | cpu_set_t child2_mask; | ||
| 72 | 1 | mu_parse_mask("2", &child2_mask); | |
| 73 | 1 | subprocess_descriptor_t child2_spd = {.id = 1112}; | |
| 74 | |||
| 75 | /* child 3 */ | ||
| 76 | cpu_set_t child3_mask; | ||
| 77 | 1 | mu_parse_mask("3", &child3_mask); | |
| 78 | 1 | subprocess_descriptor_t child3_spd = {.id = 1113}; | |
| 79 | |||
| 80 | /* Parent process pre-initializes [0-3], "child" processes inherit one by one */ | ||
| 81 | { | ||
| 82 | /* DLB_DROM_Attach: */ | ||
| 83 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_cpuinfo_ext__init(SHMEM_KEY, 0) == DLB_SUCCESS ); |
| 84 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_procinfo_ext__init(SHMEM_KEY, SHMEM_SIZE_MULTIPLIER) == DLB_SUCCESS ); |
| 85 | |||
| 86 | /* DLB_DROM_PreInit: */ | ||
| 87 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_procinfo_ext__preinit(spd.id, &process_mask, DLB_DROM_FLAGS_NONE) |
| 88 | == DLB_SUCCESS ); | ||
| 89 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_cpuinfo_ext__preinit(spd.id, &process_mask, DLB_DROM_FLAGS_NONE) |
| 90 | == DLB_SUCCESS ); | ||
| 91 | |||
| 92 | /* [Childs] DLB_Init: */ | ||
| 93 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Initialize(&child0_spd, child0_spd.id, 0, &child0_mask, children_options) |
| 94 | == DLB_SUCCESS ); | ||
| 95 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Initialize(&child1_spd, child1_spd.id, 0, &child1_mask, children_options) |
| 96 | == DLB_SUCCESS ); | ||
| 97 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Initialize(&child2_spd, child2_spd.id, 0, &child2_mask, children_options) |
| 98 | == DLB_SUCCESS ); | ||
| 99 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Initialize(&child3_spd, child3_spd.id, 0, &child3_mask, children_options) |
| 100 | == DLB_SUCCESS ); | ||
| 101 | |||
| 102 | /* [Childs] DLB_Finalize: */ | ||
| 103 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Finish(&child0_spd) == DLB_SUCCESS ); |
| 104 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Finish(&child1_spd) == DLB_SUCCESS ); |
| 105 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Finish(&child2_spd) == DLB_SUCCESS ); |
| 106 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( Finish(&child3_spd) == DLB_SUCCESS ); |
| 107 | |||
| 108 | /* DLB_DROM_PostFinalize: */ | ||
| 109 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_procinfo_ext__postfinalize(spd.id, 0) == DLB_ERR_NOPROC ); |
| 110 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_cpuinfo_ext__postfinalize(spd.id) == DLB_SUCCESS ); |
| 111 | |||
| 112 | /* DLB_DROM_Detach(): */ | ||
| 113 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_cpuinfo_ext__finalize() == DLB_SUCCESS ); |
| 114 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_procinfo_ext__finalize() == DLB_SUCCESS ); |
| 115 | } | ||
| 116 | |||
| 117 | 1 | mu_finalize(); | |
| 118 | |||
| 119 | 1 | return 0; | |
| 120 | } | ||
| 121 |