summaryrefslogtreecommitdiff
path: root/testapp.c
diff options
context:
space:
mode:
authorAli Saidi <alisaidi@amazon.com>2020-08-19 00:13:28 -0500
committerdormando <dormando@rydia.net>2020-10-27 17:54:21 -0700
commit9bb323ca3447421ee30ef26d1e48896d2d80b742 (patch)
tree85e42574ea1e877881d25ae35cdc1d4f6c754275 /testapp.c
parenteb1bc72b9497e2c0e77d66740dc3053b6855a89a (diff)
downloadmemcached-9bb323ca3447421ee30ef26d1e48896d2d80b742.tar.gz
arm64: Re-add arm crc32c hw acceleration
Use the .arch_extension directive so that a config options and special cflags aren't required. Add a few tests for both the software and hardware implementations
Diffstat (limited to 'testapp.c')
-rw-r--r--testapp.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/testapp.c b/testapp.c
index f8bd493..47cb103 100644
--- a/testapp.c
+++ b/testapp.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "cache.h"
+#include "crc32c.h"
#include "hash.h"
#include "jenkins_hash.h"
#include "stats_prefix.h"
@@ -898,6 +899,34 @@ static enum test_return test_issue_92(void) {
return TEST_PASS;
}
+static enum test_return test_crc32c(void) {
+ uint32_t crc_hw, crc_sw;
+
+ char buffer[256];
+ for (int x = 0; x < 256; x++)
+ buffer[x] = x;
+
+ /* Compare harware to software implementaiton */
+ crc_hw = crc32c(0, buffer, 256);
+ crc_sw = crc32c_sw(0, buffer, 256);
+ assert(crc_hw == 0x9c44184b);
+ assert(crc_sw == 0x9c44184b);
+
+ /* Test that passing a CRC in also works */
+ crc_hw = crc32c(crc_hw, buffer, 256);
+ crc_sw = crc32c_sw(crc_sw, buffer, 256);
+ assert(crc_hw == 0xae10ee5a);
+ assert(crc_sw == 0xae10ee5a);
+
+ /* Test odd offsets/sizes */
+ crc_hw = crc32c(crc_hw, buffer + 1, 256 - 2);
+ crc_sw = crc32c_sw(crc_sw, buffer + 1, 256 - 2);
+ assert(crc_hw == 0xed37b906);
+ assert(crc_sw == 0xed37b906);
+
+ return TEST_PASS;
+}
+
static enum test_return test_issue_102(void) {
char buffer[4096];
memset(buffer, ' ', sizeof(buffer));
@@ -2297,6 +2326,7 @@ struct testcase testcases[] = {
{ "issue_44", test_issue_44 },
{ "vperror", test_vperror },
{ "issue_101", test_issue_101 },
+ { "crc32c", test_crc32c },
/* The following tests all run towards the same server */
{ "start_server", start_memcached_server },
{ "issue_92", test_issue_92 },
@@ -2363,6 +2393,8 @@ int main(int argc, char **argv)
hash = jenkins_hash;
stats_prefix_init(':');
+ crc32c_init();
+
for (num_cases = 0; testcases[num_cases].description; num_cases++) {
/* Just counting */
}