[Skiboot] [PATCH 4/8] core/pldm/test : Add self test for lid read

ABHISHEK SINGH TOMAR abhishek.singh.tomar1 at ibm.com
Thu Feb 20 20:34:51 AEDT 2025


From: Abhishek Singh Tomar <abhishek at linux.ibm.com>

Introduce self test for PLDM lid read implementation.
lid read is used to read NVRAM, Skiroot, kernel etc

Signed-off-by: Abhishek Singh Tomar <abhishek at linux.ibm.com>
---
 core/pldm/test/test-pldm-common.c      |  1 +
 core/pldm/test/test-pldm-fileio-bios.c | 68 ++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/core/pldm/test/test-pldm-common.c b/core/pldm/test/test-pldm-common.c
index 856b9a672..fe23f738e 100644
--- a/core/pldm/test/test-pldm-common.c
+++ b/core/pldm/test/test-pldm-common.c
@@ -44,6 +44,7 @@ static inline unsigned long mftb(void);
 #include <libmctp/libmctp-astlpc.h>
 #undef pr_fmt
 #include "../pldm-bios-requests.c"
+#include "../pldm-lid-files.c"
 #include <pldm/libpldm/base.c>
 #include <pldm/libpldm/pdr.c>
 #include <pldm/libpldm/bios.c>
diff --git a/core/pldm/test/test-pldm-fileio-bios.c b/core/pldm/test/test-pldm-fileio-bios.c
index 5dcb85572..78e462afa 100644
--- a/core/pldm/test/test-pldm-fileio-bios.c
+++ b/core/pldm/test/test-pldm-fileio-bios.c
@@ -31,6 +31,7 @@ enum bios_special_case_code bios_special_case = NORMAL_CASE;
 enum pldm_completion_codes special_reply;
 
 
+struct blocklevel_device *bl;
 void *pldm_file_io_buff[TEST_FILE_IO_LENGTH];
 
 /*
@@ -832,6 +833,69 @@ int test_pldm_bios_find_lid_by_invalid_attr_name(void)
 	return OPAL_SUCCESS;
 }
 
+int test_pldm_lid_files_init(void)
+{
+	int rc;
+
+	rc = pldm_lid_files_init(&bl);
+	if (rc  != OPAL_SUCCESS) {
+		printf("PLDM_TEST: %s failed :: rc = %d exp %d\n", __func__, rc, OPAL_SUCCESS);
+		return OPAL_PARAMETER;
+
+	}
+	return OPAL_SUCCESS;
+}
+
+int test_pldm_read_invalid_lid(void)
+{
+	int rc;
+	char buff[100] = {'\0'};
+
+	rc = bl->read(bl, VMM_SIZE_RESERVED_PER_SECTION * 5, buff, 20);
+	if (rc  != OPAL_PARAMETER) {
+		printf("PLDM_TEST: %s failed :: rc = %d exp %d\n", __func__, rc, OPAL_PARAMETER);
+		return OPAL_PARAMETER;
+
+	}
+	return OPAL_SUCCESS;
+}
+
+int test_pldm_read_valid_lid_size_greter_than_file_size(void)
+{
+	int rc;
+	char buff[100] = {'\0'};
+
+	rc = bl->read(bl, VMM_SIZE_RESERVED_PER_SECTION * 3, buff, 100);
+	if (rc  != OPAL_PARAMETER) {
+		printf("PLDM_TEST: %s failed :: rc = %d exp %d\n", __func__, rc, OPAL_PARAMETER);
+		return OPAL_PARAMETER;
+
+	}
+	return OPAL_SUCCESS;
+}
+
+int test_pldm_read_valid_lid_size(void)
+{
+	int rc;
+	char buff[100] = {'\0'};
+	int size = 20;
+
+	rc = bl->read(bl, VMM_SIZE_RESERVED_PER_SECTION * 3,
+			buff, size);
+	if (rc  != OPAL_SUCCESS) {
+		printf("PLDM_TEST: %s failed :: rc = %d exp %d\n", __func__, rc, OPAL_SUCCESS);
+		return OPAL_PARAMETER;
+
+	}
+
+	/* Test if buffer read is correct */
+	if (strncmp(buff, TEST_FILE_IO_BUF1, size) != 0) {
+		printf("PLDM_TEST: %s failed :: pldm read string mismatch\n", __func__);
+		return OPAL_PARAMETER;
+	}
+	return OPAL_SUCCESS;
+}
+
 
 struct test_case {
 	const char *name;
@@ -857,6 +921,10 @@ struct test_case test_cases[] = {
 	TEST_CASE(test_init_pldm_bios_error_value_table),
 	TEST_CASE(test_init_pldm_bios),
 	TEST_CASE(test_pldm_bios_find_lid_by_invalid_attr_name),
+	TEST_CASE(test_pldm_lid_files_init),
+	TEST_CASE(test_pldm_read_invalid_lid),
+	TEST_CASE(test_pldm_read_valid_lid_size_greter_than_file_size),
+	TEST_CASE(test_pldm_read_valid_lid_size),
 	{NULL, NULL}
 };
 
-- 
2.48.1



More information about the Skiboot mailing list