2 * Copyright (c) 2016-2018, 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 struct pt_section *pt_mk_section(const char *filename, uint64_t offset,
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 struct pt_section *pt_mk_section(const char *filename, uint64_t offset,
99 struct pt_section *section;
101 section = malloc(sizeof(*section));
105 memset(section, 0, sizeof(*section));
106 section->filename = filename;
107 section->offset = offset;
108 section->size = size;
111 for (idx = 0; idx < sizeof(section->content); ++idx)
112 section->content[idx] = idx;
114 #if defined(FEATURE_THREADS)
118 errcode = mtx_init(§ion->lock, mtx_plain);
119 if (errcode != thrd_success) {
124 errcode = mtx_init(§ion->alock, mtx_plain);
125 if (errcode != thrd_success) {
126 mtx_destroy(§ion->lock);
131 #endif /* defined(FEATURE_THREADS) */
137 static int pt_section_lock(struct pt_section *section)
140 return -pte_internal;
142 #if defined(FEATURE_THREADS)
146 errcode = mtx_lock(§ion->lock);
147 if (errcode != thrd_success)
148 return -pte_bad_lock;
150 #endif /* defined(FEATURE_THREADS) */
155 static int pt_section_unlock(struct pt_section *section)
158 return -pte_internal;
160 #if defined(FEATURE_THREADS)
164 errcode = mtx_unlock(§ion->lock);
165 if (errcode != thrd_success)
166 return -pte_bad_lock;
168 #endif /* defined(FEATURE_THREADS) */
173 static int pt_section_lock_attach(struct pt_section *section)
176 return -pte_internal;
178 #if defined(FEATURE_THREADS)
182 errcode = mtx_lock(§ion->alock);
183 if (errcode != thrd_success)
184 return -pte_bad_lock;
186 #endif /* defined(FEATURE_THREADS) */
191 static int pt_section_unlock_attach(struct pt_section *section)
194 return -pte_internal;
196 #if defined(FEATURE_THREADS)
200 errcode = mtx_unlock(§ion->alock);
201 if (errcode != thrd_success)
202 return -pte_bad_lock;
204 #endif /* defined(FEATURE_THREADS) */
209 int pt_section_get(struct pt_section *section)
214 return -pte_internal;
216 errcode = pt_section_lock(section);
220 ucount = ++section->ucount;
222 errcode = pt_section_unlock(section);
227 return -pte_internal;
232 int pt_section_put(struct pt_section *section)
237 return -pte_internal;
239 errcode = pt_section_lock(section);
243 ucount = --section->ucount;
245 errcode = pt_section_unlock(section);
250 #if defined(FEATURE_THREADS)
251 mtx_destroy(§ion->alock);
252 mtx_destroy(§ion->lock);
253 #endif /* defined(FEATURE_THREADS) */
260 int pt_section_attach(struct pt_section *section,
261 struct pt_image_section_cache *iscache)
263 int errcode, ucount, acount;
265 if (!section || !iscache)
266 return -pte_internal;
268 errcode = pt_section_lock_attach(section);
272 ucount = section->ucount;
273 acount = section->acount;
275 if (section->iscache || !ucount)
278 section->iscache = iscache;
281 return pt_section_unlock_attach(section);
286 (void) pt_section_unlock_attach(section);
287 return -pte_overflow;
293 if (section->iscache != iscache)
296 section->acount = acount;
298 return pt_section_unlock_attach(section);
301 (void) pt_section_unlock_attach(section);
302 return -pte_internal;
305 int pt_section_detach(struct pt_section *section,
306 struct pt_image_section_cache *iscache)
308 int errcode, ucount, acount;
310 if (!section || !iscache)
311 return -pte_internal;
313 errcode = pt_section_lock_attach(section);
317 if (section->iscache != iscache)
320 acount = section->acount;
325 ucount = section->ucount;
329 section->acount = acount;
331 section->iscache = NULL;
333 return pt_section_unlock_attach(section);
336 (void) pt_section_unlock_attach(section);
337 return -pte_internal;
340 int pt_section_map(struct pt_section *section)
342 struct pt_image_section_cache *iscache;
346 return -pte_internal;
348 errcode = pt_section_map_share(section);
352 errcode = pt_section_lock_attach(section);
357 iscache = section->iscache;
359 status = pt_iscache_notify_map(iscache, section);
361 errcode = pt_section_unlock_attach(section);
363 return (status < 0) ? status : errcode;
366 int pt_section_map_share(struct pt_section *section)
371 return -pte_internal;
373 errcode = pt_section_lock(section);
377 mcount = ++section->mcount;
379 errcode = pt_section_unlock(section);
384 return -pte_internal;
389 int pt_section_unmap(struct pt_section *section)
394 return -pte_internal;
396 errcode = pt_section_lock(section);
400 section->bcsize = 0ull;
401 mcount = --section->mcount;
403 errcode = pt_section_unlock(section);
408 return -pte_internal;
413 int pt_section_request_bcache(struct pt_section *section)
415 struct pt_image_section_cache *iscache;
420 return -pte_internal;
422 errcode = pt_section_lock_attach(section);
426 errcode = pt_section_lock(section);
433 section->bcsize = section->size * 3;
434 memsize = section->size + section->bcsize;
436 errcode = pt_section_unlock(section);
440 iscache = section->iscache;
442 errcode = pt_iscache_notify_resize(iscache, section, memsize);
447 return pt_section_unlock_attach(section);
451 (void) pt_section_unlock(section);
454 (void) pt_section_unlock_attach(section);
458 const char *pt_section_filename(const struct pt_section *section)
463 return section->filename;
466 uint64_t pt_section_offset(const struct pt_section *section)
471 return section->offset;
474 uint64_t pt_section_size(const struct pt_section *section)
479 return section->size;
482 int pt_section_memsize(struct pt_section *section, uint64_t *size)
484 if (!section || !size)
485 return -pte_internal;
487 *size = section->mcount ? section->size + section->bcsize : 0ull;
492 int pt_section_read(const struct pt_section *section, uint8_t *buffer,
493 uint16_t size, uint64_t offset)
495 uint64_t begin, end, max;
497 if (!section || !buffer)
498 return -pte_internal;
502 max = sizeof(section->content);
513 memcpy(buffer, §ion->content[begin], (size_t) (end - begin));
514 return (int) (end - begin);
518 /* The number of test sections. */
521 #if defined(FEATURE_THREADS)
525 #endif /* defined(FEATURE_THREADS) */
527 num_iterations = 0x1000
530 struct iscache_fixture {
531 /* Threading support. */
532 struct ptunit_thrd_fixture thrd;
534 /* The image section cache under test. */
535 struct pt_image_section_cache iscache;
537 /* A bunch of test sections. */
538 struct pt_section *section[num_sections];
540 /* The test fixture initialization and finalization functions. */
541 struct ptunit_result (*init)(struct iscache_fixture *);
542 struct ptunit_result (*fini)(struct iscache_fixture *);
545 static struct ptunit_result dfix_init(struct iscache_fixture *cfix)
549 ptu_test(ptunit_thrd_init, &cfix->thrd);
551 memset(cfix->section, 0, sizeof(cfix->section));
553 for (idx = 0; idx < num_sections; ++idx) {
554 struct pt_section *section;
556 section = pt_mk_section("some-filename",
557 idx % 3 == 0 ? 0x1000 : 0x2000,
558 idx % 2 == 0 ? 0x1000 : 0x2000);
561 cfix->section[idx] = section;
567 static struct ptunit_result cfix_init(struct iscache_fixture *cfix)
571 ptu_test(dfix_init, cfix);
573 errcode = pt_iscache_init(&cfix->iscache, NULL);
574 ptu_int_eq(errcode, 0);
579 static struct ptunit_result sfix_init(struct iscache_fixture *cfix)
583 ptu_test(cfix_init, cfix);
585 cfix->iscache.limit = 0x7800;
587 for (idx = 0; idx < num_sections; ++idx) {
588 status = pt_iscache_add(&cfix->iscache, cfix->section[idx],
590 ptu_int_ge(status, 0);
596 static struct ptunit_result cfix_fini(struct iscache_fixture *cfix)
600 ptu_test(ptunit_thrd_fini, &cfix->thrd);
602 for (idx = 0; idx < cfix->thrd.nthreads; ++idx)
603 ptu_int_eq(cfix->thrd.result[idx], 0);
605 pt_iscache_fini(&cfix->iscache);
607 for (idx = 0; idx < num_sections; ++idx) {
608 ptu_int_eq(cfix->section[idx]->ucount, 1);
609 ptu_int_eq(cfix->section[idx]->acount, 0);
610 ptu_int_eq(cfix->section[idx]->mcount, 0);
611 ptu_null(cfix->section[idx]->iscache);
613 errcode = pt_section_put(cfix->section[idx]);
614 ptu_int_eq(errcode, 0);
621 static struct ptunit_result init_null(void)
625 errcode = pt_iscache_init(NULL, NULL);
626 ptu_int_eq(errcode, -pte_internal);
631 static struct ptunit_result fini_null(void)
633 pt_iscache_fini(NULL);
638 static struct ptunit_result name_null(void)
642 name = pt_iscache_name(NULL);
648 static struct ptunit_result add_null(void)
650 struct pt_image_section_cache iscache;
651 struct pt_section section;
654 errcode = pt_iscache_add(NULL, §ion, 0ull);
655 ptu_int_eq(errcode, -pte_internal);
657 errcode = pt_iscache_add(&iscache, NULL, 0ull);
658 ptu_int_eq(errcode, -pte_internal);
663 static struct ptunit_result find_null(void)
667 errcode = pt_iscache_find(NULL, "filename", 0ull, 0ull, 0ull);
668 ptu_int_eq(errcode, -pte_internal);
673 static struct ptunit_result lookup_null(void)
675 struct pt_image_section_cache iscache;
676 struct pt_section *section;
680 errcode = pt_iscache_lookup(NULL, §ion, &laddr, 0);
681 ptu_int_eq(errcode, -pte_internal);
683 errcode = pt_iscache_lookup(&iscache, NULL, &laddr, 0);
684 ptu_int_eq(errcode, -pte_internal);
686 errcode = pt_iscache_lookup(&iscache, §ion, NULL, 0);
687 ptu_int_eq(errcode, -pte_internal);
692 static struct ptunit_result clear_null(void)
696 errcode = pt_iscache_clear(NULL);
697 ptu_int_eq(errcode, -pte_internal);
702 static struct ptunit_result free_null(void)
704 pt_iscache_free(NULL);
709 static struct ptunit_result add_file_null(void)
711 struct pt_image_section_cache iscache;
714 errcode = pt_iscache_add_file(NULL, "filename", 0ull, 0ull, 0ull);
715 ptu_int_eq(errcode, -pte_invalid);
717 errcode = pt_iscache_add_file(&iscache, NULL, 0ull, 0ull, 0ull);
718 ptu_int_eq(errcode, -pte_invalid);
723 static struct ptunit_result read_null(void)
725 struct pt_image_section_cache iscache;
729 errcode = pt_iscache_read(NULL, &buffer, sizeof(buffer), 1ull, 0ull);
730 ptu_int_eq(errcode, -pte_invalid);
732 errcode = pt_iscache_read(&iscache, NULL, sizeof(buffer), 1ull, 0ull);
733 ptu_int_eq(errcode, -pte_invalid);
735 errcode = pt_iscache_read(&iscache, &buffer, 0ull, 1, 0ull);
736 ptu_int_eq(errcode, -pte_invalid);
741 static struct ptunit_result init_fini(struct iscache_fixture *cfix)
745 /* The actual init and fini calls are in cfix_init() and cfix_fini(). */
749 static struct ptunit_result name(struct iscache_fixture *cfix)
753 pt_iscache_init(&cfix->iscache, "iscache-name");
755 name = pt_iscache_name(&cfix->iscache);
756 ptu_str_eq(name, "iscache-name");
761 static struct ptunit_result name_none(struct iscache_fixture *cfix)
765 pt_iscache_init(&cfix->iscache, NULL);
767 name = pt_iscache_name(&cfix->iscache);
773 static struct ptunit_result add(struct iscache_fixture *cfix)
777 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
780 /* The cache attaches and gets a reference on success. */
781 ptu_int_eq(cfix->section[0]->ucount, 2);
782 ptu_int_eq(cfix->section[0]->acount, 1);
784 /* The added section must be implicitly put in pt_iscache_fini. */
788 static struct ptunit_result add_no_name(struct iscache_fixture *cfix)
790 struct pt_section section;
793 memset(§ion, 0, sizeof(section));
795 errcode = pt_iscache_add(&cfix->iscache, §ion, 0ull);
796 ptu_int_eq(errcode, -pte_internal);
801 static struct ptunit_result add_file(struct iscache_fixture *cfix)
805 isid = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
811 static struct ptunit_result find(struct iscache_fixture *cfix)
813 struct pt_section *section;
816 section = cfix->section[0];
819 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
822 found = pt_iscache_find(&cfix->iscache, section->filename,
823 section->offset, section->size, 0ull);
824 ptu_int_eq(found, isid);
829 static struct ptunit_result find_empty(struct iscache_fixture *cfix)
831 struct pt_section *section;
834 section = cfix->section[0];
837 found = pt_iscache_find(&cfix->iscache, section->filename,
838 section->offset, section->size, 0ull);
839 ptu_int_eq(found, 0);
844 static struct ptunit_result find_bad_filename(struct iscache_fixture *cfix)
846 struct pt_section *section;
849 section = cfix->section[0];
852 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
855 found = pt_iscache_find(&cfix->iscache, "bad-filename",
856 section->offset, section->size, 0ull);
857 ptu_int_eq(found, 0);
862 static struct ptunit_result find_null_filename(struct iscache_fixture *cfix)
866 errcode = pt_iscache_find(&cfix->iscache, NULL, 0ull, 0ull, 0ull);
867 ptu_int_eq(errcode, -pte_internal);
872 static struct ptunit_result find_bad_offset(struct iscache_fixture *cfix)
874 struct pt_section *section;
877 section = cfix->section[0];
880 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
883 found = pt_iscache_find(&cfix->iscache, section->filename, 0ull,
884 section->size, 0ull);
885 ptu_int_eq(found, 0);
890 static struct ptunit_result find_bad_size(struct iscache_fixture *cfix)
892 struct pt_section *section;
895 section = cfix->section[0];
898 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
901 found = pt_iscache_find(&cfix->iscache, section->filename,
902 section->offset, 0ull, 0ull);
903 ptu_int_eq(found, 0);
908 static struct ptunit_result find_bad_laddr(struct iscache_fixture *cfix)
910 struct pt_section *section;
913 section = cfix->section[0];
916 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
919 found = pt_iscache_find(&cfix->iscache, section->filename,
920 section->offset, section->size, 1ull);
921 ptu_int_eq(found, 0);
926 static struct ptunit_result lookup(struct iscache_fixture *cfix)
928 struct pt_section *section;
932 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
935 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, isid);
936 ptu_int_eq(errcode, 0);
937 ptu_ptr_eq(section, cfix->section[0]);
938 ptu_uint_eq(laddr, 0ull);
940 errcode = pt_section_put(section);
941 ptu_int_eq(errcode, 0);
946 static struct ptunit_result lookup_bad_isid(struct iscache_fixture *cfix)
948 struct pt_section *section;
952 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
955 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, 0);
956 ptu_int_eq(errcode, -pte_bad_image);
958 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, -isid);
959 ptu_int_eq(errcode, -pte_bad_image);
961 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, isid + 1);
962 ptu_int_eq(errcode, -pte_bad_image);
967 static struct ptunit_result clear_empty(struct iscache_fixture *cfix)
971 errcode = pt_iscache_clear(&cfix->iscache);
972 ptu_int_eq(errcode, 0);
977 static struct ptunit_result clear_find(struct iscache_fixture *cfix)
979 struct pt_section *section;
980 int errcode, found, isid;
982 section = cfix->section[0];
985 isid = pt_iscache_add(&cfix->iscache, section, 0ull);
988 errcode = pt_iscache_clear(&cfix->iscache);
989 ptu_int_eq(errcode, 0);
992 found = pt_iscache_find(&cfix->iscache, section->filename,
993 section->offset, section->size, 0ull);
994 ptu_int_eq(found, 0);
999 static struct ptunit_result clear_lookup(struct iscache_fixture *cfix)
1001 struct pt_section *section;
1005 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1006 ptu_int_gt(isid, 0);
1008 errcode = pt_iscache_clear(&cfix->iscache);
1009 ptu_int_eq(errcode, 0);
1011 errcode = pt_iscache_lookup(&cfix->iscache, §ion, &laddr, isid);
1012 ptu_int_eq(errcode, -pte_bad_image);
1014 return ptu_passed();
1017 static struct ptunit_result add_twice(struct iscache_fixture *cfix)
1021 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1022 ptu_int_gt(isid[0], 0);
1024 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1025 ptu_int_gt(isid[1], 0);
1027 /* The second add should be ignored. */
1028 ptu_int_eq(isid[1], isid[0]);
1030 return ptu_passed();
1033 static struct ptunit_result add_same(struct iscache_fixture *cfix)
1037 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1038 ptu_int_gt(isid[0], 0);
1040 cfix->section[1]->offset = cfix->section[0]->offset;
1041 cfix->section[1]->size = cfix->section[0]->size;
1043 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[1], 0ull);
1044 ptu_int_gt(isid[1], 0);
1046 /* The second add should be ignored. */
1047 ptu_int_eq(isid[1], isid[0]);
1049 return ptu_passed();
1052 static struct ptunit_result
1053 add_twice_different_laddr(struct iscache_fixture *cfix)
1057 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1058 ptu_int_gt(isid[0], 0);
1060 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[0], 1ull);
1061 ptu_int_gt(isid[1], 0);
1063 /* We must get different identifiers. */
1064 ptu_int_ne(isid[1], isid[0]);
1066 /* We attach twice and take two references - one for each entry. */
1067 ptu_int_eq(cfix->section[0]->ucount, 3);
1068 ptu_int_eq(cfix->section[0]->acount, 2);
1070 return ptu_passed();
1073 static struct ptunit_result
1074 add_same_different_laddr(struct iscache_fixture *cfix)
1078 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1079 ptu_int_gt(isid[0], 0);
1081 cfix->section[1]->offset = cfix->section[0]->offset;
1082 cfix->section[1]->size = cfix->section[0]->size;
1084 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[1], 1ull);
1085 ptu_int_gt(isid[1], 0);
1087 /* We must get different identifiers. */
1088 ptu_int_ne(isid[1], isid[0]);
1090 return ptu_passed();
1093 static struct ptunit_result
1094 add_different_same_laddr(struct iscache_fixture *cfix)
1098 isid[0] = pt_iscache_add(&cfix->iscache, cfix->section[0], 0ull);
1099 ptu_int_gt(isid[0], 0);
1101 isid[1] = pt_iscache_add(&cfix->iscache, cfix->section[1], 0ull);
1102 ptu_int_gt(isid[1], 0);
1104 /* We must get different identifiers. */
1105 ptu_int_ne(isid[1], isid[0]);
1107 return ptu_passed();
1110 static struct ptunit_result add_file_same(struct iscache_fixture *cfix)
1114 isid[0] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1115 ptu_int_gt(isid[0], 0);
1117 isid[1] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1118 ptu_int_gt(isid[1], 0);
1120 /* The second add should be ignored. */
1121 ptu_int_eq(isid[1], isid[0]);
1123 return ptu_passed();
1126 static struct ptunit_result
1127 add_file_same_different_laddr(struct iscache_fixture *cfix)
1131 isid[0] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1132 ptu_int_gt(isid[0], 0);
1134 isid[1] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 1ull);
1135 ptu_int_gt(isid[1], 0);
1137 /* We must get different identifiers. */
1138 ptu_int_ne(isid[1], isid[0]);
1140 return ptu_passed();
1143 static struct ptunit_result
1144 add_file_different_same_laddr(struct iscache_fixture *cfix)
1148 isid[0] = pt_iscache_add_file(&cfix->iscache, "name", 0ull, 1ull, 0ull);
1149 ptu_int_gt(isid[0], 0);
1151 isid[1] = pt_iscache_add_file(&cfix->iscache, "name", 1ull, 1ull, 0ull);
1152 ptu_int_gt(isid[1], 0);
1154 /* We must get different identifiers. */
1155 ptu_int_ne(isid[1], isid[0]);
1157 return ptu_passed();
1160 static struct ptunit_result read(struct iscache_fixture *cfix)
1162 uint8_t buffer[] = { 0xcc, 0xcc, 0xcc };
1165 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1166 ptu_int_gt(isid, 0);
1168 status = pt_iscache_read(&cfix->iscache, buffer, 2ull, isid, 0xa008ull);
1169 ptu_int_eq(status, 2);
1170 ptu_uint_eq(buffer[0], 0x8);
1171 ptu_uint_eq(buffer[1], 0x9);
1172 ptu_uint_eq(buffer[2], 0xcc);
1174 return ptu_passed();
1177 static struct ptunit_result read_truncate(struct iscache_fixture *cfix)
1179 uint8_t buffer[] = { 0xcc, 0xcc };
1182 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1183 ptu_int_gt(isid, 0);
1185 status = pt_iscache_read(&cfix->iscache, buffer, sizeof(buffer), isid,
1187 ptu_int_eq(status, 1);
1188 ptu_uint_eq(buffer[0], 0xf);
1189 ptu_uint_eq(buffer[1], 0xcc);
1191 return ptu_passed();
1194 static struct ptunit_result read_bad_vaddr(struct iscache_fixture *cfix)
1196 uint8_t buffer[] = { 0xcc };
1199 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1200 ptu_int_gt(isid, 0);
1202 status = pt_iscache_read(&cfix->iscache, buffer, 1ull, isid, 0xb000ull);
1203 ptu_int_eq(status, -pte_nomap);
1204 ptu_uint_eq(buffer[0], 0xcc);
1206 return ptu_passed();
1209 static struct ptunit_result read_bad_isid(struct iscache_fixture *cfix)
1211 uint8_t buffer[] = { 0xcc };
1214 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1215 ptu_int_gt(isid, 0);
1217 status = pt_iscache_read(&cfix->iscache, buffer, 1ull, isid + 1,
1219 ptu_int_eq(status, -pte_bad_image);
1220 ptu_uint_eq(buffer[0], 0xcc);
1222 return ptu_passed();
1225 static struct ptunit_result lru_map(struct iscache_fixture *cfix)
1229 cfix->iscache.limit = cfix->section[0]->size;
1230 ptu_uint_eq(cfix->iscache.used, 0ull);
1231 ptu_null(cfix->iscache.lru);
1233 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1234 ptu_int_gt(isid, 0);
1236 status = pt_section_map(cfix->section[0]);
1237 ptu_int_eq(status, 0);
1239 status = pt_section_unmap(cfix->section[0]);
1240 ptu_int_eq(status, 0);
1242 ptu_ptr(cfix->iscache.lru);
1243 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1244 ptu_null(cfix->iscache.lru->next);
1245 ptu_uint_eq(cfix->iscache.used, cfix->section[0]->size);
1247 return ptu_passed();
1250 static struct ptunit_result lru_read(struct iscache_fixture *cfix)
1252 uint8_t buffer[] = { 0xcc, 0xcc, 0xcc };
1255 cfix->iscache.limit = cfix->section[0]->size;
1256 ptu_uint_eq(cfix->iscache.used, 0ull);
1257 ptu_null(cfix->iscache.lru);
1259 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1260 ptu_int_gt(isid, 0);
1262 status = pt_iscache_read(&cfix->iscache, buffer, 2ull, isid, 0xa008ull);
1263 ptu_int_eq(status, 2);
1265 ptu_ptr(cfix->iscache.lru);
1266 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1267 ptu_null(cfix->iscache.lru->next);
1268 ptu_uint_eq(cfix->iscache.used, cfix->section[0]->size);
1270 return ptu_passed();
1273 static struct ptunit_result lru_map_nodup(struct iscache_fixture *cfix)
1277 cfix->iscache.limit = 2 * cfix->section[0]->size;
1278 ptu_uint_eq(cfix->iscache.used, 0ull);
1279 ptu_null(cfix->iscache.lru);
1281 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1282 ptu_int_gt(isid, 0);
1284 status = pt_section_map(cfix->section[0]);
1285 ptu_int_eq(status, 0);
1287 status = pt_section_unmap(cfix->section[0]);
1288 ptu_int_eq(status, 0);
1290 status = pt_section_map(cfix->section[0]);
1291 ptu_int_eq(status, 0);
1293 status = pt_section_unmap(cfix->section[0]);
1294 ptu_int_eq(status, 0);
1296 ptu_ptr(cfix->iscache.lru);
1297 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1298 ptu_null(cfix->iscache.lru->next);
1299 ptu_uint_eq(cfix->iscache.used, cfix->section[0]->size);
1301 return ptu_passed();
1304 static struct ptunit_result lru_map_too_big(struct iscache_fixture *cfix)
1308 cfix->iscache.limit = cfix->section[0]->size - 1;
1309 ptu_uint_eq(cfix->iscache.used, 0ull);
1310 ptu_null(cfix->iscache.lru);
1312 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1313 ptu_int_gt(isid, 0);
1315 status = pt_section_map(cfix->section[0]);
1316 ptu_int_eq(status, 0);
1318 status = pt_section_unmap(cfix->section[0]);
1319 ptu_int_eq(status, 0);
1321 ptu_null(cfix->iscache.lru);
1322 ptu_uint_eq(cfix->iscache.used, 0ull);
1324 return ptu_passed();
1327 static struct ptunit_result lru_map_add_front(struct iscache_fixture *cfix)
1331 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1332 ptu_uint_eq(cfix->iscache.used, 0ull);
1333 ptu_null(cfix->iscache.lru);
1335 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1336 ptu_int_gt(isid, 0);
1338 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1339 ptu_int_gt(isid, 0);
1341 status = pt_section_map(cfix->section[0]);
1342 ptu_int_eq(status, 0);
1344 status = pt_section_unmap(cfix->section[0]);
1345 ptu_int_eq(status, 0);
1347 status = pt_section_map(cfix->section[1]);
1348 ptu_int_eq(status, 0);
1350 status = pt_section_unmap(cfix->section[1]);
1351 ptu_int_eq(status, 0);
1353 ptu_ptr(cfix->iscache.lru);
1354 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[1]);
1355 ptu_ptr(cfix->iscache.lru->next);
1356 ptu_ptr_eq(cfix->iscache.lru->next->section, cfix->section[0]);
1357 ptu_null(cfix->iscache.lru->next->next);
1358 ptu_uint_eq(cfix->iscache.used,
1359 cfix->section[0]->size + cfix->section[1]->size);
1361 return ptu_passed();
1364 static struct ptunit_result lru_map_move_front(struct iscache_fixture *cfix)
1368 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1369 ptu_uint_eq(cfix->iscache.used, 0ull);
1370 ptu_null(cfix->iscache.lru);
1372 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1373 ptu_int_gt(isid, 0);
1375 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1376 ptu_int_gt(isid, 0);
1378 status = pt_section_map(cfix->section[0]);
1379 ptu_int_eq(status, 0);
1381 status = pt_section_unmap(cfix->section[0]);
1382 ptu_int_eq(status, 0);
1384 status = pt_section_map(cfix->section[1]);
1385 ptu_int_eq(status, 0);
1387 status = pt_section_unmap(cfix->section[1]);
1388 ptu_int_eq(status, 0);
1390 status = pt_section_map(cfix->section[0]);
1391 ptu_int_eq(status, 0);
1393 status = pt_section_unmap(cfix->section[0]);
1394 ptu_int_eq(status, 0);
1396 ptu_ptr(cfix->iscache.lru);
1397 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1398 ptu_ptr(cfix->iscache.lru->next);
1399 ptu_ptr_eq(cfix->iscache.lru->next->section, cfix->section[1]);
1400 ptu_null(cfix->iscache.lru->next->next);
1401 ptu_uint_eq(cfix->iscache.used,
1402 cfix->section[0]->size + cfix->section[1]->size);
1404 return ptu_passed();
1407 static struct ptunit_result lru_map_evict(struct iscache_fixture *cfix)
1411 cfix->iscache.limit = cfix->section[0]->size +
1412 cfix->section[1]->size - 1;
1413 ptu_uint_eq(cfix->iscache.used, 0ull);
1414 ptu_null(cfix->iscache.lru);
1416 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1417 ptu_int_gt(isid, 0);
1419 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1420 ptu_int_gt(isid, 0);
1422 status = pt_section_map(cfix->section[0]);
1423 ptu_int_eq(status, 0);
1425 status = pt_section_unmap(cfix->section[0]);
1426 ptu_int_eq(status, 0);
1428 status = pt_section_map(cfix->section[1]);
1429 ptu_int_eq(status, 0);
1431 status = pt_section_unmap(cfix->section[1]);
1432 ptu_int_eq(status, 0);
1434 ptu_ptr(cfix->iscache.lru);
1435 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[1]);
1436 ptu_null(cfix->iscache.lru->next);
1437 ptu_uint_eq(cfix->iscache.used, cfix->section[1]->size);
1439 return ptu_passed();
1442 static struct ptunit_result lru_bcache_evict(struct iscache_fixture *cfix)
1446 cfix->iscache.limit = 4 * cfix->section[0]->size +
1447 cfix->section[1]->size - 1;
1448 ptu_uint_eq(cfix->iscache.used, 0ull);
1449 ptu_null(cfix->iscache.lru);
1451 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1452 ptu_int_gt(isid, 0);
1454 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1455 ptu_int_gt(isid, 0);
1457 status = pt_section_map(cfix->section[0]);
1458 ptu_int_eq(status, 0);
1460 status = pt_section_unmap(cfix->section[0]);
1461 ptu_int_eq(status, 0);
1463 status = pt_section_map(cfix->section[1]);
1464 ptu_int_eq(status, 0);
1466 status = pt_section_unmap(cfix->section[1]);
1467 ptu_int_eq(status, 0);
1469 status = pt_section_request_bcache(cfix->section[0]);
1470 ptu_int_eq(status, 0);
1472 ptu_ptr(cfix->iscache.lru);
1473 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[0]);
1474 ptu_null(cfix->iscache.lru->next);
1475 ptu_uint_eq(cfix->iscache.used, 4 * cfix->section[0]->size);
1477 return ptu_passed();
1480 static struct ptunit_result lru_bcache_clear(struct iscache_fixture *cfix)
1484 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1485 ptu_uint_eq(cfix->iscache.used, 0ull);
1486 ptu_null(cfix->iscache.lru);
1488 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1489 ptu_int_gt(isid, 0);
1491 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1492 ptu_int_gt(isid, 0);
1494 status = pt_section_map(cfix->section[0]);
1495 ptu_int_eq(status, 0);
1497 status = pt_section_unmap(cfix->section[0]);
1498 ptu_int_eq(status, 0);
1500 status = pt_section_map(cfix->section[1]);
1501 ptu_int_eq(status, 0);
1503 status = pt_section_unmap(cfix->section[1]);
1504 ptu_int_eq(status, 0);
1506 status = pt_section_request_bcache(cfix->section[0]);
1507 ptu_int_eq(status, 0);
1509 ptu_null(cfix->iscache.lru);
1510 ptu_uint_eq(cfix->iscache.used, 0ull);
1512 return ptu_passed();
1515 static struct ptunit_result lru_limit_evict(struct iscache_fixture *cfix)
1519 cfix->iscache.limit = cfix->section[0]->size + cfix->section[1]->size;
1520 ptu_uint_eq(cfix->iscache.used, 0ull);
1521 ptu_null(cfix->iscache.lru);
1523 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1524 ptu_int_gt(isid, 0);
1526 isid = pt_iscache_add(&cfix->iscache, cfix->section[1], 0xa000ull);
1527 ptu_int_gt(isid, 0);
1529 status = pt_section_map(cfix->section[0]);
1530 ptu_int_eq(status, 0);
1532 status = pt_section_unmap(cfix->section[0]);
1533 ptu_int_eq(status, 0);
1535 status = pt_section_map(cfix->section[1]);
1536 ptu_int_eq(status, 0);
1538 status = pt_section_unmap(cfix->section[1]);
1539 ptu_int_eq(status, 0);
1541 status = pt_iscache_set_limit(&cfix->iscache,
1542 cfix->section[0]->size +
1543 cfix->section[1]->size - 1);
1544 ptu_int_eq(status, 0);
1546 ptu_ptr(cfix->iscache.lru);
1547 ptu_ptr_eq(cfix->iscache.lru->section, cfix->section[1]);
1548 ptu_null(cfix->iscache.lru->next);
1549 ptu_uint_eq(cfix->iscache.used, cfix->section[1]->size);
1551 return ptu_passed();
1554 static struct ptunit_result lru_clear(struct iscache_fixture *cfix)
1558 cfix->iscache.limit = cfix->section[0]->size;
1559 ptu_uint_eq(cfix->iscache.used, 0ull);
1560 ptu_null(cfix->iscache.lru);
1562 isid = pt_iscache_add(&cfix->iscache, cfix->section[0], 0xa000ull);
1563 ptu_int_gt(isid, 0);
1565 status = pt_section_map(cfix->section[0]);
1566 ptu_int_eq(status, 0);
1568 status = pt_section_unmap(cfix->section[0]);
1569 ptu_int_eq(status, 0);
1571 status = pt_iscache_clear(&cfix->iscache);
1572 ptu_int_eq(status, 0);
1574 ptu_null(cfix->iscache.lru);
1575 ptu_uint_eq(cfix->iscache.used, 0ull);
1577 return ptu_passed();
1580 static int worker_add(void *arg)
1582 struct iscache_fixture *cfix;
1587 return -pte_internal;
1589 for (it = 0; it < num_iterations; ++it) {
1593 laddr = 0x1000ull * (it % 23);
1595 for (sec = 0; sec < num_sections; ++sec) {
1596 struct pt_section *section;
1600 isid = pt_iscache_add(&cfix->iscache,
1601 cfix->section[sec], laddr);
1605 errcode = pt_iscache_lookup(&cfix->iscache, §ion,
1613 /* We may not get the image we added but the image we
1614 * get must have similar attributes.
1616 * We're using the same filename string literal for all
1619 if (section->offset != cfix->section[sec]->offset)
1620 return -pte_bad_image;
1622 if (section->size != cfix->section[sec]->size)
1623 return -pte_bad_image;
1625 errcode = pt_section_put(section);
1634 static int worker_add_file(void *arg)
1636 struct iscache_fixture *cfix;
1641 return -pte_internal;
1643 for (it = 0; it < num_iterations; ++it) {
1644 uint64_t offset, size, laddr;
1647 offset = it % 7 == 0 ? 0x1000 : 0x2000;
1648 size = it % 5 == 0 ? 0x1000 : 0x2000;
1649 laddr = it % 3 == 0 ? 0x1000 : 0x2000;
1651 for (sec = 0; sec < num_sections; ++sec) {
1652 struct pt_section *section;
1656 isid = pt_iscache_add_file(&cfix->iscache, "name",
1657 offset, size, laddr);
1661 errcode = pt_iscache_lookup(&cfix->iscache, §ion,
1669 if (section->offset != offset)
1670 return -pte_bad_image;
1672 if (section->size != size)
1673 return -pte_bad_image;
1675 errcode = pt_section_put(section);
1684 static int worker_map(void *arg)
1686 struct iscache_fixture *cfix;
1687 int it, sec, status;
1691 return -pte_internal;
1693 for (it = 0; it < num_iterations; ++it) {
1694 for (sec = 0; sec < num_sections; ++sec) {
1696 status = pt_section_map(cfix->section[sec]);
1700 status = pt_section_unmap(cfix->section[sec]);
1709 static int worker_map_limit(void *arg)
1711 struct iscache_fixture *cfix;
1712 uint64_t limits[] = { 0x8000, 0x3000, 0x12000, 0x0 }, limit;
1713 int it, sec, errcode, lim;
1717 return -pte_internal;
1720 for (it = 0; it < num_iterations; ++it) {
1721 for (sec = 0; sec < num_sections; ++sec) {
1723 errcode = pt_section_map(cfix->section[sec]);
1727 errcode = pt_section_unmap(cfix->section[sec]);
1735 limit = limits[lim++];
1736 lim %= sizeof(limits) / sizeof(*limits);
1738 errcode = pt_iscache_set_limit(&cfix->iscache, limit);
1746 static int worker_map_bcache(void *arg)
1748 struct iscache_fixture *cfix;
1749 int it, sec, status;
1753 return -pte_internal;
1755 for (it = 0; it < num_iterations; ++it) {
1756 for (sec = 0; sec < num_sections; ++sec) {
1757 struct pt_section *section;
1759 section = cfix->section[sec];
1761 status = pt_section_map(section);
1766 status = pt_section_request_bcache(section);
1768 (void) pt_section_unmap(section);
1773 status = pt_section_unmap(section);
1782 static int worker_add_map(void *arg)
1784 struct iscache_fixture *cfix;
1785 struct pt_section *section;
1790 return -pte_internal;
1792 section = cfix->section[0];
1793 for (it = 0; it < num_iterations; ++it) {
1797 laddr = (uint64_t) it << 3;
1799 isid = pt_iscache_add(&cfix->iscache, section, laddr);
1803 errcode = pt_section_map(section);
1807 errcode = pt_section_unmap(section);
1815 static int worker_add_clear(void *arg)
1817 struct iscache_fixture *cfix;
1818 struct pt_section *section;
1823 return -pte_internal;
1825 section = cfix->section[0];
1826 for (it = 0; it < num_iterations; ++it) {
1830 laddr = (uint64_t) it << 3;
1832 isid = pt_iscache_add(&cfix->iscache, section, laddr);
1836 errcode = pt_iscache_clear(&cfix->iscache);
1844 static int worker_add_file_map(void *arg)
1846 struct iscache_fixture *cfix;
1851 return -pte_internal;
1853 for (it = 0; it < num_iterations; ++it) {
1854 struct pt_section *section;
1855 uint64_t offset, size, laddr, addr;
1858 offset = it % 7 < 4 ? 0x1000 : 0x2000;
1859 size = it % 5 < 3 ? 0x1000 : 0x2000;
1860 laddr = it % 3 < 2 ? 0x1000 : 0x2000;
1862 isid = pt_iscache_add_file(&cfix->iscache, "name",
1863 offset, size, laddr);
1867 errcode = pt_iscache_lookup(&cfix->iscache, §ion,
1873 return -pte_internal;
1875 errcode = pt_section_map(section);
1879 errcode = pt_section_unmap(section);
1887 static int worker_add_file_clear(void *arg)
1889 struct iscache_fixture *cfix;
1894 return -pte_internal;
1896 for (it = 0; it < num_iterations; ++it) {
1897 uint64_t offset, size, laddr;
1900 offset = it % 7 < 4 ? 0x1000 : 0x2000;
1901 size = it % 5 < 3 ? 0x1000 : 0x2000;
1902 laddr = it % 3 < 2 ? 0x1000 : 0x2000;
1904 isid = pt_iscache_add_file(&cfix->iscache, "name",
1905 offset, size, laddr);
1912 errcode = pt_iscache_clear(&cfix->iscache);
1920 static struct ptunit_result stress(struct iscache_fixture *cfix,
1921 int (*worker)(void *))
1925 #if defined(FEATURE_THREADS)
1929 for (thrd = 0; thrd < num_threads; ++thrd)
1930 ptu_test(ptunit_thrd_create, &cfix->thrd, worker, cfix);
1932 #endif /* defined(FEATURE_THREADS) */
1934 errcode = worker(cfix);
1935 ptu_int_eq(errcode, 0);
1937 return ptu_passed();
1939 int main(int argc, char **argv)
1941 struct iscache_fixture cfix, dfix, sfix;
1942 struct ptunit_suite suite;
1944 cfix.init = cfix_init;
1945 cfix.fini = cfix_fini;
1947 dfix.init = dfix_init;
1948 dfix.fini = cfix_fini;
1950 sfix.init = sfix_init;
1951 sfix.fini = cfix_fini;
1953 suite = ptunit_mk_suite(argc, argv);
1955 ptu_run(suite, init_null);
1956 ptu_run(suite, fini_null);
1957 ptu_run(suite, name_null);
1958 ptu_run(suite, add_null);
1959 ptu_run(suite, find_null);
1960 ptu_run(suite, lookup_null);
1961 ptu_run(suite, clear_null);
1962 ptu_run(suite, free_null);
1963 ptu_run(suite, add_file_null);
1964 ptu_run(suite, read_null);
1966 ptu_run_f(suite, name, dfix);
1967 ptu_run_f(suite, name_none, dfix);
1969 ptu_run_f(suite, init_fini, cfix);
1970 ptu_run_f(suite, add, cfix);
1971 ptu_run_f(suite, add_no_name, cfix);
1972 ptu_run_f(suite, add_file, cfix);
1974 ptu_run_f(suite, find, cfix);
1975 ptu_run_f(suite, find_empty, cfix);
1976 ptu_run_f(suite, find_bad_filename, cfix);
1977 ptu_run_f(suite, find_null_filename, cfix);
1978 ptu_run_f(suite, find_bad_offset, cfix);
1979 ptu_run_f(suite, find_bad_size, cfix);
1980 ptu_run_f(suite, find_bad_laddr, cfix);
1982 ptu_run_f(suite, lookup, cfix);
1983 ptu_run_f(suite, lookup_bad_isid, cfix);
1985 ptu_run_f(suite, clear_empty, cfix);
1986 ptu_run_f(suite, clear_find, cfix);
1987 ptu_run_f(suite, clear_lookup, cfix);
1989 ptu_run_f(suite, add_twice, cfix);
1990 ptu_run_f(suite, add_same, cfix);
1991 ptu_run_f(suite, add_twice_different_laddr, cfix);
1992 ptu_run_f(suite, add_same_different_laddr, cfix);
1993 ptu_run_f(suite, add_different_same_laddr, cfix);
1995 ptu_run_f(suite, add_file_same, cfix);
1996 ptu_run_f(suite, add_file_same_different_laddr, cfix);
1997 ptu_run_f(suite, add_file_different_same_laddr, cfix);
1999 ptu_run_f(suite, read, cfix);
2000 ptu_run_f(suite, read_truncate, cfix);
2001 ptu_run_f(suite, read_bad_vaddr, cfix);
2002 ptu_run_f(suite, read_bad_isid, cfix);
2004 ptu_run_f(suite, lru_map, cfix);
2005 ptu_run_f(suite, lru_read, cfix);
2006 ptu_run_f(suite, lru_map_nodup, cfix);
2007 ptu_run_f(suite, lru_map_too_big, cfix);
2008 ptu_run_f(suite, lru_map_add_front, cfix);
2009 ptu_run_f(suite, lru_map_move_front, cfix);
2010 ptu_run_f(suite, lru_map_evict, cfix);
2011 ptu_run_f(suite, lru_limit_evict, cfix);
2012 ptu_run_f(suite, lru_bcache_evict, cfix);
2013 ptu_run_f(suite, lru_bcache_clear, cfix);
2014 ptu_run_f(suite, lru_clear, cfix);
2016 ptu_run_fp(suite, stress, cfix, worker_add);
2017 ptu_run_fp(suite, stress, cfix, worker_add_file);
2018 ptu_run_fp(suite, stress, sfix, worker_map);
2019 ptu_run_fp(suite, stress, sfix, worker_map_limit);
2020 ptu_run_fp(suite, stress, sfix, worker_map_bcache);
2021 ptu_run_fp(suite, stress, cfix, worker_add_map);
2022 ptu_run_fp(suite, stress, cfix, worker_add_clear);
2023 ptu_run_fp(suite, stress, cfix, worker_add_file_map);
2024 ptu_run_fp(suite, stress, cfix, worker_add_file_clear);
2026 return ptunit_report(&suite);