test/vsock: rework message bounds test
[linux-2.6-block.git] / tools / testing / vsock / util.c
index 2acbb7703c6a08881bd04431cefcc9945835c76e..01b636d3039a04b2be61a5785513b0bae45d3916 100644 (file)
@@ -395,3 +395,16 @@ void skip_test(struct test_case *test_cases, size_t test_cases_len,
 
        test_cases[test_id].skip = true;
 }
+
+unsigned long hash_djb2(const void *data, size_t len)
+{
+       unsigned long hash = 5381;
+       int i = 0;
+
+       while (i < len) {
+               hash = ((hash << 5) + hash) + ((unsigned char *)data)[i];
+               i++;
+       }
+
+       return hash;
+}