From 6438565a4d9d50f63a0b46e207c5457595abc531 Mon Sep 17 00:00:00 2001 From: Agustin Carranza Date: Mon, 22 May 2023 13:40:34 -0300 Subject: [PATCH] Add parsing check when Context field is empty This change adds a parsing check to ERROR if Context field is Empty. Until now there had not been a requirement of non empty fields, so in case this is needed in the future for other key/values, a collection is created. Test plan PASS: * Add/modify an alarm/log in events.yaml file with Context field set to . * Run the checkEventYaml script and check it fails. PASS: * Check that all the events in events.yaml file have the Context field set to a non empty value. * Run the checkEventYaml script and check it ends successfully. Closes-bug: 2020381 Signed-off-by: Agustin Carranza Change-Id: Ia267886dd49099525751165975fb5d291c0c6f82 --- fm-doc/fm_doc/parseEventYaml.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fm-doc/fm_doc/parseEventYaml.py b/fm-doc/fm_doc/parseEventYaml.py index e82bdeed..ce6fcb96 100755 --- a/fm-doc/fm_doc/parseEventYaml.py +++ b/fm-doc/fm_doc/parseEventYaml.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2016-2022 Wind River Systems, Inc. +# Copyright (c) 2016-2023 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -103,6 +103,10 @@ logFields = { context_FieldName: context_FieldValues } +nonEmptyFields = { + context_FieldName +} + def checkField(fieldKey, fieldValues, key, event): if fieldKey not in event: @@ -110,6 +114,10 @@ def checkField(fieldKey, fieldValues, key, event): return False # print("START: %s :END" % event[fieldKey]) + if fieldKey in nonEmptyFields and not event[fieldKey]: + print("\n ERROR: \'%s\' can not be empty." % (fieldKey)) + return False + if type(event[fieldKey]) is str: if not fieldValues: return True