diff options
author | Mike Jones <mjjones@us.ibm.com> | 2011-09-07 10:20:10 -0500 |
---|---|---|
committer | MIKE J. JONES <mjjones@us.ibm.com> | 2011-09-08 15:02:32 -0500 |
commit | d2f4ff53fa03875d7d5df7e42df71d6294622762 (patch) | |
tree | 9ad24ed7e59afe3098dea19890d71abddd523d5d /src/usr/hwpf/hwp/fapiTestHwpAttr.C | |
parent | 1a9fe61084b58fe8e56e92c5983704751b3bf536 (diff) | |
download | talos-hostboot-d2f4ff53fa03875d7d5df7e42df71d6294622762.tar.gz talos-hostboot-d2f4ff53fa03875d7d5df7e42df71d6294622762.zip |
HWPF: Attribute Simplification
Change-Id: I84553317e8b21c3f538c787e43c4482f3e1944f0
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/327
Tested-by: Jenkins Server
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/hwp/fapiTestHwpAttr.C')
-rwxr-xr-x | src/usr/hwpf/hwp/fapiTestHwpAttr.C | 793 |
1 files changed, 630 insertions, 163 deletions
diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C index a8590efbd..6cf43ee6a 100755 --- a/src/usr/hwpf/hwp/fapiTestHwpAttr.C +++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C @@ -23,7 +23,7 @@ /** * @file fapiTestHwpAttr.C * - * @brief Implements the test Hardware Procedure that exercises the test + * @brief Implements the test Hardware Procedure that exercises the scratch * attributes */ @@ -32,6 +32,7 @@ * Flag Defect/Feature User Date Description * ------ -------------- ---------- ----------- ---------------------------- * mjjones 06/30/2011 Created. + * mjjones 09/07/2011 Update to test scratch attrs * */ @@ -45,49 +46,51 @@ extern "C" //****************************************************************************** fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) { - // Attempt to call the attribute get/set functions for the test attributes + FAPI_INF("Performing HWP: hwpTestAttributes"); + + // Attempt to call the attribute get/set macros for the scratch attributes fapi::ReturnCode l_rc; - // Test getting and setting the test attributes do { //---------------------------------------------------------------------- - // Test ATTR_TEST_UINT8 (DefaultVal 6) + // Test ATTR_SCRATCH_UINT8_1 //---------------------------------------------------------------------- - uint8_t l_uint8 = 0; + { + uint8_t l_uint8 = 1; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_uint8); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from GET"); break; } // Check value - if (l_uint8 != 6) + if (l_uint8 != 0) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. GET returned %d", + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. GET returned %d", l_uint8); break; } // Test set l_uint8 = 7; - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, NULL, l_uint8); + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from SET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from SET"); break; } // Test get l_uint8 = 8; - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_uint8); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from GET (2)"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from GET (2)"); break; } @@ -95,104 +98,259 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) if (l_uint8 != 7) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. GET returned %d (2)", + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. GET returned %d (2)", l_uint8); break; } + // Set to zero + l_uint8 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from SET (2)"); + break; + } + } + //---------------------------------------------------------------------- - // Test ATTR_TEST_UINT32 (PLAT (sets val to 3). RO) + // Test ATTR_SCRATCH_UINT8_2 //---------------------------------------------------------------------- - uint32_t l_uint32 = 0; + { + uint8_t l_uint8 = 8; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, NULL, l_uint32); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_2, NULL, l_uint8); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. Error from GET"); break; } // Check value - if (l_uint32 != 3) + if (l_uint8 != 0) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32. GET returned %d", + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. GET returned %d", + l_uint8); + break; + } + + // Set to zero + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_2, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. Error from SET"); + break; + } + } + + //---------------------------------------------------------------------- + // Test ATTR_SCRATCH_UINT32_1 + //---------------------------------------------------------------------- + { + uint32_t l_uint32 = 1; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from GET"); + break; + } + + // Check value + if (l_uint32 != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. GET returned %d", l_uint32); break; } - // Cannot set read-only attribute + // Test set + l_uint32 = 7; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from SET"); + break; + } + + // Test get + l_uint32 = 8; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from GET (2)"); + break; + } + + // Check value + if (l_uint32 != 7) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. GET returned %d (2)", + l_uint32); + break; + } + + // Set to zero + l_uint32 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from SET (2)"); + break; + } + } + + //---------------------------------------------------------------------- + // Test ATTR_SCRATCH_UINT32_2 + //---------------------------------------------------------------------- + { + uint32_t l_uint32 = 1; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_2, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. Error from GET"); + break; + } + + // Check value + if (l_uint32 != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. GET returned %d", + l_uint32); + break; + } + + // Set to zero + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_2, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. Error from SET"); + break; + } + } //---------------------------------------------------------------------- - // Test ATTR_TEST_UINT64 (Enum. DefaultVal VALB) + // Test ATTR_SCRATCH_UINT64_1 //---------------------------------------------------------------------- - uint64_t l_uint64 = 0; + { + uint64_t l_uint64 = 1; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from GET"); break; } // Check value - if (l_uint64 != fapi::ATTR_TEST_UINT64_VALB) + if (l_uint64 != 0) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. GET returned %d", + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. GET returned %d", static_cast<uint32_t>(l_uint64)); break; } // Test set - l_uint64 = fapi::ATTR_TEST_UINT64_VALA; - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, l_uint64); + l_uint64 = 7; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from SET"); + break; + } + + // Test get + l_uint64 = 8; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from GET (2)"); + break; + } + + // Check value + if (l_uint64 != 7) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. GET returned %d (2)", + static_cast<uint32_t>(l_uint64)); + break; + } + + // Set to zero + l_uint64 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from SET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from SET (2)"); break; } + } + + //---------------------------------------------------------------------- + // Test ATTR_SCRATCH_UINT64_2 + //---------------------------------------------------------------------- + { + uint64_t l_uint64 = 1; // Test get - l_uint64 = fapi::ATTR_TEST_UINT64_VALC; - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from GET (2)"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from GET"); break; } - if (l_uint64 != fapi::ATTR_TEST_UINT64_VALA) + // Check value + if (l_uint64 != 0) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. GET returned %d (2)", + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. GET returned %d", static_cast<uint32_t>(l_uint64)); break; } + // Set to zero + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from SET"); + break; + } + } + //---------------------------------------------------------------------- - // Test ATTR_TEST_UINT8_ARRAY ([3], DefaultVal 2) + // Test ATTR_SCRATCH_UINT8_ARRAY_1 //---------------------------------------------------------------------- - uint8_t l_uint8Array[3]; + { + uint8_t l_uint8array1[32]; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from GET"); break; } - // Check values - for (uint32_t i = 0; i < 3; i++) + // Check value + for (uint32_t i = 0; i < 32; i++) { - if (l_uint8Array[i] != 2) + if (l_uint8array1[i] != 0) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY GET " - "returned %d in index %d", l_uint8Array[i], i); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY1. GET [%d] returned %d", + i, l_uint8array1[i]); break; } } @@ -203,36 +361,39 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) } // Test set - l_uint8Array[0] = 0; - l_uint8Array[1] = 1; - l_uint8Array[2] = 2; + for (uint32_t i = 0; i < 32; i++) + { + l_uint8array1[i] = i + 1; + } - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from SET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from SET"); break; } // Test get - l_uint8Array[0] = 6; - l_uint8Array[1] = 7; - l_uint8Array[2] = 8; - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + for (uint32_t i = 0; i < 32; i++) + { + l_uint8array1[i] = 0; + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from GET (2)"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from GET (2)"); break; } - // Check values - for (uint32_t i = 0; i < 3; i++) + // Check value + for (uint32_t i = 0; i < 32; i++) { - if (l_uint8Array[i] != i) + if (l_uint8array1[i] != (i + 1)) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. GET " - "returned %d in index %d", l_uint8Array[i], i); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY1. GET [%d] returned %d (2)", + i, l_uint8array1[i]); break; } } @@ -242,42 +403,55 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) break; } + // Set to zero + for (uint32_t i = 0; i < 32; i++) + { + l_uint8array1[i] = 0; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from SET (2)"); + break; + } + } + //---------------------------------------------------------------------- - // Test ATTR_TEST_UINT32_ARRAY ([2][3][4], DefaultVal 8) + // Test ATTR_SCRATCH_UINT8_ARRAY_2 //---------------------------------------------------------------------- - uint32_t l_uint32Array[2][3][4]; + { + uint8_t l_uint8 = 1; + uint8_t l_uint8array2[2][3][4]; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from GET"); break; } - // Check values + // Check value for (uint32_t i = 0; i < 2; i++) { for (uint32_t j = 0; j < 3; j++) { for (uint32_t k = 0; k < 4; k++) { - if (l_uint32Array[i][j][k] != 8) + if (l_uint8array2[i][j][k] != 0) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. " - "GET returned %d in index %d:%d:%d", - l_uint32Array[i][j][j], i, j, k); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY2. GET [%d:%d:%d] returned %d", + i, j, k, l_uint8array2[i][j][k]); break; } } - if (l_rc) { break; } } - if (l_rc) { break; @@ -290,22 +464,22 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) } // Test set - uint32_t l_val = 0; + l_uint8 = 1; for (uint32_t i = 0; i < 2; i++) { for (uint32_t j = 0; j < 3; j++) { for (uint32_t k = 0; k < 4; k++) { - l_uint32Array[i][j][k] = l_val++; + l_uint8array2[i][j][k] = l_uint8++; } } } - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. Error from SET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from SET"); break; } @@ -316,43 +490,39 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) { for (uint32_t k = 0; k < 4; k++) { - l_uint32Array[i][j][k] = 32; + l_uint8array2[i][j][k] = 0; } } } - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); if (l_rc) { - FAPI_ERR("hwpTestAttributes: Error from GET uint32 array (2)"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from GET (2)"); break; } - // Check values - l_val = 0; + // Check value + l_uint8 = 1; for (uint32_t i = 0; i < 2; i++) { for (uint32_t j = 0; j < 3; j++) { for (uint32_t k = 0; k < 4; k++) { - if (l_uint32Array[i][j][k] != l_val) + if (l_uint8array2[i][j][k] != l_uint8++) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. " - "GET returned %d in index %d:%d:%d (2)", - l_uint32Array[i][j][j], i, j, k); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY2. GET [%d:%d:%d] returned %d", + i, j, k, l_uint8array2[i][j][k]); break; } - l_val++; } - if (l_rc) { break; } } - if (l_rc) { break; @@ -364,28 +534,91 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) break; } + // Set to zero + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + l_uint8array2[i][j][k] = 0; + } + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from SET (2)"); + break; + } + } + //---------------------------------------------------------------------- - // Test ATTR_TEST_UINT64_ARRAY ([5]. PLAT (sets vals to 4). RO) + // Test ATTR_SCRATCH_UINT32_ARRAY_1 //---------------------------------------------------------------------- - uint64_t l_uint64Array[5]; + { + uint32_t l_uint32array1[8]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from GET"); + break; + } + + // Check value + for (uint32_t i = 0; i < 8; i++) + { + if (l_uint32array1[i] != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY1. GET [%d] returned %d", + i, l_uint32array1[i]); + break; + } + } + + if (l_rc) + { + break; + } + + // Test set + for (uint32_t i = 0; i < 8; i++) + { + l_uint32array1[i] = i + 1; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from SET"); + break; + } // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64Array); + for (uint32_t i = 0; i < 8; i++) + { + l_uint32array1[i] = 0; + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64_ARRAY. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from GET (2)"); break; } - // Check values - for (uint32_t i = 0; i < 5; i++) + // Check value + for (uint32_t i = 0; i < 8; i++) { - if (l_uint64Array[i] != 4) + if (l_uint32array1[i] != (i + 1)) { l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64_ARRAY. GET " - "returned %d in index %d", - static_cast<uint32_t>(l_uint64Array[i]), i); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY1. GET [%d] returned %d (2)", + i, l_uint32array1[i]); break; } } @@ -395,137 +628,371 @@ fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) break; } - // Cannot set read-only attribute + // Set to zero + for (uint32_t i = 0; i < 8; i++) + { + l_uint32array1[i] = 0; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from SET (2)"); + break; + } + } //---------------------------------------------------------------------- - // Test ATTR_TEST_STRING1 (DefaultVal 'mike') + // Test ATTR_SCRATCH_UINT32_ARRAY_2 //---------------------------------------------------------------------- - char * l_pString1 = NULL; + { + uint32_t l_uint32 = 1; + uint32_t l_uint32array2[2][3]; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_pString1); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from GET"); break; } // Check value - if (l_pString1 == NULL) + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + if (l_uint32array2[i][j] != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY2. GET [%d:%d] returned %d", + i, j, l_uint32array2[i][j]); + break; + } + } + if (l_rc) + { + break; + } + } + + if (l_rc) { - l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned NULL"); break; } - if (strcmp(l_pString1, "mike") != 0) + // Test set + l_uint32 = 1; + for (uint32_t i = 0; i < 2; i++) { - l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned %s", - l_pString1); + for (uint32_t j = 0; j < 3; j++) + { + l_uint32array2[i][j] = l_uint32++; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. Error from SET"); break; } - delete [] l_pString1; + // Test get + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + l_uint32array2[i][j] = 0; + } + } - // Test set - l_pString1 = "test1"; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. Error from GET (2)"); + break; + } - l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_pString1); + // Check value + l_uint32 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + if (l_uint32array2[i][j] != l_uint32++) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY2. GET [%d:%d] returned %d", + i, j, l_uint32array2[i][j]); + break; + } + } + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + + // Set to zero + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + l_uint32array2[i][j]= 0; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from SET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. Error from SET (2)"); break; } + } - l_pString1 = NULL; + //---------------------------------------------------------------------- + // Test ATTR_SCRATCH_UINT64_ARRAY_1 + //---------------------------------------------------------------------- + { + uint64_t l_uint64array1[4]; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_pString1); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from GET (2)"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from GET"); break; } // Check value - if (l_pString1 == NULL) + for (uint32_t i = 0; i < 4; i++) + { + if (l_uint64array1[i] != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY1. GET [%d] returned %d", + i, static_cast<uint32_t>(l_uint64array1[i])); + break; + } + } + + if (l_rc) { - l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned NULL (2)"); break; } - if (strcmp(l_pString1, "test1") != 0) + // Test set + for (uint32_t i = 0; i < 4; i++) { - l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned %s (2)", - l_pString1); + l_uint64array1[i] = i + 1; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from SET"); break; } - delete [] l_pString1; + // Test get + for (uint32_t i = 0; i < 4; i++) + { + l_uint64array1[i] = 0; + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from GET (2)"); + break; + } + + // Check value + for (uint32_t i = 0; i < 4; i++) + { + if (l_uint64array1[i] != (i + 1)) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY1. GET [%d] returned %d (2)", + i, static_cast<uint32_t>(l_uint64array1[i])); + break; + } + } + + if (l_rc) + { + break; + } + + // Set to zero + for (uint32_t i = 0; i < 4; i++) + { + l_uint64array1[i] = 0; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from SET (2)"); + break; + } + } //---------------------------------------------------------------------- - // Test ATTR_TEST_STRING2 (PLAT (sets val to 'platString')) + // Test ATTR_SCRATCH_UINT64_ARRAY_2 //---------------------------------------------------------------------- - char * l_pString2 = NULL; + { + uint64_t l_uint64 = 1; + uint64_t l_uint64array2[2][2]; // Test get - l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_pString2); + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); if (l_rc) { - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. Error from GET"); + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from GET"); break; } // Check value - if (l_pString2 == NULL) + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + if (l_uint64array2[i][j] != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY2. GET [%d:%d] returned %d", + i, j, static_cast<uint32_t>(l_uint64array2[i][j])); + break; + } + } + if (l_rc) + { + break; + } + } + + if (l_rc) { - l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. GET returned NULL"); break; } - if (strcmp(l_pString2, "platString") != 0) + // Test set + l_uint64 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + l_uint64array2[i][j] = l_uint64++; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. Error from SET"); + break; + } + + // Test get + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + l_uint64array2[i][j] = 0; + } + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. Error from GET (2)"); + break; + } + + // Check value + l_uint64 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + if (l_uint64array2[i][j] != l_uint64++) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY2. GET [%d:%d] returned %d", + i, j, static_cast<uint32_t>(l_uint64array2[i][j])); + break; + } + } + if (l_rc) + { + break; + } + } + + if (l_rc) { - l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; - FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. GET returned %s", - l_pString2); break; } + // Set to zero + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + l_uint64array2[i][j]= 0; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. Error from SET (2)"); + break; + } + } - // All of the following should not compile due to setting read-only - // attributes - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, NULL, l_uint32); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64Array); + //---------------------------------------------------------------------- + // Test invalid accesses + //---------------------------------------------------------------------- // All of the following should not compile due to wrong types used - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_uint32); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_uint64); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_uint8Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_pString1); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, NULL, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint8Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_pString1); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, &l_uint32Array[0][0][0]); - - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_uint8); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING2, NULL, l_uint32); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING2, NULL, l_uint64Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, NULL, l_pString1); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, NULL, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, &l_uint32Array[0][0][0]); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, l_uint64Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, NULL, l_pString2); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint8); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64); + { + //uint32_t l_val; + //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + } + { + //uint64_t l_val; + //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_1, NULL, l_val); + //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_val); + } + { + //uint8_t l_val; + //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_val); + //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_val); + } + { + //uint8_t l_array[33]; // size should be 32 + //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_array); + //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_array); + } + { + //uint8_t l_array[2][3]; // type should be uint32_t + //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_array); + //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_array); + } + { + //uint64_t l_array[2][1]; // second dimension should be 2 + //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_array); + //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_array); + } } while (0); |