Lines Matching +full:- +full:30
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
60 if (!world->key_refs[key_id_index(key_id)]) { in world_obj_get()
61 world->objagg_objs[key_id_index(key_id)] = objagg_obj; in world_obj_get()
62 } else if (world->objagg_objs[key_id_index(key_id)] != objagg_obj) { in world_obj_get()
65 err = -EINVAL; in world_obj_get()
68 world->key_refs[key_id_index(key_id)]++; in world_obj_get()
81 if (!world->key_refs[key_id_index(key_id)]) in world_obj_put()
83 objagg_obj = world->objagg_objs[key_id_index(key_id)]; in world_obj_put()
85 world->key_refs[key_id_index(key_id)]--; in world_obj_put()
94 int diff = key->id - parent_key->id; in delta_check()
104 int diff = key->id - parent_key->id; in delta_create()
108 return ERR_PTR(-EINVAL); in delta_create()
112 return ERR_PTR(-ENOMEM); in delta_create()
113 delta->key_id_diff = diff; in delta_create()
114 world->delta_count++; in delta_create()
123 world->delta_count--; in delta_destroy()
135 return ERR_PTR(-ENOMEM); in root_create()
136 memcpy(&root->key, key, sizeof(root->key)); in root_create()
137 memcpy(root->buf, world->next_root_buf, sizeof(root->buf)); in root_create()
138 world->root_count++; in root_create()
147 world->root_count--; in root_destroy()
154 unsigned int orig_root_count = world->root_count; in test_nodelta_obj_get()
160 get_random_bytes(world->next_root_buf, in test_nodelta_obj_get()
161 sizeof(world->next_root_buf)); in test_nodelta_obj_get()
169 if (world->root_count != orig_root_count + 1) { in test_nodelta_obj_get()
171 err = -EINVAL; in test_nodelta_obj_get()
175 if (world->root_count != orig_root_count) { in test_nodelta_obj_get()
178 err = -EINVAL; in test_nodelta_obj_get()
183 if (root->key.id != key_id) { in test_nodelta_obj_get()
185 err = -EINVAL; in test_nodelta_obj_get()
189 memcmp(world->next_root_buf, root->buf, sizeof(root->buf))) { in test_nodelta_obj_get()
192 err = -EINVAL; in test_nodelta_obj_get()
207 unsigned int orig_root_count = world->root_count; in test_nodelta_obj_put()
212 if (world->root_count != orig_root_count - 1) { in test_nodelta_obj_put()
214 return -EINVAL; in test_nodelta_obj_put()
217 if (world->root_count != orig_root_count) { in test_nodelta_obj_put()
220 return -EINVAL; in test_nodelta_obj_put()
235 if (stats->stats_info_count != 0) { in check_stats_zero()
237 err = -EINVAL; in check_stats_zero()
254 if (stats->stats_info_count != NUM_KEYS) { in check_stats_nodelta()
256 NUM_KEYS, stats->stats_info_count); in check_stats_nodelta()
257 err = -EINVAL; in check_stats_nodelta()
261 for (i = 0; i < stats->stats_info_count; i++) { in check_stats_nodelta()
262 if (stats->stats_info[i].stats.user_count != 2) { in check_stats_nodelta()
264 err = -EINVAL; in check_stats_nodelta()
267 if (stats->stats_info[i].stats.delta_user_count != 2) { in check_stats_nodelta()
269 err = -EINVAL; in check_stats_nodelta()
288 return ERR_PTR(-EOPNOTSUPP); in delta_create_dummy()
339 for (i = NUM_KEYS - 1; i >= 0; i--) { in test_nodelta()
344 for (i = NUM_KEYS - 1; i >= 0; i--) { in test_nodelta()
360 for (i--; i >= 0; i--) in test_nodelta()
366 for (i--; i >= 0; i--) in test_nodelta()
461 30, ACTION_GET, EXPECT_DELTA_SAME, EXPECT_ROOT_INC,
462 EXPECT_STATS(5, ROOT(1, 2, 5), ROOT(7, 1, 1), ROOT(30, 1, 1),
464 }, /* r: 1, 1, 7, 30 d: 3^1, 3^1, 5^1 */
467 EXPECT_STATS(6, ROOT(1, 2, 5), ROOT(7, 1, 2), ROOT(30, 1, 1),
469 }, /* r: 1, 1, 7, 30 d: 3^1, 3^1, 5^1, 8^7 */
472 EXPECT_STATS(6, ROOT(1, 2, 5), ROOT(7, 1, 3), ROOT(30, 1, 1),
474 }, /* r: 1, 1, 7, 30 d: 3^1, 3^1, 5^1, 8^7, 8^7 */
477 EXPECT_STATS(6, ROOT(1, 2, 4), ROOT(7, 1, 3), ROOT(30, 1, 1),
479 }, /* r: 1, 1, 7, 30 d: 3^1, 5^1, 8^7, 8^7 */
482 EXPECT_STATS(5, ROOT(1, 2, 3), ROOT(7, 1, 3), ROOT(30, 1, 1),
484 }, /* r: 1, 1, 7, 30 d: 5^1, 8^7, 8^7 */
487 EXPECT_STATS(5, ROOT(7, 1, 3), ROOT(1, 1, 2), ROOT(30, 1, 1),
489 }, /* r: 1, 7, 30 d: 5^1, 8^7, 8^7 */
492 EXPECT_STATS(5, ROOT(7, 1, 3), ROOT(30, 1, 1), ROOT(1, 0, 1),
494 }, /* r: 7, 30 d: 5^1, 8^7, 8^7 */
497 EXPECT_STATS(3, ROOT(7, 1, 3), ROOT(30, 1, 1),
499 }, /* r: 7, 30 d: 8^7, 8^7 */
502 EXPECT_STATS(4, ROOT(7, 1, 3), ROOT(30, 1, 1), ROOT(5, 1, 1),
504 }, /* r: 7, 30, 5 d: 8^7, 8^7 */
507 EXPECT_STATS(5, ROOT(7, 1, 3), ROOT(5, 1, 2), ROOT(30, 1, 1),
509 }, /* r: 7, 30, 5 d: 8^7, 8^7, 6^5 */
512 EXPECT_STATS(5, ROOT(7, 1, 4), ROOT(5, 1, 2), ROOT(30, 1, 1),
514 }, /* r: 7, 30, 5 d: 8^7, 8^7, 8^7, 6^5 */
517 EXPECT_STATS(5, ROOT(7, 1, 3), ROOT(5, 1, 2), ROOT(30, 1, 1),
519 }, /* r: 7, 30, 5 d: 8^7, 8^7, 6^5 */
522 EXPECT_STATS(5, ROOT(7, 1, 2), ROOT(5, 1, 2), ROOT(30, 1, 1),
524 }, /* r: 7, 30, 5 d: 8^7, 6^5 */
527 EXPECT_STATS(4, ROOT(5, 1, 2), ROOT(7, 1, 1), ROOT(30, 1, 1),
529 }, /* r: 7, 30, 5 d: 6^5 */
532 EXPECT_STATS(5, ROOT(5, 1, 3), ROOT(7, 1, 1), ROOT(30, 1, 1),
534 }, /* r: 7, 30, 5 d: 6^5, 8^5 */
537 EXPECT_STATS(4, ROOT(5, 1, 3), ROOT(30, 1, 1),
539 }, /* r: 30, 5 d: 6^5, 8^5 */
541 30, ACTION_PUT, EXPECT_DELTA_SAME, EXPECT_ROOT_DEC,
566 unsigned int key_id = action_item->key_id; in check_expect()
568 switch (action_item->expect_delta) { in check_expect()
570 if (orig_delta_count != world->delta_count) { in check_expect()
573 return -EINVAL; in check_expect()
577 if (WARN_ON(action_item->action == ACTION_PUT)) in check_expect()
578 return -EINVAL; in check_expect()
579 if (orig_delta_count + 1 != world->delta_count) { in check_expect()
582 return -EINVAL; in check_expect()
586 if (WARN_ON(action_item->action == ACTION_GET)) in check_expect()
587 return -EINVAL; in check_expect()
588 if (orig_delta_count - 1 != world->delta_count) { in check_expect()
591 return -EINVAL; in check_expect()
596 switch (action_item->expect_root) { in check_expect()
598 if (orig_root_count != world->root_count) { in check_expect()
601 return -EINVAL; in check_expect()
605 if (WARN_ON(action_item->action == ACTION_PUT)) in check_expect()
606 return -EINVAL; in check_expect()
607 if (orig_root_count + 1 != world->root_count) { in check_expect()
610 return -EINVAL; in check_expect()
614 if (WARN_ON(action_item->action == ACTION_GET)) in check_expect()
615 return -EINVAL; in check_expect()
616 if (orig_root_count - 1 != world->root_count) { in check_expect()
619 return -EINVAL; in check_expect()
633 key_id = root_key->id; in obj_to_key_id()
636 key_id += delta->key_id_diff; in obj_to_key_id()
645 if (stats_info->is_root != expect_stats_info->is_root) { in check_expect_stats_nums()
648 return -EINVAL; in check_expect_stats_nums()
650 if (stats_info->stats.user_count != in check_expect_stats_nums()
651 expect_stats_info->stats.user_count) { in check_expect_stats_nums()
654 return -EINVAL; in check_expect_stats_nums()
656 if (stats_info->stats.delta_user_count != in check_expect_stats_nums()
657 expect_stats_info->stats.delta_user_count) { in check_expect_stats_nums()
660 return -EINVAL; in check_expect_stats_nums()
670 if (obj_to_key_id(stats_info->objagg_obj) != in check_expect_stats_key_id()
671 expect_stats_info->key_id) { in check_expect_stats_key_id()
674 return -EINVAL; in check_expect_stats_key_id()
686 for (i = pos - 1; i >= 0; i--) { in check_expect_stats_neigh()
687 err = check_expect_stats_nums(&stats->stats_info[i], in check_expect_stats_neigh()
688 &expect_stats->info[pos], NULL); in check_expect_stats_neigh()
691 err = check_expect_stats_key_id(&stats->stats_info[i], in check_expect_stats_neigh()
692 &expect_stats->info[pos], NULL); in check_expect_stats_neigh()
696 for (i = pos + 1; i < stats->stats_info_count; i++) { in check_expect_stats_neigh()
697 err = check_expect_stats_nums(&stats->stats_info[i], in check_expect_stats_neigh()
698 &expect_stats->info[pos], NULL); in check_expect_stats_neigh()
701 err = check_expect_stats_key_id(&stats->stats_info[i], in check_expect_stats_neigh()
702 &expect_stats->info[pos], NULL); in check_expect_stats_neigh()
706 return -EINVAL; in check_expect_stats_neigh()
716 if (stats->stats_info_count != expect_stats->info_count) { in __check_expect_stats()
718 return -EINVAL; in __check_expect_stats()
721 for (i = 0; i < stats->stats_info_count; i++) { in __check_expect_stats()
722 err = check_expect_stats_nums(&stats->stats_info[i], in __check_expect_stats()
723 &expect_stats->info[i], errmsg); in __check_expect_stats()
726 err = check_expect_stats_key_id(&stats->stats_info[i], in __check_expect_stats()
727 &expect_stats->info[i], errmsg); in __check_expect_stats()
762 unsigned int orig_delta_count = world->delta_count; in test_delta_action_item()
763 unsigned int orig_root_count = world->root_count; in test_delta_action_item()
764 unsigned int key_id = action_item->key_id; in test_delta_action_item()
765 enum action action = action_item->action; in test_delta_action_item()
791 err = check_expect_stats(objagg, &action_item->expect_stats, &errmsg); in test_delta_action_item()
793 pr_err("Key %u: Stats: %s\n", action_item->key_id, errmsg); in test_delta_action_item()
829 for (i--; i >= 0; i--) in test_delta()
844 1, 7, 3, 5, 3, 1, 30, 8, 8, 5, 6, 8,
851 EXPECT_STATS(7, ROOT(1, 2, 7), ROOT(7, 1, 4), ROOT(30, 1, 1),
855 EXPECT_STATS(7, ROOT(3, 2, 9), ROOT(1, 2, 2), ROOT(30, 1, 1),
864 for (i = 0; i < stats->stats_info_count; i++) in __pr_debug_stats()
866 obj_to_key_id(stats->stats_info[i].objagg_obj), in __pr_debug_stats()
867 stats->stats_info[i].stats.user_count, in __pr_debug_stats()
868 stats->stats_info[i].stats.delta_user_count, in __pr_debug_stats()
869 stats->stats_info[i].is_root ? "root" : "noroot"); in __pr_debug_stats()
925 for (i = 0; i < hints_case->key_ids_count; i++) { in test_hints_case()
927 hints_case->key_ids[i]); in test_hints_case()
935 err = check_expect_stats(objagg, &hints_case->expect_stats, &errmsg); in test_hints_case()
948 err = check_expect_hints_stats(hints, &hints_case->expect_stats_hints, in test_hints_case()
959 for (i = 0; i < hints_case->key_ids_count; i++) { in test_hints_case()
961 hints_case->key_ids[i]); in test_hints_case()
969 err = check_expect_stats(objagg2, &hints_case->expect_stats_hints, in test_hints_case()
980 for (i--; i >= 0; i--) in test_hints_case()
981 world_obj_put(&world2, objagg, hints_case->key_ids[i]); in test_hints_case()
982 i = hints_case->key_ids_count; in test_hints_case()
989 for (i--; i >= 0; i--) in test_hints_case()
990 world_obj_put(&world, objagg, hints_case->key_ids[i]); in test_hints_case()