1 #include "intel_rdt.c" /* sic */
4 /***************************************************************************
7 int pqos_mon_reset(void) { return 0; }
8 int pqos_mon_assoc_get(const unsigned lcore, pqos_rmid_t *rmid) { return 0; }
9 int pqos_mon_start(const unsigned num_cores, const unsigned *cores,
10 const enum pqos_mon_event event, void *context,
11 struct pqos_mon_data *group) {
14 #if PQOS_VERSION >= 30000
15 int pqos_mon_start_pids(const unsigned num_pids, const pid_t *pids,
16 const enum pqos_mon_event event, void *context,
17 struct pqos_mon_data *group) {
20 int pqos_mon_add_pids(const unsigned num_pids, const pid_t *pids,
21 struct pqos_mon_data *group) {
24 int pqos_mon_remove_pids(const unsigned num_pids, const pid_t *pids,
25 struct pqos_mon_data *group) {
30 int pqos_mon_start_pid(const pid_t pids, const enum pqos_mon_event event,
31 void *context, struct pqos_mon_data *group) {
35 int pqos_mon_stop(struct pqos_mon_data *group) { return 0; }
36 int pqos_mon_poll(struct pqos_mon_data **groups, const unsigned num_groups) {
40 #if PQOS_VERSION >= 30000
41 int pqos_alloc_reset(const enum pqos_cdp_config l3_cdp_cfg,
42 const enum pqos_cdp_config l2_cdp_cfg,
43 const enum pqos_mba_config mba_cfg) {
46 #elif PQOS_VERSION >= 20000
47 int pqos_alloc_reset(const enum pqos_cdp_config l3_cdp_cfg,
48 const enum pqos_cdp_config l2_cdp_cfg) {
52 int pqos_alloc_reset(const enum pqos_cdp_config l3_cdp_cfg) { return 0; }
54 int pqos_alloc_assoc_set(const unsigned lcore, const unsigned class_id) {
57 int pqos_alloc_assoc_get(const unsigned lcore, unsigned *class_id) { return 0; }
58 int pqos_alloc_assoc_set_pid(const pid_t task, const unsigned class_id) {
61 int pqos_alloc_assoc_get_pid(const pid_t task, unsigned *class_id) { return 0; }
62 int pqos_alloc_assign(const unsigned technology, const unsigned *core_array,
63 const unsigned core_num, unsigned *class_id) {
66 int pqos_alloc_release(const unsigned *core_array, const unsigned core_num) {
69 int pqos_alloc_assign_pid(const unsigned technology, const pid_t *task_array,
70 const unsigned task_num, unsigned *class_id) {
73 int pqos_alloc_release_pid(const pid_t *task_array, const unsigned task_num) {
76 int pqos_init(const struct pqos_config *config) { return 0; }
77 int pqos_fini(void) { return 0; }
78 int pqos_cap_get_type(const struct pqos_cap *cap, const enum pqos_cap_type type,
79 const struct pqos_capability **cap_item) {
82 int pqos_cap_get(const struct pqos_cap **cap, const struct pqos_cpuinfo **cpu) {
87 /***************************************************************************
90 rdt_ctx_t *stub_rdt_setup() {
92 rdt_ctx_t *rdt = calloc(1, sizeof(*rdt));
93 struct pqos_cpuinfo *pqos_cpu = calloc(1, sizeof(*pqos_cpu));
94 struct pqos_cap *pqos_cap = calloc(1, sizeof(*pqos_cap));
95 struct pqos_cap_mon *mon = calloc(1, sizeof(*mon));
96 struct pqos_capability *cap_mon = calloc(1, sizeof(*cap_mon));
99 rdt->pqos_cap = pqos_cap;
100 rdt->pqos_cpu = pqos_cpu;
101 rdt->cap_mon = cap_mon;
106 void stub_rdt_teardown(rdt_ctx_t *rdt) {
107 free(rdt->cap_mon->u.mon);
108 free((void *)rdt->cap_mon);
109 free((void *)rdt->pqos_cpu);
110 free((void *)rdt->pqos_cap);
114 /***************************************************************************
117 DEF_TEST(rdt_config_ngroups__one_process) {
119 rdt_ctx_t *rdt = stub_rdt_setup();
121 oconfig_value_t values[] = {
122 {.value.string = "proc1", .type = OCONFIG_TYPE_STRING},
124 oconfig_item_t config_item = {
126 .values_num = STATIC_ARRAY_SIZE(values),
130 int result = rdt_config_ngroups(rdt, &config_item);
131 EXPECT_EQ_INT(0, result);
132 EXPECT_EQ_STR(values[0].value.string, rdt->ngroups[0].desc);
133 EXPECT_EQ_INT(1, rdt->num_ngroups);
136 rdt_free_ngroups(rdt);
137 stub_rdt_teardown(rdt);
142 DEF_TEST(rdt_config_ngroups__two_groups) {
144 rdt_ctx_t *rdt = stub_rdt_setup();
146 oconfig_value_t values[] = {
147 {.value.string = "proc11,proc12,proc13", .type = OCONFIG_TYPE_STRING},
148 {.value.string = "proc21,proc22,proc23", .type = OCONFIG_TYPE_STRING},
150 oconfig_item_t config_item = {
152 .values_num = STATIC_ARRAY_SIZE(values),
156 int result = rdt_config_ngroups(rdt, &config_item);
157 EXPECT_EQ_INT(0, result);
158 EXPECT_EQ_INT(2, rdt->num_ngroups);
159 EXPECT_EQ_STR("proc11,proc12,proc13", rdt->ngroups[0].desc);
160 EXPECT_EQ_STR("proc21,proc22,proc23", rdt->ngroups[1].desc);
161 EXPECT_EQ_STR("proc11", rdt->ngroups[0].names[0]);
162 EXPECT_EQ_STR("proc12", rdt->ngroups[0].names[1]);
163 EXPECT_EQ_STR("proc13", rdt->ngroups[0].names[2]);
164 EXPECT_EQ_STR("proc21", rdt->ngroups[1].names[0]);
165 EXPECT_EQ_STR("proc22", rdt->ngroups[1].names[1]);
166 EXPECT_EQ_STR("proc23", rdt->ngroups[1].names[2]);
169 rdt_free_ngroups(rdt);
170 stub_rdt_teardown(rdt);
175 DEF_TEST(rdt_config_ngroups__too_long_proc_name) {
177 rdt_ctx_t *rdt = stub_rdt_setup();
179 oconfig_value_t values[] = {
180 {.value.string = "_seventeen_chars_", .type = OCONFIG_TYPE_STRING},
182 oconfig_item_t config_item = {
184 .values_num = STATIC_ARRAY_SIZE(values),
188 int result = rdt_config_ngroups(rdt, &config_item);
189 EXPECT_EQ_INT(-EINVAL, result);
192 stub_rdt_teardown(rdt);
197 DEF_TEST(rdt_config_ngroups__duplicate_proc_name_between_groups) {
199 rdt_ctx_t *rdt = stub_rdt_setup();
201 oconfig_value_t values[] = {
202 {.value.string = "proc11,proc12,proc", .type = OCONFIG_TYPE_STRING},
203 {.value.string = "proc21,proc,proc23", .type = OCONFIG_TYPE_STRING},
205 oconfig_item_t config_item = {
207 .values_num = STATIC_ARRAY_SIZE(values),
211 int result = rdt_config_ngroups(rdt, &config_item);
212 EXPECT_EQ_INT(-EINVAL, result);
215 stub_rdt_teardown(rdt);
220 DEF_TEST(rdt_config_ngroups__duplicate_proc_name_in_group) {
222 rdt_ctx_t *rdt = stub_rdt_setup();
224 oconfig_value_t values[] = {
225 {.value.string = "proc11,proc,proc,proc14", .type = OCONFIG_TYPE_STRING},
227 oconfig_item_t config_item = {
229 .values_num = STATIC_ARRAY_SIZE(values),
233 int result = rdt_config_ngroups(rdt, &config_item);
234 EXPECT_EQ_INT(-EINVAL, result);
237 stub_rdt_teardown(rdt);
242 DEF_TEST(rdt_config_ngroups__empty_group) {
244 rdt_ctx_t *rdt = stub_rdt_setup();
246 oconfig_value_t values[] = {
247 {.value.string = "proc11,proc12,proc13", .type = OCONFIG_TYPE_STRING},
248 {.value.string = "", .type = OCONFIG_TYPE_STRING},
251 oconfig_item_t config_item = {
253 .values_num = STATIC_ARRAY_SIZE(values),
257 int result = rdt_config_ngroups(rdt, &config_item);
258 EXPECT_EQ_INT(-EINVAL, result);
261 stub_rdt_teardown(rdt);
266 DEF_TEST(rdt_config_ngroups__empty_proc_name) {
268 rdt_ctx_t *rdt = stub_rdt_setup();
270 oconfig_value_t values[] = {
271 {.value.string = "proc11,,proc13", .type = OCONFIG_TYPE_STRING},
273 oconfig_item_t config_item = {
275 .values_num = STATIC_ARRAY_SIZE(values),
279 int result = rdt_config_ngroups(rdt, &config_item);
280 EXPECT_EQ_INT(-EINVAL, result);
283 stub_rdt_teardown(rdt);
289 RUN_TEST(rdt_config_ngroups__one_process);
290 RUN_TEST(rdt_config_ngroups__two_groups);
291 RUN_TEST(rdt_config_ngroups__too_long_proc_name);
292 RUN_TEST(rdt_config_ngroups__duplicate_proc_name_between_groups);
293 RUN_TEST(rdt_config_ngroups__duplicate_proc_name_in_group);
294 RUN_TEST(rdt_config_ngroups__empty_group);
295 RUN_TEST(rdt_config_ngroups__empty_proc_name);
300 DEF_TEST(pqos12_test_stub) {
306 RUN_TEST(pqos12_test_stub);