MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ztest_fletcher

Function ztest_fletcher

freebsd/contrib/openzfs/cmd/ztest/ztest.c:6238–6305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6236}
6237
6238void
6239ztest_fletcher(ztest_ds_t *zd, uint64_t id)
6240{
6241 hrtime_t end = gethrtime() + NANOSEC;
6242
6243 while (gethrtime() <= end) {
6244 int run_count = 100;
6245 void *buf;
6246 struct abd *abd_data, *abd_meta;
6247 uint32_t size;
6248 int *ptr;
6249 int i;
6250 zio_cksum_t zc_ref;
6251 zio_cksum_t zc_ref_byteswap;
6252
6253 size = ztest_random_blocksize();
6254
6255 buf = umem_alloc(size, UMEM_NOFAIL);
6256 abd_data = abd_alloc(size, B_FALSE);
6257 abd_meta = abd_alloc(size, B_TRUE);
6258
6259 for (i = 0, ptr = buf; i < size / sizeof (*ptr); i++, ptr++)
6260 *ptr = ztest_random(UINT_MAX);
6261
6262 abd_copy_from_buf_off(abd_data, buf, 0, size);
6263 abd_copy_from_buf_off(abd_meta, buf, 0, size);
6264
6265 VERIFY0(fletcher_4_impl_set("scalar"));
6266 fletcher_4_native(buf, size, NULL, &zc_ref);
6267 fletcher_4_byteswap(buf, size, NULL, &zc_ref_byteswap);
6268
6269 VERIFY0(fletcher_4_impl_set("cycle"));
6270 while (run_count-- > 0) {
6271 zio_cksum_t zc;
6272 zio_cksum_t zc_byteswap;
6273
6274 fletcher_4_byteswap(buf, size, NULL, &zc_byteswap);
6275 fletcher_4_native(buf, size, NULL, &zc);
6276
6277 VERIFY0(bcmp(&zc, &zc_ref, sizeof (zc)));
6278 VERIFY0(bcmp(&zc_byteswap, &zc_ref_byteswap,
6279 sizeof (zc_byteswap)));
6280
6281 /* Test ABD - data */
6282 abd_fletcher_4_byteswap(abd_data, size, NULL,
6283 &zc_byteswap);
6284 abd_fletcher_4_native(abd_data, size, NULL, &zc);
6285
6286 VERIFY0(bcmp(&zc, &zc_ref, sizeof (zc)));
6287 VERIFY0(bcmp(&zc_byteswap, &zc_ref_byteswap,
6288 sizeof (zc_byteswap)));
6289
6290 /* Test ABD - metadata */
6291 abd_fletcher_4_byteswap(abd_meta, size, NULL,
6292 &zc_byteswap);
6293 abd_fletcher_4_native(abd_meta, size, NULL, &zc);
6294
6295 VERIFY0(bcmp(&zc, &zc_ref, sizeof (zc)));

Callers

nothing calls this directly

Calls 13

ztest_random_blocksizeFunction · 0.85
umem_allocFunction · 0.85
abd_allocFunction · 0.85
ztest_randomFunction · 0.85
abd_copy_from_buf_offFunction · 0.85
fletcher_4_impl_setFunction · 0.85
fletcher_4_nativeFunction · 0.85
fletcher_4_byteswapFunction · 0.85
abd_fletcher_4_byteswapFunction · 0.85
abd_fletcher_4_nativeFunction · 0.85
umem_freeFunction · 0.85
abd_freeFunction · 0.85

Tested by

no test coverage detected