Lines Matching +full:non +full:- +full:overlap +full:- +full:time

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
8 #include <kunit/run-in-irq-context.h>
22 * which does not require cryptographically secure random numbers. A hard-coded
29 random_seed = (random_seed * 25214903917 + 11) & ((1ULL << 48) - 1); in rand32()
77 * Allocate the test buffer using vmalloc() with a page-aligned length in hash_suite_init()
85 return -ENOMEM; in hash_suite_init()
87 test_buf = orig_test_buf + alloc_len - TEST_BUF_LEN; in hash_suite_init()
102 * one-shot instead of incremental), since consistency between different ways of
145 * Test that the hash function produces the same result with a one-shot
159 offset = rand_offset(TEST_BUF_LEN - total_len); in test_hash_incremental_updates()
178 remaining_len -= part_len; in test_hash_incremental_updates()
200 const size_t max_tested_len = TEST_BUF_LEN - sizeof(struct HASH_CTX); in test_hash_buffer_overruns()
202 struct HASH_CTX *guarded_ctx = buf_end - sizeof(*guarded_ctx); in test_hash_buffer_overruns()
212 HASH(buf_end - len, len, hash); in test_hash_buffer_overruns()
214 HASH_UPDATE(&ctx, buf_end - len, len); in test_hash_buffer_overruns()
218 HASH(test_buf, len, buf_end - HASH_SIZE); in test_hash_buffer_overruns()
221 HASH_FINAL(&ctx, buf_end - HASH_SIZE); in test_hash_buffer_overruns()
236 const size_t max_tested_len = TEST_BUF_LEN - HASH_SIZE; in test_hash_overlaps()
244 size_t offset = HASH_SIZE + rand_offset(max_tested_len - len); in test_hash_overlaps()
247 &test_buf[offset + len - HASH_SIZE]; in test_hash_overlaps()
253 "Overlap test 1 failed with len=%zu offset=%zu left_end=%d", in test_hash_overlaps()
256 /* Repeat the above test, but this time use init+update+final */ in test_hash_overlaps()
263 "Overlap test 2 failed with len=%zu offset=%zu left_end=%d", in test_hash_overlaps()
274 "Overlap test 3 failed with len=%zu offset=%zu left_end=%d", in test_hash_overlaps()
290 size_t data_offs1 = rand_offset(TEST_BUF_LEN - len); in test_hash_alignment_consistency()
291 size_t data_offs2 = rand_offset(TEST_BUF_LEN - len); in test_hash_alignment_consistency()
330 * expected hash from @state->expected_hashes. To increase the chance of
336 u32 i = (u32)atomic_inc_return(&state->seqno) % IRQ_TEST_NUM_BUFFERS; in hash_irq_test1_func()
340 return memcmp(actual_hash, state->expected_hashes[i], HASH_SIZE) == 0; in hash_irq_test1_func()
380 for (ctx = &state->ctxs[0]; ctx < &state->ctxs[ARRAY_SIZE(state->ctxs)]; in hash_irq_test2_func()
382 if (atomic_cmpxchg(&ctx->in_use, 0, 1) == 0) in hash_irq_test2_func()
385 if (WARN_ON_ONCE(ctx == &state->ctxs[ARRAY_SIZE(state->ctxs)])) { in hash_irq_test2_func()
393 if (ctx->step == 0) { in hash_irq_test2_func()
395 HASH_INIT(&ctx->hash_ctx); in hash_irq_test2_func()
396 ctx->offset = 0; in hash_irq_test2_func()
397 ctx->step++; in hash_irq_test2_func()
398 } else if (ctx->step < state->num_steps - 1) { in hash_irq_test2_func()
400 HASH_UPDATE(&ctx->hash_ctx, &test_buf[ctx->offset], in hash_irq_test2_func()
401 state->update_lens[ctx->step - 1]); in hash_irq_test2_func()
402 ctx->offset += state->update_lens[ctx->step - 1]; in hash_irq_test2_func()
403 ctx->step++; in hash_irq_test2_func()
408 if (WARN_ON_ONCE(ctx->offset != TEST_BUF_LEN)) in hash_irq_test2_func()
410 HASH_FINAL(&ctx->hash_ctx, actual_hash); in hash_irq_test2_func()
411 if (memcmp(actual_hash, state->expected_hash, HASH_SIZE) != 0) in hash_irq_test2_func()
413 ctx->step = 0; in hash_irq_test2_func()
415 atomic_set_release(&ctx->in_use, 0); in hash_irq_test2_func()
436 HASH(test_buf, TEST_BUF_LEN, state->expected_hash); in test_hash_interrupt_context_2()
443 for (state->num_steps = 0; in test_hash_interrupt_context_2()
444 state->num_steps < ARRAY_SIZE(state->update_lens) - 1 && remaining; in test_hash_interrupt_context_2()
445 state->num_steps++) { in test_hash_interrupt_context_2()
446 state->update_lens[state->num_steps] = in test_hash_interrupt_context_2()
448 remaining -= state->update_lens[state->num_steps]; in test_hash_interrupt_context_2()
451 state->update_lens[state->num_steps++] = remaining; in test_hash_interrupt_context_2()
452 state->num_steps += 2; /* for init and final */ in test_hash_interrupt_context_2()
474 * the underlying unkeyed hash function, which is already well-tested by the
484 * failure would likely be non-input-specific or also show in the unkeyed tests.
548 /* Warm-up */ in benchmark_hash()
554 /* The '+ 128' tries to account for per-message overhead. */ in benchmark_hash()
563 t = ktime_get_ns() - t; in benchmark_hash()