Add media top-level directory for storage medium access components
Introduces the top-level media directory for components concerned
with accessing storage media using well-known formats. Reuses
external source code from TF-A where possible.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I5fa2cb24aa33f019df5108e80ccd78f0170e4c0b
diff --git a/components/common/crc32/test/crc32_test.cpp b/components/common/crc32/test/crc32_test.cpp
new file mode 100644
index 0000000..a21286f
--- /dev/null
+++ b/components/common/crc32/test/crc32_test.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <common/crc32/crc32.h>
+#include <CppUTest/TestHarness.h>
+
+TEST_GROUP(Crc32Tests)
+{
+
+};
+
+/*
+ * Expected results obtained from: https://crc32.online/
+ */
+TEST(Crc32Tests, shortString)
+{
+ const unsigned char test_input[] = "Hello";
+ uint32_t expected_result = 0xf7d18982;
+ uint32_t input_crc = 0;
+
+ uint32_t result = crc32(input_crc, test_input, sizeof(test_input) - 1);
+
+ UNSIGNED_LONGS_EQUAL(expected_result, result);
+}
+
+TEST(Crc32Tests, longString)
+{
+ const unsigned char test_input[] =
+ "The boy stood on the burning deck Whence all but he had fled";
+ uint32_t expected_result = 0x1f11704c;
+ uint32_t input_crc = 0;
+
+ uint32_t result = crc32(input_crc, test_input, sizeof(test_input) - 1);
+
+ UNSIGNED_LONGS_EQUAL(expected_result, result);
+}
+
+TEST(Crc32Tests, multiPart)
+{
+ const unsigned char test_input_1[] =
+ "The boy stood on the burning deck ";
+ const unsigned char test_input_2[] =
+ "Whence all but he had fled";
+
+ uint32_t expected_result = 0x1f11704c;
+ uint32_t result = 0;
+
+ result = crc32(result, test_input_1, sizeof(test_input_1) - 1);
+ result = crc32(result, test_input_2, sizeof(test_input_2) - 1);
+
+ UNSIGNED_LONGS_EQUAL(expected_result, result);
+}
\ No newline at end of file