2 * Copyright (c) 2016-2019, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of Intel Corporation nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include "pt_image_section_cache.h"
31 #include "ptunit_threads.h"
39 /* The filename. We only support string literals for testing. */
42 /* The file offset and size. */
46 /* The bcache size. */
49 /* The iscache back link. */
50 struct pt_image_section_cache *iscache;
52 /* The file content. */
53 uint8_t content[0x10];
58 /* The attach count. */
64 #if defined(FEATURE_THREADS)
65 /* A lock protecting this section. */
67 /* A lock protecting the iscache and acount fields. */
69 #endif /* defined(FEATURE_THREADS) */
72 extern int pt_mk_section(struct pt_section **psection, const char *filename,
73 uint64_t offset, uint64_t size);
75 extern int pt_section_get(struct pt_section *section);
76 extern int pt_section_put(struct pt_section *section);
77 extern int pt_section_attach(struct pt_section *section,
78 struct pt_image_section_cache *iscache);
79 extern int pt_section_detach(struct pt_section *section,
80 struct pt_image_section_cache *iscache);
82 extern int pt_section_map(struct pt_section *section);
83 extern int pt_section_map_share(struct pt_section *section);
84 extern int pt_section_unmap(struct pt_section *section);
85 extern int pt_section_request_bcache(struct pt_section *section);
87 extern const char *pt_section_filename(const struct pt_section *section);
88 extern uint64_t pt_section_offset(const struct pt_section *section);
89 extern uint64_t pt_section_size(const struct pt_section *section);
90 extern int pt_section_memsize(struct pt_section *section, uint64_t *size);
92 extern int pt_section_read(const struct pt_section *section, uint8_t *buffer,
93 uint16_t size, uint64_t offset);
96 int pt_mk_section(struct pt_section **psection, const char *filename,
97 uint64_t offset, uint64_t size)
99 struct pt_section *section;
102 section = malloc(sizeof(*section));
106 memset(section, 0, sizeof(*section));
107 section->filename = filename;
108 section->offset = offset;
109 section->size = size;
112 for (idx = 0; idx < sizeof(section->content); ++idx)
113 section->content[idx] = idx;
115 #if defined(FEATURE_THREADS)
119 errcode = mtx_init(§ion->lock, mtx_plain);
120 if (errcode != thrd_success) {
122 return -pte_bad_lock;
125 errcode = mtx_init(§ion->alock, mtx_plain);
126 if (errcode != thrd_success) {
127 mtx_destroy(§ion->lock);
129 return -pte_bad_lock;
132 #endif /* defined(FEATURE_THREADS) */
139 static int pt_section_lock(struct pt_section *section)
142 return -pte_internal;
144 #if defined(FEATURE_THREADS)
148 errcode = mtx_lock(§ion->lock);
149 if (errcode != thrd_success)
150 return -pte_bad_lock;
152 #endif /* defined(FEATURE_THREADS) */
157 static int pt_section_unlock(struct pt_section *section)
160 return -pte_internal;
162 #if defined(FEATURE_THREADS)
166 errcode = mtx_unlock(§ion->lock);
167 if (errcode != thrd_success)
168 return -pte_bad_lock;
170 #endif /* defined(FEATURE_THREADS) */
175 static int pt_section_lock_attach(struct pt_section *section)
178 return -pte_internal;
180 #if defined(FEATURE_THREADS)
184 errcode = mtx_lock(§ion->alock);
185 if (errcode != thrd_success)
186 return -pte_bad_lock;
188 #endif /* defined(FEATURE_THREADS) */
193 static int pt_section_unlock_attach(struct pt_section *section)
196 return -pte_internal;
198 #if defined(FEATURE_THREADS)
202 errcode = mtx_unlock(§ion->alock);
203 if (errcode != thrd_success)
204 return -pte_bad_lock;
206 #endif /* defined(FEATURE_THREADS) */
211 int pt_section_get(struct pt_section *section)
216 return -pte_internal;
218 errcode = pt_section_lock(section);
222 ucount = ++section->ucount;
224 errcode = pt_section_unlock(section);
229 return -pte_internal;
234 int pt_section_put(struct pt_section *section)
239 return -pte_internal;
241 errcode = pt_section_lock(section);
245 ucount = --section->ucount;
247 errcode = pt_section_unlock(section);
252 #if defined(FEATURE_THREADS)
253 mtx_destroy(§ion->alock);
254 mtx_destroy(§ion->lock);
255 #endif /* defined(FEATURE_THREADS) */
262 int pt_section_attach(struct pt_section *section,
263 struct pt_image_section_cache *iscache)
265 int errcode, ucount, acount;
267 if (!section || !iscache)
268 return -pte_internal;
270 errcode = pt_section_lock_attach(section);
274 ucount = section->ucount;
275 acount = section->acount;
277 if (section->iscache || !ucount)
280 section->iscache = iscache;
283 return pt_section_unlock_attach(section);
288 (void) pt_section_unlock_attach(section);
289 return -pte_overflow;
295 if (section->iscache != iscache)
298 section->acount = acount;
300 return pt_section_unlock_attach(section);
303 (void) pt_section_unlock_attach(section);
304 return -pte_internal;
307 int pt_section_detach(struct pt_section *section,
308 struct pt_image_section_cache *iscache)
310 int errcode, ucount, acount;
312 if (!section || !iscache)
313 return -pte_internal;
315 errcode = pt_section_lock_attach(section);
319 if (section->iscache != iscache)
322 acount = section->acount;
327 ucount = section->ucount;
331 section->acount = acount;
333 section->iscache = NULL;
335 return pt_section_unlock_attach(section);
338 (void) pt_section_unlock_attach(section);
339 return -pte_internal;
342 int pt_section_map(struct pt_section *section)
344 struct pt_image_section_cache *iscache;
348 return -pte_internal;
350 errcode = pt_section_map_share(section);
354 errcode = pt_section_lock_attach(section);
359 iscache = section->iscache;
361 status = pt_iscache_notify_map(iscache, section);
363 errcode = pt_section_unlock_attach(section);
365 return (status < 0) ? status : errcode;
368 int pt_section_map_share(struct pt_section *section)
373 return -pte_internal;
375 errcode = pt_section_lock(section);
379 mcount = ++section->mcount;
381 errcode = pt_section_unlock(section);
386 return -pte_internal;
391 int pt_section_unmap(struct pt_section *section)
396 return -pte_internal;
398 errcode = pt_section_lock(section);
402 section->bcsize = 0ull;
403 mcount = --section->mcount;
405 errcode = pt_section_unlock(section);
410 return -pte_internal;
415 int pt_section_request_bcache(struct pt_section *section)
417 struct pt_image_section_cache *iscache;
422 return -pte_internal;
424 errcode = pt_section_lock_attach(section);
428 errcode = pt_section_lock(section);
435 section->bcsize = section->size * 3;
436 memsize = section->size + section->bcsize;
438 errcode = pt_section_unlock(section);
442 iscache = section->iscache;
444 errcode = pt_iscache_notify_resize(iscache, section, memsize);
449 return pt_section_unlock_attach(section);
453 (void) pt_section_unlock(section);
456 (void) pt_section_unlock_attach(section);
460 const char *pt_section_filename(const struct pt_section *section)
465 return section->filename;
468 uint64_t pt_section_offset(const struct pt_section *section)
473 return section->offset;
476 uint64_t pt_section_size(const struct pt_section *section)
481 return section->size;
484 int pt_section_memsize(struct pt_section *section, uint64_t *size)
486 if (!section || !size)
487 return -pte_internal;
489 *size = section->mcount ? section->size + section->bcsize : 0ull;
494 int pt_section_read(const struct pt_section *section, uint8_t *buffer,
495 uint16_t size, uint64_t offset)
497 uint64_t begin, end, max;
499 if (!section || !buffer)
500 return -pte_internal;
504 max = sizeof(section->content);
515 memcpy(buffer, §ion->content[begin], (size_t) (end - begin));
516 return (int) (end - begin);
520 /* The number of test sections. */
523 #if defined(FEATURE_THREADS)
527 #endif /* defined(FEATURE_THREADS) */
529 num_iterations = 0x1000
532 struct iscache_fixture {
533 /* Threading support. */
534 struct ptunit_thrd_fixture thrd;
536 /* The image section cache under test. */
537 struct pt_image_section_cache iscache;
539 /* A bunch of test sections. */
540 struct pt_section *section[num_sections];
542 /* The test fixture initialization and finalization functions. */
543 struct ptunit_result (*init)(struct iscache_fixture *);
544 struct ptunit_result (*fini)(struct iscache_fixture *);
547 static struct ptunit_result dfix_init(struct iscache_fixture *cfix)
551 ptu_test(ptunit_thrd_init, &cfix->thrd);
553 memset(cfix->section, 0, sizeof(cfix->section));
555 for (idx = 0; idx < num_sections; ++idx) {
556 struct pt_section *section;
559 errcode = pt_mk_section(§ion, "some-filename",
560 idx % 3 == 0 ? 0x1000 : 0x2000,
561 idx % 2 == 0 ? 0x1000 : 0x2000);
562 ptu_int_eq(errcode, 0);
565 cfix->section[idx] = section;
571 static struct ptunit_result cfix_init(struct iscache_fixture *cfix)
575 ptu_test(dfix_init, cfix);
577 errcode = pt_iscache_init(&cfix->iscache, NULL);
578 ptu_int_eq(errcode, 0);
583 static struct ptunit_result sfix_init(struct iscache_fixture *cfix)
587 ptu_test(cfix_init, cfix);
589 cfix->iscache.limit = 0x7800;
591 for (idx = 0; idx < num_sections; ++idx) {
592 status = pt_iscache_add(&cfix->iscache, cfix->section[idx],
594 ptu_int_ge(status, 0);
600 static struct ptunit_result cfix_fini(struct iscache_fixture *cfix)
604 ptu_test(ptunit_thrd_fini, &cfix->thrd);
606 for (idx = 0; idx < cfix->thrd.nthreads; ++idx)
607 ptu_int_eq(cfix->thrd.result[idx], 0);
609 pt_iscache_fini(&cfix->iscache);
611 for (idx = 0; idx < num_sections; ++idx) {
612 ptu_int_eq(cfix->section[idx]->ucount, 1);
613 ptu_int_eq(cfix->section[idx]->acount, 0);
614 ptu_int_eq(cfix->section[idx]->mcount, 0);
615 ptu_null(cfix->section[idx]->iscache);
617 errcode = pt_section_put(cfix->section[idx]);
618 ptu_int_eq(errcode, 0);
625 static struct ptunit_result init_null(void)
629 errcode = pt_iscache_init(NULL, NULL);
630 ptu_int_eq(errcode, -pte_internal);
635 static struct ptunit_result fini_null(void)
637 pt_iscache_fini(NULL);
642 static struct ptunit_result name_null(void)
646 name = pt_iscache_name(NULL);
652 static struct ptunit_result add_null(void)
654 struct pt_image_section_cache iscache;
655 struct pt_section section;
658 errcode = pt_iscache_add(NULL, §ion, 0ull);
659 ptu_int_eq(errcode, -pte_internal);
661 errcode = pt_iscache_add(&iscache, NULL, 0ull);
662 ptu_int_eq(errcode, -pte_internal);
667 static struct ptunit_result find_null(void)
671 errcode = pt_iscache_find(NULL, "filename", 0ull, 0ull, 0ull);
672 ptu_int_eq(errcode, -pte_internal);
677 static struct ptunit_result lookup_null(void)
679 struct pt_image_section_cache iscache;
680 struct pt_section *section;
684 errcode = pt_iscache_lookup(NULL, §ion, &laddr, 0);
685 ptu_int_eq(errcode, -pte_internal);
687 errcode = pt_iscache_lookup(&iscache, NULL, &laddr, 0);
688 ptu_int_eq(errcode, -pte_internal);
690 errcode = pt_iscache_lookup(&iscache, §ion, NULL, 0);
691 ptu_int_eq(errcode, -pte_internal);
696 static struct ptunit_result clear_null(void)
700 errcode = pt_iscache_clear(NULL);
701 ptu_int_eq(errcode, -pte_internal);
706 static struct ptunit_result free_null(void)
708 pt_iscache_free(NULL);
713 static struct ptunit_result add_file_null(void)
715 struct pt_image_section_cache iscache;
718 errcode = pt_iscache_add_file(NULL, "filename", 0ull, 0ull, 0ull);
719 ptu_int_eq(errcode, -pte_invalid);
721 errcode = pt_iscache_add_file(&iscache, NULL, 0ull, 0ull, 0ull);
722 ptu_int_eq(errcode, -pte_invalid);
727 static struct ptunit_result read_null(void)
729 struct pt_image_section_cache iscache;
733 errcode = pt_iscache_read(NULL, &buffer, sizeof(buffer), 1ull, 0ull);
734 ptu_int_eq(errcode, -pte_invalid);
736 errcode = pt_iscache_read(&iscache, NULL, sizeof(buffer), 1ull, 0ull);
737 ptu_int_eq(errcode, -pte_invalid);
739 errcode = pt_iscache_read(&iscache, &buffer, 0ull, 1, 0ull);
740 ptu_int_eq(errcode, -pte_invalid);
745 static struct ptunit_result init_fini(struct iscache_fixture *cfix)
749 /* The actual init and fini calls are in cfix_init() and cfix_fini(). */
753 static struct ptunit_result name(struct iscache_fixture *cfix)
757 pt_iscache_init(&cfix->iscache, "iscache-name");
759 name = pt_iscache_name(&cfix->iscache);
760 ptu_str_eq(name, "iscache-name");
765 static struct ptunit_result name_none(struct iscache_fixture *cfix)
769 pt_iscache_init(&cfix->iscache, NULL);
771 name = pt_iscache_name(&cfix->iscache);
777 static struct ptunit_result add(struct iscache_fixture *cfix)
781 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
784 /* The cache attaches and gets a reference on success. */
785 ptu_int_eq(cfix->section[0]->ucount, 2);
786 ptu_int_eq(cfix->section[0]->acount, 1);
788 /* The added section must be implicitly put in pt_iscache_fini. */
792 static struct ptunit_result add_no_name(struct iscache_fixture *cfix)
794 struct pt_section section;
797 memset(§ion, 0, sizeof(section));
799 errcode = pt_iscache_add(&cfix->iscache, §ion, 0ull);
800 ptu_int_eq(errcode, -pte_internal);
805 static struct ptunit_result add_file(struct iscache_fixture *cfix)
809 isid = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
815 static struct ptunit_result find(struct iscache_fixture *cfix)
817 struct pt_section *section;
820 section = cfix->section[0];
823 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
826 found = pt_iscache_find(&cfix->iscache, section->filename,
827 section->offset, section->size, 0ull);
828 ptu_int_eq(found, isid);
833 static struct ptunit_result find_empty(struct iscache_fixture *cfix)
835 struct pt_section *section;
838 section = cfix->section[0];
841 found = pt_iscache_find(&cfix->iscache, section->filename,
842 section->offset, section->size, 0ull);
843 ptu_int_eq(found, 0);
848 static struct ptunit_result find_bad_filename(struct iscache_fixture *cfix)
850 struct pt_section *section;
853 section = cfix->section[0];
856 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
859 found = pt_iscache_find(&cfix->iscache, "bad-filename",
860 section->offset, section->size, 0ull);
861 ptu_int_eq(found, 0);
866 static struct ptunit_result find_null_filename(struct iscache_fixture *cfix)
870 errcode = pt_iscache_find(&cfix->iscache, NULL, 0ull, 0ull, 0ull);
871 ptu_int_eq(errcode, -pte_internal);
876 static struct ptunit_result find_bad_offset(struct iscache_fixture *cfix)
878 struct pt_section *section;
881 section = cfix->section[0];
884 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
887 found = pt_iscache_find(&cfix->iscache, section->filename, 0ull,
888 section->size, 0ull);
889 ptu_int_eq(found, 0);
894 static struct ptunit_result find_bad_size(struct iscache_fixture *cfix)
896 struct pt_section *section;
899 section = cfix->section[0];
902 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
905 found = pt_iscache_find(&cfix->iscache, section->filename,
906 section->offset, 0ull, 0ull);
907 ptu_int_eq(found, 0);
912 static struct ptunit_result find_bad_laddr(struct iscache_fixture *cfix)
914 struct pt_section *section;
917 section = cfix->section[0];
920 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
923 found = pt_iscache_find(&cfix->iscache, section->filename,
924 section->offset, section->size, 1ull);
925 ptu_int_eq(found, 0);
930 static struct ptunit_result lookup(struct iscache_fixture *cfix)
932 struct pt_section *section;
936 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
939 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, isid);
940 ptu_int_eq(errcode, 0);
941 ptu_ptr_eq(section, cfix->section[0]);
942 ptu_uint_eq(laddr, 0ull);
944 errcode = pt_section_put(section);
945 ptu_int_eq(errcode, 0);
950 static struct ptunit_result lookup_bad_isid(struct iscache_fixture *cfix)
952 struct pt_section *section;
956 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
959 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, 0);
960 ptu_int_eq(errcode, -pte_bad_image);
962 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, -isid);
963 ptu_int_eq(errcode, -pte_bad_image);
965 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, isid + 1);
966 ptu_int_eq(errcode, -pte_bad_image);
971 static struct ptunit_result clear_empty(struct iscache_fixture *cfix)
975 errcode = pt_iscache_clear(&cfix->iscache);
976 ptu_int_eq(errcode, 0);
981 static struct ptunit_result clear_find(struct iscache_fixture *cfix)
983 struct pt_section *section;
984 int errcode, found, isid;
986 section = cfix->section[0];
989 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
992 errcode = pt_iscache_clear(&cfix->iscache);
993 ptu_int_eq(errcode, 0);
996 found = pt_iscache_find(&cfix->iscache, section->filename,
997 section->offset, section->size, 0ull);
998 ptu_int_eq(found, 0);
1000 return ptu_passed();
1003 static struct ptunit_result clear_lookup(struct iscache_fixture *cfix)
1005 struct pt_section *section;
1009 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1010 ptu_int_gt(isid, 0);
1012 errcode = pt_iscache_clear(&cfix->iscache);
1013 ptu_int_eq(errcode, 0);
1015 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, isid);
1016 ptu_int_eq(errcode, -pte_bad_image);
1018 return ptu_passed();
1021 static struct ptunit_result add_twice(struct iscache_fixture *cfix)
1025 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1026 ptu_int_gt(isid[0], 0);
1028 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1029 ptu_int_gt(isid[1], 0);
1031 /* The second add should be ignored. */
1032 ptu_int_eq(isid[1], isid[0]);
1034 return ptu_passed();
1037 static struct ptunit_result add_same(struct iscache_fixture *cfix)
1041 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1042 ptu_int_gt(isid[0], 0);
1044 cfix->section[1]->offset = cfix->section[0]->offset;
1045 cfix->section[1]->size = cfix->section[0]->size;
1047 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[1], 0ull);
1048 ptu_int_gt(isid[1], 0);
1050 /* The second add should be ignored. */
1051 ptu_int_eq(isid[1], isid[0]);
1053 return ptu_passed();
1056 static struct ptunit_result
1057 add_twice_different_laddr(struct iscache_fixture *cfix)
1061 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1062 ptu_int_gt(isid[0], 0);
1064 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[0], 1ull);
1065 ptu_int_gt(isid[1], 0);
1067 /* We must get different identifiers. */
1068 ptu_int_ne(isid[1], isid[0]);
1070 /* We attach twice and take two references - one for each entry. */
1071 ptu_int_eq(cfix->section[0]->ucount, 3);
1072 ptu_int_eq(cfix->section[0]->acount, 2);
1074 return ptu_passed();
1077 static struct ptunit_result
1078 add_same_different_laddr(struct iscache_fixture *cfix)
1082 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1083 ptu_int_gt(isid[0], 0);
1085 cfix->section[1]->offset = cfix->section[0]->offset;
1086 cfix->section[1]->size = cfix->section[0]->size;
1088 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[1], 1ull);
1089 ptu_int_gt(isid[1], 0);
1091 /* We must get different identifiers. */
1092 ptu_int_ne(isid[1], isid[0]);
1094 return ptu_passed();
1097 static struct ptunit_result
1098 add_different_same_laddr(struct iscache_fixture *cfix)
1102 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1103 ptu_int_gt(isid[0], 0);
1105 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[1], 0ull);
1106 ptu_int_gt(isid[1], 0);
1108 /* We must get different identifiers. */
1109 ptu_int_ne(isid[1], isid[0]);
1111 return ptu_passed();
1114 static struct ptunit_result add_file_same(struct iscache_fixture *cfix)
1118 isid[0] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1119 ptu_int_gt(isid[0], 0);
1121 isid[1] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1122 ptu_int_gt(isid[1], 0);
1124 /* The second add should be ignored. */
1125 ptu_int_eq(isid[1], isid[0]);
1127 return ptu_passed();
1130 static struct ptunit_result
1131 add_file_same_different_laddr(struct iscache_fixture *cfix)
1135 isid[0] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1136 ptu_int_gt(isid[0], 0);
1138 isid[1] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 1ull);
1139 ptu_int_gt(isid[1], 0);
1141 /* We must get different identifiers. */
1142 ptu_int_ne(isid[1], isid[0]);
1144 return ptu_passed();
1147 static struct ptunit_result
1148 add_file_different_same_laddr(struct iscache_fixture *cfix)
1152 isid[0] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1153 ptu_int_gt(isid[0], 0);
1155 isid[1] = pt_iscache_add_file(&cfix->iscache, "name", 1ull, 1ull, 0ull);
1156 ptu_int_gt(isid[1], 0);
1158 /* We must get different identifiers. */
1159 ptu_int_ne(isid[1], isid[0]);
1161 return ptu_passed();
1164 static struct ptunit_result read(struct iscache_fixture *cfix)
1166 uint8_t buffer[] = { 0xcc, 0xcc, 0xcc };
1169 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1170 ptu_int_gt(isid, 0);
1172 status = pt_iscache_read(&cfix->iscache, buffer, 2ull, isid, 0xa008ull);
1173 ptu_int_eq(status, 2);
1174 ptu_uint_eq(buffer[0], 0x8);
1175 ptu_uint_eq(buffer[1], 0x9);
1176 ptu_uint_eq(buffer[2], 0xcc);
1178 return ptu_passed();
1181 static struct ptunit_result read_truncate(struct iscache_fixture *cfix)
1183 uint8_t buffer[] = { 0xcc, 0xcc };
1186 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1187 ptu_int_gt(isid, 0);
1189 status = pt_iscache_read(&cfix->iscache, buffer, sizeof(buffer), isid,
1191 ptu_int_eq(status, 1);
1192 ptu_uint_eq(buffer[0], 0xf);
1193 ptu_uint_eq(buffer[1], 0xcc);
1195 return ptu_passed();
1198 static struct ptunit_result read_bad_vaddr(struct iscache_fixture *cfix)
1200 uint8_t buffer[] = { 0xcc };
1203 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1204 ptu_int_gt(isid, 0);
1206 status = pt_iscache_read(&cfix->iscache, buffer, 1ull, isid, 0xb000ull);
1207 ptu_int_eq(status, -pte_nomap);
1208 ptu_uint_eq(buffer[0], 0xcc);
1210 return ptu_passed();
1213 static struct ptunit_result read_bad_isid(struct iscache_fixture *cfix)
1215 uint8_t buffer[] = { 0xcc };
1218 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1219 ptu_int_gt(isid, 0);
1221 status = pt_iscache_read(&cfix->iscache, buffer, 1ull, isid + 1,
1223 ptu_int_eq(status, -pte_bad_image);
1224 ptu_uint_eq(buffer[0], 0xcc);
1226 return ptu_passed();
1229 static struct ptunit_result lru_map(struct iscache_fixture *cfix)
1233 cfix->iscache.limit = cfix->section[0]->size;
1234 ptu_uint_eq(cfix->iscache.used, 0ull);
1235 ptu_null(cfix->iscache.lru);
1237 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1238 ptu_int_gt(isid, 0);
1240 status = pt_section_map(cfix->section[0]);
1241 ptu_int_eq(status, 0);
1243 status = pt_section_unmap(cfix->section[0]);
1244 ptu_int_eq(status, 0);
1246 ptu_ptr(cfix->iscache.lru);
1247 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1248 ptu_null(cfix->iscache.lru->next);
1249 ptu_uint_eq(cfix->iscache.used, cfix->section[0]->size);
1251 return ptu_passed();
1254 static struct ptunit_result lru_read(struct iscache_fixture *cfix)
1256 uint8_t buffer[] = { 0xcc, 0xcc, 0xcc };
1259 cfix->iscache.limit = cfix->section[0]->size;
1260 ptu_uint_eq(cfix->iscache.used, 0ull);
1261 ptu_null(cfix->iscache.lru);
1263 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1264 ptu_int_gt(isid, 0);
1266 status = pt_iscache_read(&cfix->iscache, buffer, 2ull, isid, 0xa008ull);
1267 ptu_int_eq(status, 2);
1269 ptu_ptr(cfix->iscache.lru);
1270 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1271 ptu_null(cfix->iscache.lru->next);
1272 ptu_uint_eq(cfix->iscache.used, cfix->section[0]->size);
1274 return ptu_passed();
1277 static struct ptunit_result lru_map_nodup(struct iscache_fixture *cfix)
1281 cfix->iscache.limit = 2 * cfix->section[0]->size;
1282 ptu_uint_eq(cfix->iscache.used, 0ull);
1283 ptu_null(cfix->iscache.lru);
1285 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1286 ptu_int_gt(isid, 0);
1288 status = pt_section_map(cfix->section[0]);
1289 ptu_int_eq(status, 0);
1291 status = pt_section_unmap(cfix->section[0]);
1292 ptu_int_eq(status, 0);
1294 status = pt_section_map(cfix->section[0]);
1295 ptu_int_eq(status, 0);
1297 status = pt_section_unmap(cfix->section[0]);
1298 ptu_int_eq(status, 0);
1300 ptu_ptr(cfix->iscache.lru);
1301 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1302 ptu_null(cfix->iscache.lru->next);
1303 ptu_uint_eq(cfix->iscache.used, cfix->section[0]->size);
1305 return ptu_passed();
1308 static struct ptunit_result lru_map_too_big(struct iscache_fixture *cfix)
1312 cfix->iscache.limit = cfix->section[0]->size - 1;
1313 ptu_uint_eq(cfix->iscache.used, 0ull);
1314 ptu_null(cfix->iscache.lru);
1316 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1317 ptu_int_gt(isid, 0);
1319 status = pt_section_map(cfix->section[0]);
1320 ptu_int_eq(status, 0);
1322 status = pt_section_unmap(cfix->section[0]);
1323 ptu_int_eq(status, 0);
1325 ptu_null(cfix->iscache.lru);
1326 ptu_uint_eq(cfix->iscache.used, 0ull);
1328 return ptu_passed();
1331 static struct ptunit_result lru_map_add_front(struct iscache_fixture *cfix)
1335 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1336 ptu_uint_eq(cfix->iscache.used, 0ull);
1337 ptu_null(cfix->iscache.lru);
1339 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1340 ptu_int_gt(isid, 0);
1342 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1343 ptu_int_gt(isid, 0);
1345 status = pt_section_map(cfix->section[0]);
1346 ptu_int_eq(status, 0);
1348 status = pt_section_unmap(cfix->section[0]);
1349 ptu_int_eq(status, 0);
1351 status = pt_section_map(cfix->section[1]);
1352 ptu_int_eq(status, 0);
1354 status = pt_section_unmap(cfix->section[1]);
1355 ptu_int_eq(status, 0);
1357 ptu_ptr(cfix->iscache.lru);
1358 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[1]);
1359 ptu_ptr(cfix->iscache.lru->next);
1360 ptu_ptr_eq(cfix->iscache.lru->next->section, cfix->section[0]);
1361 ptu_null(cfix->iscache.lru->next->next);
1362 ptu_uint_eq(cfix->iscache.used,
1363 cfix->section[0]->size + cfix->section[1]->size);
1365 return ptu_passed();
1368 static struct ptunit_result lru_map_move_front(struct iscache_fixture *cfix)
1372 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1373 ptu_uint_eq(cfix->iscache.used, 0ull);
1374 ptu_null(cfix->iscache.lru);
1376 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1377 ptu_int_gt(isid, 0);
1379 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1380 ptu_int_gt(isid, 0);
1382 status = pt_section_map(cfix->section[0]);
1383 ptu_int_eq(status, 0);
1385 status = pt_section_unmap(cfix->section[0]);
1386 ptu_int_eq(status, 0);
1388 status = pt_section_map(cfix->section[1]);
1389 ptu_int_eq(status, 0);
1391 status = pt_section_unmap(cfix->section[1]);
1392 ptu_int_eq(status, 0);
1394 status = pt_section_map(cfix->section[0]);
1395 ptu_int_eq(status, 0);
1397 status = pt_section_unmap(cfix->section[0]);
1398 ptu_int_eq(status, 0);
1400 ptu_ptr(cfix->iscache.lru);
1401 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1402 ptu_ptr(cfix->iscache.lru->next);
1403 ptu_ptr_eq(cfix->iscache.lru->next->section, cfix->section[1]);
1404 ptu_null(cfix->iscache.lru->next->next);
1405 ptu_uint_eq(cfix->iscache.used,
1406 cfix->section[0]->size + cfix->section[1]->size);
1408 return ptu_passed();
1411 static struct ptunit_result lru_map_evict(struct iscache_fixture *cfix)
1415 cfix->iscache.limit = cfix->section[0]->size +
1416 cfix->section[1]->size - 1;
1417 ptu_uint_eq(cfix->iscache.used, 0ull);
1418 ptu_null(cfix->iscache.lru);
1420 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1421 ptu_int_gt(isid, 0);
1423 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1424 ptu_int_gt(isid, 0);
1426 status = pt_section_map(cfix->section[0]);
1427 ptu_int_eq(status, 0);
1429 status = pt_section_unmap(cfix->section[0]);
1430 ptu_int_eq(status, 0);
1432 status = pt_section_map(cfix->section[1]);
1433 ptu_int_eq(status, 0);
1435 status = pt_section_unmap(cfix->section[1]);
1436 ptu_int_eq(status, 0);
1438 ptu_ptr(cfix->iscache.lru);
1439 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[1]);
1440 ptu_null(cfix->iscache.lru->next);
1441 ptu_uint_eq(cfix->iscache.used, cfix->section[1]->size);
1443 return ptu_passed();
1446 static struct ptunit_result lru_bcache_evict(struct iscache_fixture *cfix)
1450 cfix->iscache.limit = 4 * cfix->section[0]->size +
1451 cfix->section[1]->size - 1;
1452 ptu_uint_eq(cfix->iscache.used, 0ull);
1453 ptu_null(cfix->iscache.lru);
1455 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1456 ptu_int_gt(isid, 0);
1458 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1459 ptu_int_gt(isid, 0);
1461 status = pt_section_map(cfix->section[0]);
1462 ptu_int_eq(status, 0);
1464 status = pt_section_unmap(cfix->section[0]);
1465 ptu_int_eq(status, 0);
1467 status = pt_section_map(cfix->section[1]);
1468 ptu_int_eq(status, 0);
1470 status = pt_section_unmap(cfix->section[1]);
1471 ptu_int_eq(status, 0);
1473 status = pt_section_request_bcache(cfix->section[0]);
1474 ptu_int_eq(status, 0);
1476 ptu_ptr(cfix->iscache.lru);
1477 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1478 ptu_null(cfix->iscache.lru->next);
1479 ptu_uint_eq(cfix->iscache.used, 4 * cfix->section[0]->size);
1481 return ptu_passed();
1484 static struct ptunit_result lru_bcache_clear(struct iscache_fixture *cfix)
1488 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1489 ptu_uint_eq(cfix->iscache.used, 0ull);
1490 ptu_null(cfix->iscache.lru);
1492 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1493 ptu_int_gt(isid, 0);
1495 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1496 ptu_int_gt(isid, 0);
1498 status = pt_section_map(cfix->section[0]);
1499 ptu_int_eq(status, 0);
1501 status = pt_section_unmap(cfix->section[0]);
1502 ptu_int_eq(status, 0);
1504 status = pt_section_map(cfix->section[1]);
1505 ptu_int_eq(status, 0);
1507 status = pt_section_unmap(cfix->section[1]);
1508 ptu_int_eq(status, 0);
1510 status = pt_section_request_bcache(cfix->section[0]);
1511 ptu_int_eq(status, 0);
1513 ptu_null(cfix->iscache.lru);
1514 ptu_uint_eq(cfix->iscache.used, 0ull);
1516 return ptu_passed();
1519 static struct ptunit_result lru_limit_evict(struct iscache_fixture *cfix)
1523 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1524 ptu_uint_eq(cfix->iscache.used, 0ull);
1525 ptu_null(cfix->iscache.lru);
1527 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1528 ptu_int_gt(isid, 0);
1530 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1531 ptu_int_gt(isid, 0);
1533 status = pt_section_map(cfix->section[0]);
1534 ptu_int_eq(status, 0);
1536 status = pt_section_unmap(cfix->section[0]);
1537 ptu_int_eq(status, 0);
1539 status = pt_section_map(cfix->section[1]);
1540 ptu_int_eq(status, 0);
1542 status = pt_section_unmap(cfix->section[1]);
1543 ptu_int_eq(status, 0);
1545 status = pt_iscache_set_limit(&cfix->iscache,
1546 cfix->section[0]->size +
1547 cfix->section[1]->size - 1);
1548 ptu_int_eq(status, 0);
1550 ptu_ptr(cfix->iscache.lru);
1551 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[1]);
1552 ptu_null(cfix->iscache.lru->next);
1553 ptu_uint_eq(cfix->iscache.used, cfix->section[1]->size);
1555 return ptu_passed();
1558 static struct ptunit_result lru_clear(struct iscache_fixture *cfix)
1562 cfix->iscache.limit = cfix->section[0]->size;
1563 ptu_uint_eq(cfix->iscache.used, 0ull);
1564 ptu_null(cfix->iscache.lru);
1566 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1567 ptu_int_gt(isid, 0);
1569 status = pt_section_map(cfix->section[0]);
1570 ptu_int_eq(status, 0);
1572 status = pt_section_unmap(cfix->section[0]);
1573 ptu_int_eq(status, 0);
1575 status = pt_iscache_clear(&cfix->iscache);
1576 ptu_int_eq(status, 0);
1578 ptu_null(cfix->iscache.lru);
1579 ptu_uint_eq(cfix->iscache.used, 0ull);
1581 return ptu_passed();
1584 static int worker_add(void *arg)
1586 struct iscache_fixture *cfix;
1591 return -pte_internal;
1593 for (it = 0; it < num_iterations; ++it) {
1597 laddr = 0x1000ull * (it % 23);
1599 for (sec = 0; sec < num_sections; ++sec) {
1600 struct pt_section *section;
1604 isid = pt_iscache_add(&cfix->iscache,
1605 cfix->section[sec], laddr);
1609 errcode = pt_iscache_lookup(&cfix->iscache, §ion,
1617 /* We may not get the image we added but the image we
1618 * get must have similar attributes.
1620 * We're using the same filename string literal for all
1623 if (section->offset != cfix->section[sec]->offset)
1624 return -pte_bad_image;
1626 if (section->size != cfix->section[sec]->size)
1627 return -pte_bad_image;
1629 errcode = pt_section_put(section);
1638 static int worker_add_file(void *arg)
1640 struct iscache_fixture *cfix;
1645 return -pte_internal;
1647 for (it = 0; it < num_iterations; ++it) {
1648 uint64_t offset, size, laddr;
1651 offset = it % 7 == 0 ? 0x1000 : 0x2000;
1652 size = it % 5 == 0 ? 0x1000 : 0x2000;
1653 laddr = it % 3 == 0 ? 0x1000 : 0x2000;
1655 for (sec = 0; sec < num_sections; ++sec) {
1656 struct pt_section *section;
1660 isid = pt_iscache_add_file(&cfix->iscache, "name",
1661 offset, size, laddr);
1665 errcode = pt_iscache_lookup(&cfix->iscache, §ion,
1673 if (section->offset != offset)
1674 return -pte_bad_image;
1676 if (section->size != size)
1677 return -pte_bad_image;
1679 errcode = pt_section_put(section);
1688 static int worker_map(void *arg)
1690 struct iscache_fixture *cfix;
1691 int it, sec, status;
1695 return -pte_internal;
1697 for (it = 0; it < num_iterations; ++it) {
1698 for (sec = 0; sec < num_sections; ++sec) {
1700 status = pt_section_map(cfix->section[sec]);
1704 status = pt_section_unmap(cfix->section[sec]);
1713 static int worker_map_limit(void *arg)
1715 struct iscache_fixture *cfix;
1716 uint64_t limits[] = { 0x8000, 0x3000, 0x12000, 0x0 }, limit;
1717 int it, sec, errcode, lim;
1721 return -pte_internal;
1724 for (it = 0; it < num_iterations; ++it) {
1725 for (sec = 0; sec < num_sections; ++sec) {
1727 errcode = pt_section_map(cfix->section[sec]);
1731 errcode = pt_section_unmap(cfix->section[sec]);
1739 limit = limits[lim++];
1740 lim %= sizeof(limits) / sizeof(*limits);
1742 errcode = pt_iscache_set_limit(&cfix->iscache, limit);
1750 static int worker_map_bcache(void *arg)
1752 struct iscache_fixture *cfix;
1753 int it, sec, status;
1757 return -pte_internal;
1759 for (it = 0; it < num_iterations; ++it) {
1760 for (sec = 0; sec < num_sections; ++sec) {
1761 struct pt_section *section;
1763 section = cfix->section[sec];
1765 status = pt_section_map(section);
1770 status = pt_section_request_bcache(section);
1772 (void) pt_section_unmap(section);
1777 status = pt_section_unmap(section);
1786 static int worker_add_map(void *arg)
1788 struct iscache_fixture *cfix;
1789 struct pt_section *section;
1794 return -pte_internal;
1796 section = cfix->section[0];
1797 for (it = 0; it < num_iterations; ++it) {
1801 laddr = (uint64_t) it << 3;
1803 isid = pt_iscache_add(&cfix->iscache, section, laddr);
1807 errcode = pt_section_map(section);
1811 errcode = pt_section_unmap(section);
1819 static int worker_add_clear(void *arg)
1821 struct iscache_fixture *cfix;
1822 struct pt_section *section;
1827 return -pte_internal;
1829 section = cfix->section[0];
1830 for (it = 0; it < num_iterations; ++it) {
1834 laddr = (uint64_t) it << 3;
1836 isid = pt_iscache_add(&cfix->iscache, section, laddr);
1840 errcode = pt_iscache_clear(&cfix->iscache);
1848 static int worker_add_file_map(void *arg)
1850 struct iscache_fixture *cfix;
1855 return -pte_internal;
1857 for (it = 0; it < num_iterations; ++it) {
1858 struct pt_section *section;
1859 uint64_t offset, size, laddr, addr;
1862 offset = it % 7 < 4 ? 0x1000 : 0x2000;
1863 size = it % 5 < 3 ? 0x1000 : 0x2000;
1864 laddr = it % 3 < 2 ? 0x1000 : 0x2000;
1866 isid = pt_iscache_add_file(&cfix->iscache, "name",
1867 offset, size, laddr);
1871 errcode = pt_iscache_lookup(&cfix->iscache, §ion,
1877 return -pte_internal;
1879 errcode = pt_section_map(section);
1883 errcode = pt_section_unmap(section);
1891 static int worker_add_file_clear(void *arg)
1893 struct iscache_fixture *cfix;
1898 return -pte_internal;
1900 for (it = 0; it < num_iterations; ++it) {
1901 uint64_t offset, size, laddr;
1904 offset = it % 7 < 4 ? 0x1000 : 0x2000;
1905 size = it % 5 < 3 ? 0x1000 : 0x2000;
1906 laddr = it % 3 < 2 ? 0x1000 : 0x2000;
1908 isid = pt_iscache_add_file(&cfix->iscache, "name",
1909 offset, size, laddr);
1916 errcode = pt_iscache_clear(&cfix->iscache);
1924 static struct ptunit_result stress(struct iscache_fixture *cfix,
1925 int (*worker)(void *))
1929 #if defined(FEATURE_THREADS)
1933 for (thrd = 0; thrd < num_threads; ++thrd)
1934 ptu_test(ptunit_thrd_create, &cfix->thrd, worker, cfix);
1936 #endif /* defined(FEATURE_THREADS) */
1938 errcode = worker(cfix);
1939 ptu_int_eq(errcode, 0);
1941 return ptu_passed();
1943 int main(int argc, char **argv)
1945 struct iscache_fixture cfix, dfix, sfix;
1946 struct ptunit_suite suite;
1948 cfix.init = cfix_init;
1949 cfix.fini = cfix_fini;
1951 dfix.init = dfix_init;
1952 dfix.fini = cfix_fini;
1954 sfix.init = sfix_init;
1955 sfix.fini = cfix_fini;
1957 suite = ptunit_mk_suite(argc, argv);
1959 ptu_run(suite, init_null);
1960 ptu_run(suite, fini_null);
1961 ptu_run(suite, name_null);
1962 ptu_run(suite, add_null);
1963 ptu_run(suite, find_null);
1964 ptu_run(suite, lookup_null);
1965 ptu_run(suite, clear_null);
1966 ptu_run(suite, free_null);
1967 ptu_run(suite, add_file_null);
1968 ptu_run(suite, read_null);
1970 ptu_run_f(suite, name, dfix);
1971 ptu_run_f(suite, name_none, dfix);
1973 ptu_run_f(suite, init_fini, cfix);
1974 ptu_run_f(suite, add, cfix);
1975 ptu_run_f(suite, add_no_name, cfix);
1976 ptu_run_f(suite, add_file, cfix);
1978 ptu_run_f(suite, find, cfix);
1979 ptu_run_f(suite, find_empty, cfix);
1980 ptu_run_f(suite, find_bad_filename, cfix);
1981 ptu_run_f(suite, find_null_filename, cfix);
1982 ptu_run_f(suite, find_bad_offset, cfix);
1983 ptu_run_f(suite, find_bad_size, cfix);
1984 ptu_run_f(suite, find_bad_laddr, cfix);
1986 ptu_run_f(suite, lookup, cfix);
1987 ptu_run_f(suite, lookup_bad_isid, cfix);
1989 ptu_run_f(suite, clear_empty, cfix);
1990 ptu_run_f(suite, clear_find, cfix);
1991 ptu_run_f(suite, clear_lookup, cfix);
1993 ptu_run_f(suite, add_twice, cfix);
1994 ptu_run_f(suite, add_same, cfix);
1995 ptu_run_f(suite, add_twice_different_laddr, cfix);
1996 ptu_run_f(suite, add_same_different_laddr, cfix);
1997 ptu_run_f(suite, add_different_same_laddr, cfix);
1999 ptu_run_f(suite, add_file_same, cfix);
2000 ptu_run_f(suite, add_file_same_different_laddr, cfix);
2001 ptu_run_f(suite, add_file_different_same_laddr, cfix);
2003 ptu_run_f(suite, read, cfix);
2004 ptu_run_f(suite, read_truncate, cfix);
2005 ptu_run_f(suite, read_bad_vaddr, cfix);
2006 ptu_run_f(suite, read_bad_isid, cfix);
2008 ptu_run_f(suite, lru_map, cfix);
2009 ptu_run_f(suite, lru_read, cfix);
2010 ptu_run_f(suite, lru_map_nodup, cfix);
2011 ptu_run_f(suite, lru_map_too_big, cfix);
2012 ptu_run_f(suite, lru_map_add_front, cfix);
2013 ptu_run_f(suite, lru_map_move_front, cfix);
2014 ptu_run_f(suite, lru_map_evict, cfix);
2015 ptu_run_f(suite, lru_limit_evict, cfix);
2016 ptu_run_f(suite, lru_bcache_evict, cfix);
2017 ptu_run_f(suite, lru_bcache_clear, cfix);
2018 ptu_run_f(suite, lru_clear, cfix);
2020 ptu_run_fp(suite, stress, cfix, worker_add);
2021 ptu_run_fp(suite, stress, cfix, worker_add_file);
2022 ptu_run_fp(suite, stress, sfix, worker_map);
2023 ptu_run_fp(suite, stress, sfix, worker_map_limit);
2024 ptu_run_fp(suite, stress, sfix, worker_map_bcache);
2025 ptu_run_fp(suite, stress, cfix, worker_add_map);
2026 ptu_run_fp(suite, stress, cfix, worker_add_clear);
2027 ptu_run_fp(suite, stress, cfix, worker_add_file_map);
2028 ptu_run_fp(suite, stress, cfix, worker_add_file_clear);
2030 return ptunit_report(&suite);