[Fuego] [PATCH 1/2] Kernel_build: Update to parse and get test_build time

[email protected] Tue, 12 Apr 2022 17:25:06 +0530
Newsgroups dev.linux.lists.fuego
Message-ID <[email protected]>
From: sireesha <[email protected]>

scripts/parser/common.py: Update reference to 'Consolelog' to parse build time

chart_config.json: Add reference to get test build time

parser.py: Implement to parse test build time from console log

reference.json: Add reference for test build time

test.yaml: Add data files related to kernel build

Signed-off-by: sireesha <[email protected]>
---
 scripts/parser/common.py                      |  1 +
 .../Functional.kernel_build/chart_config.json |  5 +++++
 tests/Functional.kernel_build/parser.py       | 21 +++++++++++++++++++
 tests/Functional.kernel_build/reference.json  | 20 ++++++++++++++++++
 tests/Functional.kernel_build/test.yaml       |  3 +++
 5 files changed, 50 insertions(+)
 create mode 100644 tests/Functional.kernel_build/chart_config.json
 create mode 100644 tests/Functional.kernel_build/parser.py
 create mode 100644 tests/Functional.kernel_build/reference.json

diff --git a/scripts/parser/common.py b/scripts/parser/common.py
index d7dcfbd..ba28cc1 100644
--- a/scripts/parser/common.py
+++ b/scripts/parser/common.py
@@ -114,6 +114,7 @@ for env_var in env_list:
 REF_JSON  = TEST_HOME + '/reference.json'
 CHART_CONFIG_JSON  = TEST_HOME + '/chart_config.json'
 TEST_LOG = '%s/logs/%s/%s.%s.%s.%s/testlog.txt' % (FUEGO_RW, TESTDIR, NODE_NAME, TESTSPEC, BUILD_NUMBER, BUILD_ID)
+CONSOLE_LOG = '%s/logs/%s/%s.%s.%s.%s/consolelog.txt' % (FUEGO_RW, TESTDIR, NODE_NAME, TESTSPEC, BUILD_NUMBER, BUILD_ID)
 RUN_JSON = LOGDIR + '/run.json'
 
 #Here are some pre-packaged regex strings
diff --git a/tests/Functional.kernel_build/chart_config.json b/tests/Functional.kernel_build/chart_config.json
new file mode 100644
index 0000000..a8802de
--- /dev/null
+++ b/tests/Functional.kernel_build/chart_config.json
@@ -0,0 +1,5 @@
+{
+    "chart_type": "measure_plot",
+    "measures": ["default.test_build"]
+}
+
diff --git a/tests/Functional.kernel_build/parser.py b/tests/Functional.kernel_build/parser.py
new file mode 100644
index 0000000..78f35c3
--- /dev/null
+++ b/tests/Functional.kernel_build/parser.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+import os, re, sys
+import common as plib
+   
+cur_search_str = "^(Fuego.test_build.duration=)\ *([\d]{1,8}.[\d]{1,4}).*"
+
+print("Reading current values from " + plib.CONSOLE_LOG)
+cur_file = open(plib.CONSOLE_LOG,'r')
+
+lines = cur_file.readlines()
+cur_file.close()
+
+measurements = {}
+for line in lines:
+    m = re.match(cur_search_str, line)
+    if m:
+        value = m.group(2)
+        measurements['default.kernel_build'] = [{"name": "test_build", "measure" : value}]
+
+sys.exit(plib.process(measurements))
+
diff --git a/tests/Functional.kernel_build/reference.json b/tests/Functional.kernel_build/reference.json
new file mode 100644
index 0000000..9d8adfc
--- /dev/null
+++ b/tests/Functional.kernel_build/reference.json
@@ -0,0 +1,20 @@
+{
+    "test_sets":[
+        {
+            "name":"default",
+            "test_cases":[
+                {
+                    "name":"kernel_build",
+                    "measurements":[
+                        {
+                            "name":"test_build",
+                            "unit":"s"
+                        }
+
+                    ]
+                }
+            ]
+        }
+    ]
+}
+
diff --git a/tests/Functional.kernel_build/test.yaml b/tests/Functional.kernel_build/test.yaml
index c076bd7..304218e 100644
--- a/tests/Functional.kernel_build/test.yaml
+++ b/tests/Functional.kernel_build/test.yaml
@@ -46,3 +46,6 @@ data_files:
     - fuego_test.sh
     - spec.json
     - test.yaml
+    - parser.py
+    - reference.json
+    - chart_config.json
-- 
2.20.1