| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************/ | ||
| 2 | /* Copyright 2009-2024 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 | /* Test basic mask utils functions that do not need to read system's topology, | ||
| 21 | * i.e., mostly mask operations */ | ||
| 22 | |||
| 23 | #include "support/mask_utils.h" | ||
| 24 | |||
| 25 | #include <assert.h> | ||
| 26 | #include <sched.h> | ||
| 27 | #include <stdio.h> | ||
| 28 | #include <string.h> | ||
| 29 | |||
| 30 | 1 | int main(int argc, char *argv[]) { | |
| 31 | |||
| 32 | cpu_set_t mask0, mask1, mask2; | ||
| 33 | 1 | CPU_ZERO(&mask0); | |
| 34 | 1 | mu_parse_mask("0,1", &mask1); | |
| 35 | 1 | mu_parse_mask("0-3", &mask2); | |
| 36 | |||
| 37 | /* mu_is_subset */ | ||
| 38 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_subset(&mask0, &mask0) ); |
| 39 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_subset(&mask0, &mask1) ); |
| 40 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_subset(&mask0, &mask2) ); |
| 41 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_subset(&mask1, &mask0) ); |
| 42 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_subset(&mask1, &mask1) ); |
| 43 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_subset(&mask1, &mask2) ); |
| 44 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_subset(&mask2, &mask0) ); |
| 45 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_subset(&mask2, &mask1) ); |
| 46 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_subset(&mask2, &mask2) ); |
| 47 | |||
| 48 | /* mu_is_superset */ | ||
| 49 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_superset(&mask0, &mask0) ); |
| 50 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_superset(&mask0, &mask1) ); |
| 51 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_superset(&mask0, &mask2) ); |
| 52 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_superset(&mask1, &mask0) ); |
| 53 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_superset(&mask1, &mask1) ); |
| 54 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_superset(&mask1, &mask2) ); |
| 55 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_superset(&mask2, &mask0) ); |
| 56 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_superset(&mask2, &mask1) ); |
| 57 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_superset(&mask2, &mask2) ); |
| 58 | |||
| 59 | /* mu_is_proper_subset */ | ||
| 60 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_subset(&mask0, &mask0) ); |
| 61 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_proper_subset(&mask0, &mask1) ); |
| 62 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_proper_subset(&mask0, &mask2) ); |
| 63 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_subset(&mask1, &mask0) ); |
| 64 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_subset(&mask1, &mask1) ); |
| 65 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_proper_subset(&mask1, &mask2) ); |
| 66 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_subset(&mask2, &mask0) ); |
| 67 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_subset(&mask2, &mask1) ); |
| 68 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_subset(&mask2, &mask2) ); |
| 69 | |||
| 70 | /* mu_is_proper_superset */ | ||
| 71 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_superset(&mask0, &mask0) ); |
| 72 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_superset(&mask0, &mask1) ); |
| 73 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_superset(&mask0, &mask2) ); |
| 74 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_proper_superset(&mask1, &mask0) ); |
| 75 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_superset(&mask1, &mask1) ); |
| 76 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_superset(&mask1, &mask2) ); |
| 77 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_proper_superset(&mask2, &mask0) ); |
| 78 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_is_proper_superset(&mask2, &mask1) ); |
| 79 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_is_proper_superset(&mask2, &mask2) ); |
| 80 | |||
| 81 | /* mu_intersects */ | ||
| 82 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_intersects(&mask0, &mask0) ); |
| 83 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_intersects(&mask0, &mask1) ); |
| 84 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_intersects(&mask0, &mask2) ); |
| 85 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_intersects(&mask1, &mask0) ); |
| 86 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_intersects(&mask1, &mask1) ); |
| 87 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_intersects(&mask1, &mask2) ); |
| 88 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( !mu_intersects(&mask2, &mask0) ); |
| 89 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_intersects(&mask2, &mask1) ); |
| 90 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_intersects(&mask2, &mask2) ); |
| 91 | |||
| 92 | /* mu_subtract */ | ||
| 93 | cpu_set_t result; | ||
| 94 | 1 | mu_subtract(&result, &mask1, &mask0); | |
| 95 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | assert( CPU_COUNT(&result) == 2 && |
| 96 | CPU_ISSET(0, &result) && CPU_ISSET(1, &result) ); | ||
| 97 | 1 | mu_subtract(&result, &mask1, &mask2); | |
| 98 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( CPU_COUNT(&result) == 0 ); |
| 99 | 1 | mu_subtract(&result, &mask2, &mask1); | |
| 100 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | assert( CPU_COUNT(&result) == 2 && |
| 101 | CPU_ISSET(2, &result) && CPU_ISSET(3, &result) ); | ||
| 102 | 1 | mu_subtract(&result, &mask1, &mask1); | |
| 103 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( CPU_COUNT(&result) == 0 ); |
| 104 | |||
| 105 | /* mu_and, mu_or, mu_count */ | ||
| 106 | 1 | mu_and(&result, &mask0, &mask1); | |
| 107 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( CPU_EQUAL(&result, &mask0) ); |
| 108 | 1 | mu_or(&result, &mask0, &mask1); | |
| 109 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( CPU_EQUAL(&result, &mask1) ); |
| 110 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | assert( mu_count(&result) == CPU_COUNT(&mask1) ); |
| 111 | |||
| 112 | // warning: from this point mask0 is no longer an empty mask | ||
| 113 | cpu_set_t empty_mask, mask5, mask200; | ||
| 114 | 1 | CPU_ZERO(&empty_mask); | |
| 115 | 1 | CPU_ZERO(&mask0); | |
| 116 | 1 | CPU_ZERO(&mask5); | |
| 117 | 1 | CPU_ZERO(&mask200); | |
| 118 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_SET(0, &mask0); |
| 119 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_SET(5, &mask5); |
| 120 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_SET(200, &mask200); |
| 121 | |||
| 122 | /* CPU_SETSIZE is machine-dependent */ | ||
| 123 | enum { BUFFER_SIZE = 16 }; | ||
| 124 | 1 | int max_cpuid = CPU_SETSIZE - 1; | |
| 125 | |||
| 126 | /* first and last, on most systems: 0,1023 */ | ||
| 127 | char fl_mask_raw[BUFFER_SIZE]; | ||
| 128 | char fl_mask_sq[BUFFER_SIZE]; | ||
| 129 | char fl_mask_quoted[BUFFER_SIZE]; | ||
| 130 | 1 | snprintf(fl_mask_raw, BUFFER_SIZE, "0,%d", max_cpuid); | |
| 131 | 1 | snprintf(fl_mask_sq, BUFFER_SIZE, "[0,%d]", max_cpuid); | |
| 132 | 1 | snprintf(fl_mask_quoted, BUFFER_SIZE, "\"0,%d\"", max_cpuid); | |
| 133 | cpu_set_t fl_mask; | ||
| 134 | 1 | mu_parse_mask(fl_mask_raw, &fl_mask); | |
| 135 | |||
| 136 | /* first to last, on most systems: 0-1023 */ | ||
| 137 | char full_mask_raw[BUFFER_SIZE]; | ||
| 138 | char full_mask_sq[BUFFER_SIZE]; | ||
| 139 | char full_mask_quoted[BUFFER_SIZE]; | ||
| 140 | 1 | snprintf(full_mask_raw, BUFFER_SIZE, "0-%d", max_cpuid); | |
| 141 | 1 | snprintf(full_mask_sq, BUFFER_SIZE, "[0-%d]", max_cpuid); | |
| 142 | 1 | snprintf(full_mask_quoted, BUFFER_SIZE, "\"0-%d\"", max_cpuid); | |
| 143 | cpu_set_t full_mask; | ||
| 144 | 1 | mu_parse_mask(full_mask_raw, &full_mask); | |
| 145 | |||
| 146 | /* mu_get_single_cpu */ | ||
| 147 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_single_cpu(&mask0) == 0); |
| 148 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_single_cpu(&mask5) == 5); |
| 149 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_single_cpu(&mask200) == 200); |
| 150 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_single_cpu(&full_mask) == -1); |
| 151 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_single_cpu(&empty_mask) == -1); |
| 152 | |||
| 153 | /* mu_get_first_cpu */ | ||
| 154 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_first_cpu(&mask0) == 0 ); |
| 155 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_first_cpu(&mask5) == 5 ); |
| 156 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_first_cpu(&mask200) == 200 ); |
| 157 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_first_cpu(&full_mask) == 0); |
| 158 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_first_cpu(&empty_mask) == -1 ); |
| 159 | |||
| 160 | /* mu_get_last_cpu */ | ||
| 161 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_last_cpu(&mask0) == 0 ); |
| 162 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_last_cpu(&mask1) == 1 ); |
| 163 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_last_cpu(&mask200) == 200 ); |
| 164 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_last_cpu(&full_mask) == max_cpuid); |
| 165 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_last_cpu(&empty_mask) == -1 ); |
| 166 | |||
| 167 | /* mu_get_next_cpu */ | ||
| 168 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&mask0, -2) == -1 ); |
| 169 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&mask0, -1) == 0 ); |
| 170 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&mask1, 0) == 1 ); |
| 171 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&mask1, 1) == -1 ); |
| 172 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_CLR(42, &full_mask); |
| 173 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&full_mask, 41) == 43 ); |
| 174 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&full_mask, 42) == 43 ); |
| 175 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_SET(42, &full_mask); |
| 176 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_CLR(63, &full_mask); |
| 177 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&full_mask, 62) == 64 ); |
| 178 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&full_mask, 63) == 64 ); |
| 179 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_SET(63, &full_mask); |
| 180 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&fl_mask, 0) == max_cpuid ); /* 1st ulong */ |
| 181 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&fl_mask, 65) == max_cpuid ); /* 2nd ulong */ |
| 182 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&fl_mask, 130) == max_cpuid ); /* 3rd ulong */ |
| 183 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_cpu(&fl_mask, 250) == max_cpuid ); /* 4th ulong */ |
| 184 | |||
| 185 | /* first, last and next */ | ||
| 186 | 1 | int sum = 0; | |
| 187 |
2/2✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 1 times.
|
1025 | for (int cpuid = mu_get_first_cpu(&full_mask); cpuid >= 0; |
| 188 | 1024 | cpuid = mu_get_next_cpu(&full_mask, cpuid)) { | |
| 189 | 1024 | sum += cpuid; | |
| 190 | } | ||
| 191 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( sum == max_cpuid*(max_cpuid+1)/2 ); |
| 192 | |||
| 193 | /* mu_get_next_unset */ | ||
| 194 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_unset(&mask0, -2) == -1 ); |
| 195 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_unset(&mask0, -1) == 1 ); |
| 196 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_unset(&mask0, 0) == 1 ); |
| 197 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_unset(&mask0, 1) == 2 ); |
| 198 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_unset(&mask5, 5) == 6 ); |
| 199 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_get_next_unset(&full_mask, 0) == -1 ); |
| 200 | |||
| 201 | /* mu_to_str */ | ||
| 202 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&mask0), "[0]") == 0 ); |
| 203 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&mask1), "[0,1]") == 0 ); |
| 204 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&mask2), "[0-3]") == 0 ); |
| 205 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&mask5), "[5]") == 0 ); |
| 206 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&empty_mask), "[]") == 0 ); |
| 207 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&fl_mask), fl_mask_sq) == 0 ); |
| 208 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( strcmp(mu_to_str(&full_mask), full_mask_sq) == 0 ); |
| 209 | |||
| 210 | /* mu_get_quoted_mask */ | ||
| 211 | enum { BUFFER_LEN = 16 }; | ||
| 212 | char buffer[BUFFER_LEN]; | ||
| 213 | 1 | mu_get_quoted_mask(&mask0, buffer, BUFFER_LEN); | |
| 214 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( strcmp(buffer, "\"0\"") == 0 ); |
| 215 | 1 | mu_get_quoted_mask(&mask1, buffer, BUFFER_LEN); | |
| 216 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( strcmp(buffer, "\"0,1\"") == 0 ); |
| 217 | 1 | mu_get_quoted_mask(&mask2, buffer, BUFFER_LEN); | |
| 218 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( strcmp(buffer, "\"0-3\"") == 0 ); |
| 219 | 1 | mu_get_quoted_mask(&empty_mask, buffer, BUFFER_LEN); | |
| 220 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( strcmp(buffer, "\"\"") == 0 ); |
| 221 | 1 | mu_get_quoted_mask(&fl_mask, buffer, BUFFER_LEN); | |
| 222 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( strcmp(buffer, fl_mask_quoted) == 0 ); |
| 223 | 1 | mu_get_quoted_mask(&full_mask, buffer, BUFFER_LEN); | |
| 224 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert( strcmp(buffer, full_mask_quoted) == 0 ); |
| 225 | |||
| 226 | /* None of the previous tests should initialize mask utils */ | ||
| 227 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( mu_testing_is_initialized() == false ); |
| 228 | |||
| 229 | 1 | return 0; | |
| 230 | } | ||
| 231 |