Compile switch to output all properties

With validation bits removed, debug scenarios might require all
fields to be printed regardless of their validity.
Disable unit tests in this case as round trip will fail.

Add meson switch to bb file to enable all properties:
EXTRA_OEMESON += "-Doutput_all_properties=enabled"

Tested with locally generated examples and diffing results.

Change-Id: Ic232c295197e2152735fcf0f33041d6f972512bc
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/cper-utils.c b/cper-utils.c
index c777974..d36e944 100644
--- a/cper-utils.c
+++ b/cper-utils.c
@@ -241,6 +241,11 @@
 // Overload function for 16, 32, 64b
 bool isvalid_prop_to_ir(ValidationTypes *val, int vbit_idx)
 {
+// If the option is enabled, output invalid properties
+// as well as valid ones.
+#ifdef OUTPUT_ALL_PROPERTIES
+	return true;
+#endif //OUTPUT_ALL_PROPERTIES
 	UINT64 vbit_mask = 0x01 << vbit_idx;
 	switch (val->size) {
 	case UINT_16T:
diff --git a/meson.build b/meson.build
index fa054c5..4936a76 100644
--- a/meson.build
+++ b/meson.build
@@ -24,6 +24,10 @@
 library_is_share = get_option('default_library') == 'shared'
 add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c')
 
+if get_option('output-all-properties').enabled()
+    add_project_arguments('-DOUTPUT_ALL_PROPERTIES', language: ['c', 'cpp'])
+endif
+
 project_description = 'libcper library'
 
 section_sources = files(
@@ -158,6 +162,10 @@
     )
 endif
 
-if get_option('tests').allowed()
-    subdir('tests')
+# Disable unit tests when output-all-properties is enabled
+# because it changes CPER-IR output format.
+if get_option('output-all-properties').disabled()
+    if get_option('tests').allowed()
+        subdir('tests')
+    endif
 endif
diff --git a/meson.options b/meson.options
index b34d541..f22076c 100644
--- a/meson.options
+++ b/meson.options
@@ -1,2 +1,8 @@
 option('tests', type: 'feature', value: 'enabled', description: 'Build tests')
 option('utility', type: 'feature', value: 'enabled', description: 'Utility')
+option(
+    'output-all-properties',
+    type: 'feature',
+    value: 'disabled',
+    description: 'Force enabling of all CPER to IR properties for debugging',
+)