[Pdbg] [RFC PATCH 08/11] SQ: tests: Convert the test to use device trees
Amitay Isaacs
amitay at ozlabs.org
Tue Nov 12 13:12:48 AEDT 2019
And also fix the compile flags.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
Makefile.am | 8 +-
src/tests/libpdbg_p9_fapi_translation_test.C | 164 +++++++++----------
2 files changed, 79 insertions(+), 93 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 45787b3..5ab64e5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,12 +12,12 @@ GIT_SHA1 ?= `git --work-tree=$(top_srcdir) --git-dir=$(top_srcdir)/.git describe
libpdbg_tests = libpdbg_target_test \
libpdbg_probe_test1 \
libpdbg_probe_test2 \
- libpdbg_probe_test3 \
- libpdbg_p9_fapi_translation_test
+ libpdbg_probe_test3
bin_PROGRAMS = pdbg
check_PROGRAMS = $(libpdbg_tests) libpdbg_dtree_test \
- optcmd_test hexdump_test cronus_proxy
+ libpdbg_p9_fapi_translation_test \
+ optcmd_test hexdump_test cronus_proxy
PDBG_TESTS = \
tests/test_selection.sh \
@@ -259,7 +259,7 @@ libpdbg_dtree_test_LDADD = $(libpdbg_test_ldadd)
libpdbg_p9_fapi_translation_test_SOURCES = src/tests/libpdbg_p9_fapi_translation_test.C \
src/tests/p9_scominfo.C
-libpdbg_p9_fapi_translation_test_CFLAGS = $(libpdbg_test_cflags)
+libpdbg_p9_fapi_translation_test_CXXFLAGS = $(libpdbg_test_cflags)
libpdbg_p9_fapi_translation_test_LDFLAGS = $(libpdbg_test_ldflags)
libpdbg_p9_fapi_translation_test_LDADD = $(libpdbg_test_ldadd)
diff --git a/src/tests/libpdbg_p9_fapi_translation_test.C b/src/tests/libpdbg_p9_fapi_translation_test.C
index 0b2d23b..54e8c99 100644
--- a/src/tests/libpdbg_p9_fapi_translation_test.C
+++ b/src/tests/libpdbg_p9_fapi_translation_test.C
@@ -9,34 +9,10 @@
#include "p9_scominfo.H"
-#define MAX_INDEX 30
+#include "p9-kernel.dt.h"
+#include "p9.dt.h"
-extern struct hw_unit_info p9_core_hw_unit;
-extern struct hw_unit_info p9_ex_hw_unit;
-extern struct hw_unit_info p9_mba_hw_unit;
-extern struct hw_unit_info p9_mcs_hw_unit;
-extern struct hw_unit_info p9_xbus_hw_unit;
-extern struct hw_unit_info p9_abus_hw_unit;
-extern struct hw_unit_info p9_l4_hw_unit;
-extern struct hw_unit_info p9_eq_hw_unit;
-extern struct hw_unit_info p9_mca_hw_unit;
-extern struct hw_unit_info p9_mcbist_hw_unit;
-extern struct hw_unit_info p9_mi_hw_unit;
-extern struct hw_unit_info p9_dmi_hw_unit;
-extern struct hw_unit_info p9_obus_hw_unit;
-extern struct hw_unit_info p9_obus_brick_hw_unit;
-extern struct hw_unit_info p9_sbe_hw_unit;
-extern struct hw_unit_info p9_ppe_hw_unit;
-extern struct hw_unit_info p9_pec_hw_unit;
-extern struct hw_unit_info p9_phb_hw_unit;
-extern struct hw_unit_info p9_mc_hw_unit;
-extern struct hw_unit_info p9_mem_port_hw_unit;
-extern struct hw_unit_info p9_nmmu_hw_unit;
-extern struct hw_unit_info p9_pau_hw_unit;
-extern struct hw_unit_info p9_iohs_hw_unit;
-extern struct hw_unit_info p9_fc_hw_unit;
-extern struct hw_unit_info p9_pauc_hw_unit;
-extern struct hw_unit_info p9_chiplet_hw_unit;
+#define MAX_INDEX 30
int test_unit_translation(struct pdbg_target *target, p9ChipUnits_t cu, int index, uint64_t addr)
{
@@ -59,68 +35,78 @@ int test_unit_translation(struct pdbg_target *target, p9ChipUnits_t cu, int inde
return pdbg_addr == fapi_addr;
}
-int main(void)
+static struct chip_unit {
+ p9ChipUnits_t cu;
+ const char *classname;
+} chip_unit[] = {
+ { P9C_CHIP, "" },
+ { P9N_CHIP, "" },
+ { P9A_CHIP, "" },
+ { PU_C_CHIPUNIT, "core" },
+ { PU_EQ_CHIPUNIT, "eq" },
+ { PU_EX_CHIPUNIT, "ex" },
+ { PU_XBUS_CHIPUNIT, "xbus" },
+ { PU_OBUS_CHIPUNIT, "obus" },
+ { PU_NV_CHIPUNIT, "nv" },
+ { PU_PEC_CHIPUNIT, "pec" },
+ { PU_PHB_CHIPUNIT, "phb" },
+ { PU_MI_CHIPUNIT, "mi" },
+ { PU_DMI_CHIPUNIT, "dmi" },
+ { PU_MCC_CHIPUNIT, "mcc" },
+ { PU_OMIC_CHIPUNIT, "omic" },
+ { PU_OMI_CHIPUNIT, "omi" },
+ { PU_MCS_CHIPUNIT, "mcs" },
+ { PU_MCA_CHIPUNIT, "mca" },
+ { PU_MCBIST_CHIPUNIT, "mcbist" },
+ { PU_PERV_CHIPUNIT, "chiplet" },
+ { PU_PPE_CHIPUNIT, "ppe" },
+ { PU_SBE_CHIPUNIT, "sbe" },
+ { PU_CAPP_CHIPUNIT, "capp" },
+ { PU_MC_CHIPUNIT, "mc" },
+ { NONE, NULL },
+};
+
+int main(int argc, const char **argv)
{
- uint64_t addr;
- int i, index;
- struct pdbg_target *p9_cu[NONE] = {0};
-
- pdbg_set_logfunc(NULL);
-
- p9_cu[PU_C_CHIPUNIT] = (struct pdbg_target *) p9_core_hw_unit.hw_unit;
- p9_cu[PU_EQ_CHIPUNIT] = (struct pdbg_target *) p9_eq_hw_unit.hw_unit;
- p9_cu[PU_EX_CHIPUNIT] = (struct pdbg_target *) p9_ex_hw_unit.hw_unit;
- p9_cu[PU_XBUS_CHIPUNIT] = (struct pdbg_target *) p9_xbus_hw_unit.hw_unit;
- p9_cu[PU_OBUS_CHIPUNIT] = (struct pdbg_target *) p9_obus_hw_unit.hw_unit;
- p9_cu[PU_PEC_CHIPUNIT] = (struct pdbg_target *) p9_pec_hw_unit.hw_unit;
- p9_cu[PU_PHB_CHIPUNIT] = (struct pdbg_target *) p9_phb_hw_unit.hw_unit;
- p9_cu[PU_MI_CHIPUNIT] = (struct pdbg_target *) p9_mi_hw_unit.hw_unit;
- p9_cu[PU_DMI_CHIPUNIT] = (struct pdbg_target *) p9_dmi_hw_unit.hw_unit;
- p9_cu[PU_MCS_CHIPUNIT] = (struct pdbg_target *) p9_mcs_hw_unit.hw_unit;
- p9_cu[PU_MCA_CHIPUNIT] = (struct pdbg_target *) p9_mca_hw_unit.hw_unit;
- p9_cu[PU_MCBIST_CHIPUNIT] = (struct pdbg_target *) p9_mcbist_hw_unit.hw_unit;
- p9_cu[PU_PERV_CHIPUNIT] = (struct pdbg_target *) p9_chiplet_hw_unit.hw_unit;
- p9_cu[PU_PPE_CHIPUNIT] = (struct pdbg_target *) p9_ppe_hw_unit.hw_unit;
- p9_cu[PU_SBE_CHIPUNIT] = (struct pdbg_target *) p9_sbe_hw_unit.hw_unit;
- p9_cu[PU_MC_CHIPUNIT] = (struct pdbg_target *) p9_mc_hw_unit.hw_unit;
-
-
- /* Need to initialise the dn_name so pdbg_target_path doesn't segfault */
- ((struct pdbg_target *) p9_core_hw_unit.hw_unit)->dn_name = "p9_core";
- ((struct pdbg_target *) p9_chiplet_hw_unit.hw_unit)->dn_name = "p9_chiplet";
- ((struct pdbg_target *) p9_ex_hw_unit.hw_unit)->dn_name = "p9_ex";
- ((struct pdbg_target *) p9_mba_hw_unit.hw_unit)->dn_name = "p9_mba";
- ((struct pdbg_target *) p9_mcs_hw_unit.hw_unit)->dn_name = "p9_mcs";
- ((struct pdbg_target *) p9_xbus_hw_unit.hw_unit)->dn_name = "p9_xbus";
- ((struct pdbg_target *) p9_abus_hw_unit.hw_unit)->dn_name = "p9_abus";
- ((struct pdbg_target *) p9_l4_hw_unit.hw_unit)->dn_name = "p9_l4";
- ((struct pdbg_target *) p9_eq_hw_unit.hw_unit)->dn_name = "p9_eq";
- ((struct pdbg_target *) p9_mca_hw_unit.hw_unit)->dn_name = "p9_mca";
- ((struct pdbg_target *) p9_mcbist_hw_unit.hw_unit)->dn_name = "p9_mcbist";
- ((struct pdbg_target *) p9_mi_hw_unit.hw_unit)->dn_name = "p9_mi";
- ((struct pdbg_target *) p9_dmi_hw_unit.hw_unit)->dn_name = "p9_dmi";
- ((struct pdbg_target *) p9_obus_hw_unit.hw_unit)->dn_name = "p9_obus";
- ((struct pdbg_target *) p9_obus_brick_hw_unit.hw_unit)->dn_name = "p9_obus_brick";
- ((struct pdbg_target *) p9_sbe_hw_unit.hw_unit)->dn_name = "p9_sbe";
- ((struct pdbg_target *) p9_ppe_hw_unit.hw_unit)->dn_name = "p9_ppe";
- ((struct pdbg_target *) p9_pec_hw_unit.hw_unit)->dn_name = "p9_pec";
- ((struct pdbg_target *) p9_phb_hw_unit.hw_unit)->dn_name = "p9_phb";
- ((struct pdbg_target *) p9_mc_hw_unit.hw_unit)->dn_name = "p9_mc";
- ((struct pdbg_target *) p9_mem_port_hw_unit.hw_unit)->dn_name = "p9_mem_port";
- ((struct pdbg_target *) p9_nmmu_hw_unit.hw_unit)->dn_name = "p9_nmmu";
- ((struct pdbg_target *) p9_pau_hw_unit.hw_unit)->dn_name = "p9_pau";
- ((struct pdbg_target *) p9_iohs_hw_unit.hw_unit)->dn_name = "p9_iohs";
- ((struct pdbg_target *) p9_fc_hw_unit.hw_unit)->dn_name = "p9_fc";
- ((struct pdbg_target *) p9_pauc_hw_unit.hw_unit)->dn_name = "p9_pauc";
-
- for (i = 0; i < NONE; i++) {
- if (p9_cu[i])
- for (index = 0; index < MAX_INDEX; index++) {
- printf("Testing %s@%d\n", pdbg_target_path(p9_cu[i]), index);
-
- /* Test every sat offset */
- for (addr = 0; addr < 0xffffffff; addr += 0x40)
- assert(test_unit_translation(p9_cu[i], (p9ChipUnits_t) i, index, addr));
- }
+ struct pdbg_target *target;
+ p9ChipUnits_t cu = NONE;
+ int i, count=0;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <class>\n", argv[0]);
+ return 1;
+ }
+
+ // pdbg_set_logfunc(NULL);
+
+ pdbg_targets_init(NULL);
+
+ for (i=0; chip_unit[i].classname; i++) {
+ if (!strcmp(argv[1], chip_unit[i].classname)) {
+ cu = chip_unit[i].cu;
+ }
+ }
+
+ if (cu == NONE) {
+ fprintf(stderr, "Unknown class '%s'\n", argv[1]);
+ return 1;
}
+
+ pdbg_for_each_class_target(argv[1], target) {
+ uint64_t addr;
+ int index = pdbg_target_index(target);
+
+ printf("Testing %s %d\n", pdbg_target_path(target), index);
+ /* Test every sat offset */
+ for (addr = 0; addr < 0xffffffff; addr += 0x40)
+ assert(test_unit_translation(target, cu, index, addr));
+
+ count++;
+ }
+
+ if (count == 0) {
+ printf("Test skipped for class '%s'\n", argv[1]);
+ }
+
+ return 0;
}
--
2.21.0
More information about the Pdbg
mailing list