diff options
author | Mahircan Gul <mahircg@mpi-sws.org> | 2016-07-18 10:05:20 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-07-18 10:46:23 -0400 |
commit | cf1d1f6e4b1138a5a841a47a2cba4aacdcaf0d72 (patch) | |
tree | 0f78c6a6a131700800c2f9dc7bf4768a775857e9 /tests | |
parent | 11a2acc387b274d2323104272e585a7059b96f4f (diff) |
Add unit-test for CPU mapping parsing
- Decompose read_mapping into two functions: *read_mapping* which reads
CPU mapping data as string from file, and *set_mapping* that actually sets
the cpu_set_t according to the mapping
- Add unit test for setting cpu_set_t to various CPU indexes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_api.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/core_api.c b/tests/core_api.c index feb60c5..065c1fc 100644 --- a/tests/core_api.c +++ b/tests/core_api.c | |||
@@ -193,6 +193,44 @@ TESTCASE(ctrl_page_writable, ALL, | |||
193 | ctrl_page[32] = 0x12345678; | 193 | ctrl_page[32] = 0x12345678; |
194 | } | 194 | } |
195 | 195 | ||
196 | TESTCASE(set_cpu_mapping, LITMUS, | ||
197 | "task's CPU affinity is set to CPU set that is read from file") | ||
198 | { | ||
199 | char buf[4096/4 /* enough chars for hex data (4 CPUs per char) */ | ||
200 | + 4096/(4*8) /* for commas (separate groups of 8 chars) */ | ||
201 | + 1] = {0}; /* for \0 */ | ||
202 | int len; | ||
203 | cpu_set_t *set; | ||
204 | size_t sz; | ||
205 | |||
206 | /*set affinity to CPU 0 */ | ||
207 | strcpy(buf, "20"); | ||
208 | len = strnlen(buf, sizeof(buf)); | ||
209 | set_mapping(buf, len, &set, &sz); | ||
210 | ASSERT( CPU_ISSET_S(5, sz, set) ); | ||
211 | |||
212 | /*set affinity to CPU 29 */ | ||
213 | strcpy(buf, "20000000"); | ||
214 | len = strnlen(buf, sizeof(buf)); | ||
215 | set_mapping(buf, len, &set, &sz); | ||
216 | ASSERT( CPU_ISSET_S(29, sz, set) ); | ||
217 | |||
218 | /*set affinity to CPUS 27 and 39 */ | ||
219 | strcpy(buf, "80,08000000"); | ||
220 | len = strnlen(buf, sizeof(buf)); | ||
221 | set_mapping(buf, len, &set, &sz); | ||
222 | ASSERT( CPU_ISSET_S(27, sz, set) ); | ||
223 | ASSERT( CPU_ISSET_S(39, sz, set) ); | ||
224 | |||
225 | /*set affinity to CPUS 96 */ | ||
226 | strcpy(buf, "1,00000000,00000000,00000000"); | ||
227 | len = strnlen(buf, sizeof(buf)); | ||
228 | set_mapping(buf, len, &set, &sz); | ||
229 | ASSERT( CPU_ISSET_S(96, sz, set) ); | ||
230 | |||
231 | } | ||
232 | |||
233 | |||
196 | 234 | ||
197 | TESTCASE(suspended_admission, LITMUS, | 235 | TESTCASE(suspended_admission, LITMUS, |
198 | "admission control handles suspended tasks correctly") | 236 | "admission control handles suspended tasks correctly") |