libpldm: Reorganize source and test files
Primarily this is about moving specification-specific files into
'dsp/' (in the "DMTF Standard Publication" sense[1]) subdirectories of
both src/ and tests/.
[1]: https://www.dmtf.org/sites/default/files/standards/documents/DSP4014_2.14.0.pdf
libpldm is a concrete C implementation of the PLDM family of
specifications. This invokes some accidental complexity[2] such as the
msgbuf APIs and other concerns.
[2]: https://en.wikipedia.org/wiki/No_Silver_Bullet
Separate the essential complexity (everything under the dsp/
subdirectories) from the accidental complexity (almost everything else).
While doing so, I took the opportunity to drop the 'libpldm_' prefix
and '_test' suffix from a variety of tests. The 'libpldm_' prefix is a
hangover from the days when libpldm was a subproject of OpenBMC's pldm
repo. The '_test' suffix feels redundant given the parent directory
path.
Note that we maintain separation of the src/ and tests/. The test suite
is implemented in C++ while libpldm's APIs are declared and defined in
C. The ability to chop all the tests and C++ out of the implementation
by ignoring a subtree seems like a desirable property when vendoring the
library into other projects.
Finally, update the x86_64 GCC ABI dump, as rearranging the source
causes a lot of churn in its definitions.
Change-Id: Icffcc6cf48b3101ecd38168827c0a81cffb8f083
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/tests/dsp/bios_table_iter.c b/tests/dsp/bios_table_iter.c
new file mode 100644
index 0000000..5e187b4
--- /dev/null
+++ b/tests/dsp/bios_table_iter.c
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
+/* Force elision of assert() */
+#ifndef NDEBUG
+#define NDEBUG
+#endif
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+/* NOLINTNEXTLINE(bugprone-suspicious-include) */
+#include "dsp/bios_table.c"
+
+/* Satisfy the symbol needs of bios_table.c */
+uint32_t crc32(const void* data __attribute__((unused)),
+ size_t size __attribute__((unused)))
+{
+ return 0;
+}
+
+/* This is the non-death version of TEST(Iterator, DeathTest) */
+int main(void)
+{
+ struct pldm_bios_attr_table_entry entries[2] = {0};
+ struct pldm_bios_table_iter* iter;
+ int result;
+
+ static_assert(2 * sizeof(entries[0]) == sizeof(entries), "");
+
+ entries[0].attr_type = PLDM_BIOS_PASSWORD;
+ entries[1].attr_type = PLDM_BIOS_STRING_READ_ONLY;
+
+ iter = pldm_bios_table_iter_create(entries, sizeof(entries),
+ PLDM_BIOS_ATTR_TABLE);
+
+ /*
+ * We expect the test configuration to claim the iterator has reached the
+ * end beause the there's no entry length descriptor for the
+ * PLDM_BIOS_PASSWORD entry type. By the attr_able_entry_length()
+ * implementation this would normally trigger an assert() to uphold that the
+ * necessary pointers are not NULL. However, we've defined NDEBUG above and
+ * so the assert() is elided. That should force us down the path of the
+ * early-exit, which should in-turn yield a `true` result from
+ * pldm_bios_table_iter_is_end() to prevent further attempts to access
+ * invalid objects.
+ */
+ result = pldm_bios_table_iter_is_end(iter) ? EXIT_SUCCESS : EXIT_FAILURE;
+
+ pldm_bios_table_iter_free(iter);
+
+ exit(result);
+
+ return 0;
+}