1 + | /*
|
2 + | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
3 + | * SPDX-License-Identifier: Apache-2.0
|
4 + | */
|
5 + |
|
6 + | //! Integration test to verify CRC checksums work correctly across architectures.
|
7 + | //! This test specifically exercises crc-fast to catch issues like the 1.4 SIGILL bug.
|
8 + |
|
9 + | use aws_smithy_checksums::ChecksumAlgorithm;
|
10 + | use bytes::Bytes;
|
11 + |
|
12 + | #[test]
|
13 + | fn test_crc32_checksum() {
|
14 + | let data = Bytes::from_static(b"hello world");
|
15 + | let mut hasher = ChecksumAlgorithm::Crc32.into_impl();
|
16 + | hasher.update(&data);
|
17 + | let checksum = hasher.finalize();
|
18 + |
|
19 + | // Verify we get a valid checksum (not testing exact value, just that it doesn't crash)
|
20 + | assert!(!checksum.is_empty());
|
21 + | }
|
22 + |
|
23 + | #[test]
|
24 + | fn test_crc32c_checksum() {
|
25 + | let data = Bytes::from_static(b"hello world");
|
26 + | let mut hasher = ChecksumAlgorithm::Crc32c.into_impl();
|
27 + | hasher.update(&data);
|
28 + | let checksum = hasher.finalize();
|
29 + |
|
30 + | assert!(!checksum.is_empty());
|
31 + | }
|
32 + |
|
33 + | #[test]
|
34 + | fn test_crc64_checksum() {
|
35 + | let data = Bytes::from_static(b"hello world");
|
36 + | let mut hasher = ChecksumAlgorithm::Crc64Nvme.into_impl();
|
37 + | hasher.update(&data);
|
38 + | let checksum = hasher.finalize();
|
39 + |
|
40 + | assert!(!checksum.is_empty());
|
41 + | }
|
42 + |
|
43 + | #[test]
|
44 + | fn test_large_data_crc32() {
|
45 + | // Test with larger data to ensure AVX-512 code paths are exercised
|
46 + | let data = vec![0u8; 1024 * 1024]; // 1MB
|
47 + | let data = Bytes::from(data);
|
48 + | let mut hasher = ChecksumAlgorithm::Crc32.into_impl();
|
49 + | hasher.update(&data);
|
50 + | let checksum = hasher.finalize();
|
51 + |
|
52 + | assert!(!checksum.is_empty());
|
53 + | }
|
54 + |
|
55 + | #[test]
|
56 + | fn test_large_data_crc64() {
|
57 + | // Test with larger data to ensure AVX-512 code paths are exercised
|
58 + | let data = vec![0u8; 1024 * 1024]; // 1MB
|
59 + | let data = Bytes::from(data);
|
60 + | let mut hasher = ChecksumAlgorithm::Crc64Nvme.into_impl();
|
61 + | hasher.update(&data);
|
62 + | let checksum = hasher.finalize();
|
63 + |
|
64 + | assert!(!checksum.is_empty());
|
65 + | }
|