Remove validation bits
Discard invalid properties from json decode. JSON output should only
contain valid properties. This saves time in preventing post
processing of output for valid fields.
Ensure round trip validity with validation bits removed and required
properties populated.
Fix bugs in json decode.
Overhaul unit tests to use valijson. Add tests with static examples
to validate against schema. Use and nlohmann for better schema
validation over intrinsic libcper validation.
Example json output before:
{
"ValidationBits": {
"LevelValid": false,
"CorrectedValid": true
},
"Level": 1,
"Corrected": true
}
After:
{
"Corrected": true
}
Change-Id: I188bdc2827a57d938c22a431238fadfcdc939ab8
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/generator/sections/gen-section-generic.c b/generator/sections/gen-section-generic.c
index 7baf325..54de52e 100644
--- a/generator/sections/gen-section-generic.c
+++ b/generator/sections/gen-section-generic.c
@@ -11,21 +11,28 @@
//Generates a single pseudo-random generic processor section, saving the resulting address to the given
//location. Returns the size of the newly created section.
-size_t generate_section_generic(void **location)
+size_t generate_section_generic(void **location,
+ GEN_VALID_BITS_TEST_TYPE validBitsType)
{
//Create random bytes.
size_t size = generate_random_section(location, 192);
//Set reserved locations to zero.
UINT8 *start_byte = (UINT8 *)*location;
- *((UINT64 *)start_byte) &= 0xFFF;
+ UINT64 *validation = (UINT64 *)*location;
+ *validation &= 0x1FFF;
+ if (validBitsType == ALL_VALID) {
+ *validation = 0x1FFF;
+ } else if (validBitsType == SOME_VALID) {
+ *validation = 0x1555;
+ }
*(start_byte + 12) &= 0x7;
*((UINT16 *)(start_byte + 14)) = 0x0;
//Ensure CPU brand string does not terminate early.
for (int i = 0; i < 128; i++) {
UINT8 *byte = start_byte + 24 + i;
- //CPU brand can only be ASCII
+ //Ensure only ascii is used
*byte = rand() % 127 + 1;
//Null terminate last byte.