Skip to content

Commit

Permalink
test-hash: Remove the check_word_hash() for hash_bytes128_cb.
Browse files Browse the repository at this point in the history
The original test fails on big-endian system due to the hash function
performing not as well when input is uint32_t.  In reality, users should
only use hash_bytes128() to hash words larger than 128 bits (e.g. struct
flow).  Besides, we do check the 1-bit set case for 16 128-bit words in
following test case.  Therefore, the cleanest way to fix the failure
in big-endian system seems to be just removing the check_word_hash()
test for hash_bytes128_cb.

Signed-off-by: Alex Wang <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
yew011 committed Feb 27, 2015
1 parent 135fec5 commit 2a638b8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
1 change: 1 addition & 0 deletions lib/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ hash_rot(uint32_t x, int k)
}

uint32_t hash_bytes(const void *, size_t n_bytes, uint32_t basis);
/* The hash input must be a word larger than 128 bits. */
void hash_bytes128(const void *_, size_t n_bytes, uint32_t basis,
ovs_u128 *out);

Expand Down
10 changes: 0 additions & 10 deletions tests/test-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ hash_int_cb(uint32_t input)
return hash_int(input, 0);
}

static uint32_t
hash_bytes128_cb(uint32_t input)
{
ovs_u128 hash;

hash_bytes128(&input, sizeof input, 0, &hash);
return hash.u64.lo;
}

static void
check_word_hash(uint32_t (*hash)(uint32_t), const char *name,
int min_unique)
Expand Down Expand Up @@ -249,7 +240,6 @@ test_hash_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
* function.
*/
check_word_hash(hash_int_cb, "hash_int", 12);
check_word_hash(hash_bytes128_cb, "hash_bytes128", 12);

/* Check that all hashes computed with hash_bytes128 with 1-bit (or no
* 1-bits) set within 16 128-bit words have different values in their
Expand Down

0 comments on commit 2a638b8

Please sign in to comment.