Merging upstream version 0.7.1 (Closes: #991419).
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
05c588e9d7
commit
9e09e0ef69
99 changed files with 6727 additions and 943 deletions
41
regressions/ck_ec/validate/prop_test_timeutil_scale.c
Normal file
41
regressions/ck_ec/validate/prop_test_timeutil_scale.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "../../../src/ck_ec_timeutil.h"
|
||||
#include "fuzz_harness.h"
|
||||
|
||||
struct example {
|
||||
uint32_t nsec;
|
||||
uint32_t multiplier;
|
||||
unsigned int shift;
|
||||
};
|
||||
|
||||
static const struct example examples[] = {
|
||||
{
|
||||
UINT32_MAX,
|
||||
UINT32_MAX,
|
||||
1
|
||||
},
|
||||
{
|
||||
10,
|
||||
20,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
static inline int test_wait_time_scale(const struct example *example)
|
||||
{
|
||||
const uint32_t nsec = example->nsec;
|
||||
const uint32_t multiplier = example->multiplier;
|
||||
const unsigned int shift = example->shift % 32;
|
||||
uint32_t actual = wait_time_scale(nsec, multiplier, shift);
|
||||
uint64_t expected = ((uint64_t)nsec * multiplier) >> shift;
|
||||
|
||||
if (expected > UINT32_MAX) {
|
||||
expected = UINT32_MAX;
|
||||
}
|
||||
|
||||
assert(actual == expected);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST(test_wait_time_scale, examples)
|
Loading…
Add table
Add a link
Reference in a new issue