Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (C) 2017 Intel Corporation. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #include "spdk/stdinc.h" 7 : : 8 : : #include "spdk_internal/cunit.h" 9 : : 10 : : #include "util/crc32.c" 11 : : #include "util/crc32_ieee.c" 12 : : 13 : : static void 14 : 2 : test_crc32_ieee(void) 15 : : { 16 : : uint32_t crc; 17 : 2 : char buf[] = "Hello world!"; 18 : : 19 : 2 : crc = 0xFFFFFFFFu; 20 : 2 : crc = spdk_crc32_ieee_update(buf, strlen(buf), crc); 21 : 2 : crc ^= 0xFFFFFFFFu; 22 : 2 : CU_ASSERT(crc == 0x1b851995); 23 : 2 : } 24 : : 25 : : int 26 : 2 : main(int argc, char **argv) 27 : : { 28 : 2 : CU_pSuite suite = NULL; 29 : : unsigned int num_failures; 30 : : 31 : 2 : CU_initialize_registry(); 32 : : 33 : 2 : suite = CU_add_suite("crc32_ieee", NULL, NULL); 34 : : 35 : 2 : CU_ADD_TEST(suite, test_crc32_ieee); 36 : : 37 : : 38 : 2 : num_failures = spdk_ut_run_tests(argc, argv, NULL); 39 : : 40 : 2 : CU_cleanup_registry(); 41 : : 42 : 2 : return num_failures; 43 : : }