Revert "SQUAD : Adding a memory footprint gathering script launched from ci"
This reverts commit b605c6ce6e5e150e8f0eb7a22286381863955a47.
Reason for revert:
python3 tf-m-ci-scripts/memory_footprint.py /home/buildslave/workspace/tf-m-build-config/trusted-firmware-m/ AN521_GNUARM_PSA_2_Debug_BL2_NS_MEDIUM Default,CoreIPC,CoreIPCTfmLevel2 ****
Traceback (most recent call last):
File "tf-m-ci-scripts/memory_footprint.py", line 207, in <module>
config = identify_config(CI_CONFIG)
File "tf-m-ci-scripts/memory_footprint.py", line 138, in identify_config
arguments = get_config(CI_CONFIG)
File "tf-m-ci-scripts/memory_footprint.py", line 115, in get_config
match_dict = m.groupdict()
AttributeError: 'NoneType' object has no attribute 'groupdict'
Change-Id: I6ad9ae8dc30298ee9622c4438a2a8f84bcf0ce0e
diff --git a/jenkins/build-config.jpl b/jenkins/build-config.jpl
index 665f939..21e7ea0 100644
--- a/jenkins/build-config.jpl
+++ b/jenkins/build-config.jpl
@@ -1,6 +1,6 @@
#!/usr/bin/env groovy
//-------------------------------------------------------------------------------
-// Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+// Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
//
// SPDX-License-Identifier: BSD-3-Clause
//
@@ -100,16 +100,6 @@
stage("Post") {
archiveArtifacts 'trusted-firmware-m/build/bin/**'
archiveArtifacts 'trusted-firmware-m/build/install/interface/**'
- if (env.SQUAD_CONFIGURATIONS != ""){
- //Creating a folder to store memory footprint artifacts and launching the memory footprint script.
- sh "mkdir tf-m-ci-scripts/Memory_footprint/"
- withCredentials([string(credentialsId: 'QA_REPORTS_TOKEN', variable: 'TOKEN')]) {
- sh(script: "python3 tf-m-ci-scripts/memory_footprint.py ${env.WORKSPACE}/trusted-firmware-m/ ${env.CONFIG_NAME} \'${env.SQUAD_CONFIGURATIONS}\' ${TOKEN}", returnStdout: true)
- }
- if (fileExists('tf-m-ci-scripts/Memory_footprint/filesize.json')) {
- archiveArtifacts 'tf-m-ci-scripts/Memory_footprint/filesize.json'
- }
- }
}
} catch (Exception e) {
manager.buildFailure()
diff --git a/jenkins/ci.jpl b/jenkins/ci.jpl
index 41eb6c9..25e6eb6 100644
--- a/jenkins/ci.jpl
+++ b/jenkins/ci.jpl
@@ -1,6 +1,6 @@
#!/usr/bin/env groovy
//-------------------------------------------------------------------------------
-// Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+// Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
//
// SPDX-License-Identifier: BSD-3-Clause
//
@@ -158,9 +158,6 @@
params += string(name: 'CODE_REPO', value: env.CODE_REPO)
params += string(name: 'CODE_COVERAGE_EN', value: env.CODE_COVERAGE_EN)
params += string(name: 'CI_SCRIPTS_BRANCH', value: env.CI_SCRIPTS_BRANCH)
- if (env.JOB_NAME.equals("tf-m-nightly")) { //Setting the Memory footprint gathering.
- params += string(name: 'SQUAD_CONFIGURATIONS', value: env.SQUAD_CONFIGURATIONS)
- }
return { -> results
def build_res = build(job: 'tf-m-build-config', parameters: params, propagate: false)
def build_info = [build_res, config, params_collection]
diff --git a/memory_footprint.py b/memory_footprint.py
deleted file mode 100644
index dca011c..0000000
--- a/memory_footprint.py
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/usr/bin/env python
-
-#memory_footprint.py : Script for sending memory footprint data from the TFM CI
-#to a SQUAD web interface
-#
-#Copyright (c) 2020-2021, Arm Limited. All rights reserved.
-#
-#SPDX-License-Identifier: BSD-3-Clause
-
-
-import argparse
-import os
-import re
-import sys
-import json
-import requests
-import subprocess
-from tfm_ci_pylib import utils
-
-# Arguments/parameters given by CI
-PATH_TO_TFM = sys.argv[1]
-CI_CONFIG = sys.argv[2]
-REFERENCE_CONFIGS = sys.argv[3].split(",")
-SQUAD_TOKEN = sys.argv[4]
-
-# local constant
-SQUAD_BASE_PROJECT_URL = ("https://qa-reports.linaro.org/api/submit/tf/tf-m/")
-
-# This function uses arm_non_eabi_size to get the sizes of a file
-# in the build directory of tfm
-def get_file_size(filename):
- f_path = os.path.join(PATH_TO_TFM, "build", "bin", filename)
- if os.path.exists(f_path) :
- bl2_sizes = utils.arm_non_eabi_size(f_path)[0]
- return bl2_sizes
- else :
- print(f_path + "Not found")
- return -1
-
-# This function creates a json file containing all the data about
-# memory footprint and sends this data to SQUAD
-def send_file_size(change_id, config_name, bl2_sizes, tfms_sizes):
- url = SQUAD_BASE_PROJECT_URL + change_id + '/' + config_name
-
- try:
- metrics = json.dumps({ "bl2_size" : bl2_sizes["dec"],
- "bl2_data" : bl2_sizes["data"],
- "bl2_bss" : bl2_sizes["bss"],
- "tfms_size" : tfms_sizes["dec"],
- "tfms_data" : tfms_sizes["data"],
- "tfms_bss" : tfms_sizes["bss"]})
- except:
- return -1
- headers = {"Auth-Token": SQUAD_TOKEN}
- data= {"metrics": metrics}
-
- try:
- #Sending the data to SQUAD, 40s timeout
- result = requests.post(url, headers=headers, data=data, timeout=40)
- except:
- return -1
-
- with open(os.path.join(PATH_TO_TFM,
- "..",
- "tf-m-ci-scripts",
- "Memory_footprint",
- "filesize.json"), "w") as F:
- #Storing the json file
- F.write(metrics)
-
- if not result.ok:
- print(f"Error submitting to qa-reports: {result.reason}: {result.text}")
- return -1
- else :
- print ("POST request sent to project " + config_name )
- return 0
-
-#Function used to launch the configs.py script and get the printed output
-def get_config(config_string):
- script_directory = os.path.join(PATH_TO_TFM, "..", "tf-m-ci-scripts")
- directory = os.path.abspath(script_directory)
- cur_dir = os.path.abspath(os.getcwd())
- os.chdir(directory) # Going to the repo's directory
-
- cmd = "python3 configs.py " + config_string
-
- rex = re.compile(r'(?P<config>^[\s\S]*?)((?:TFM_PLATFORM=)'
- r'(?P<platform>.*)\n)((?:TOOLCHAIN_FILE=)'
- r'(?P<toolchain>.*)\n)((?:PSA_API=)'
- r'(?P<psa>.*)\n)((?:ISOLATION_LEVEL=)'
- r'(?P<isolation_level>.*)\n)((?:TEST_REGRESSION=)'
- r'(?P<regression>.*)\n)((?:TEST_PSA_API=)'
- r'(?P<psa_test>.*)\n)((?:CMAKE_BUILD_TYPE=)'
- r'(?P<build_type>.*)\n)((?:OTP=)'
- r'(?P<otp>.*)\n)((?:BL2=)'
- r'(?P<bl2>.*)\n)((?:NS=)'
- r'(?P<ns>.*)\n)((?:PROFILE=)'
- r'(?P<profile>.*)\n)((?:PARTITION_PS=)'
- r'(?P<partition_ps>.*)?)', re.MULTILINE)
-
- r, e = subprocess.Popen(cmd,
- shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).communicate()
- if e:
- print("Error", e)
- return -1
- else:
- try:
- txt_body = r.decode('ascii')
- except UnicodeDecodeError as E:
- txt_body = r.decode('utf-8')
-
- m = rex.search(txt_body)
- match_dict = m.groupdict()
-
- match_dict = {k: simple_filter(v) for k, v in match_dict.items()}
-
- os.chdir(cur_dir)
-
- return match_dict
-
-def simple_filter(A):
- try:
- a = A.lower()
- if a in ["true", "on"]:
- return True
- elif a in ["false", "off"]:
- return False
- else:
- return A
- except Exception:
- return A
-
-# This funcion manipulates the format of the config given
-# as entry to extract the name of the configuration used
-def identify_config(ci_config):
- arguments = get_config(CI_CONFIG)
- name_config = "Unknown"
- try :
- if (arguments["psa"] and arguments["isolation_level"] == "1" and
- not arguments["regression"] and not arguments["psa_test"] and
- arguments["build_type"] == "Release" and not arguments["otp"] and
- arguments["bl2"] and arguments["ns"] and
- arguments["profile"] == "N.A" and arguments["partition_ps"]):
- name_config = "CoreIPC"
- elif (not arguments["psa"] and arguments["isolation_level"] == "1" and
- not arguments["regression"] and not arguments["psa_test"] and
- arguments["build_type"] == "Release" and not arguments["otp"] and
- arguments["bl2"] and arguments["ns"] and
- arguments["profile"] == "N.A" and arguments["partition_ps"]):
- name_config = "Default"
- elif (arguments["psa"] and arguments["isolation_level"] == "2" and
- not arguments["regression"] and not arguments["psa_test"] and
- arguments["build_type"] == "Release" and not arguments["otp"] and
- arguments["bl2"] and arguments["ns"] and
- arguments["profile"] == "N.A" and arguments["partition_ps"]):
- name_config = "CoreIPCTfmLevel2"
- elif (not arguments["psa"] and arguments["isolation_level"] == "1" and
- not arguments["regression"] and not arguments["psa_test"] and
- arguments["build_type"] == "Release" and not arguments["otp"] and
- arguments["bl2"] and arguments["ns"] and
- arguments["profile"] == "SMALL" and arguments["partition_ps"]):
- name_config = "DefaultProfileS"
- elif (not arguments["psa"] and arguments["isolation_level"] == "2" and
- not arguments["regression"] and not arguments["psa_test"] and
- arguments["build_type"] == "Release" and not arguments["otp"] and
- arguments["bl2"] and arguments["ns"] and
- arguments["profile"] == "MEDIUM" and arguments["partition_ps"]):
- name_config = "DefaultProfileM"
- ret = [arguments["platform"],arguments["toolchain"], name_config]
- except:
- ret = ["Unknown", "Unknown", "Unknown"]
- return ret
-
-# Function based on get_local_git_info() from utils, getting change id for the tfm repo
-def get_change_id(directory):
- directory = os.path.abspath(directory)
- cur_dir = os.path.abspath(os.getcwd())
- os.chdir(directory) # Going to the repo's directory
- cmd = "git log HEAD -n 1 --pretty=format:'%b'"
-
- git_info_rex = re.compile(r'(?P<body>^[\s\S]*?)((?:Change-Id:\s)'
- r'(?P<change_id>.*)\n?)', re.MULTILINE)
-
- r, e = subprocess.Popen(cmd,
- shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).communicate()
- if e:
- print("Error", e)
- return
- else:
- try:
- txt_body = r.decode('ascii')
- except UnicodeDecodeError as E:
- txt_body = r.decode('utf-8')
- result = txt_body.rstrip()
-
- change_id = git_info_rex.search(result).groupdict()["change_id"].strip()
- os.chdir(cur_dir) #Going back to the initial directory
- return change_id
-
-if __name__ == "__main__":
- for i in range(len(REFERENCE_CONFIGS)):
- REFERENCE_CONFIGS[i] = REFERENCE_CONFIGS[i].strip().lower()
- config = identify_config(CI_CONFIG)
- if (config[2].lower() in REFERENCE_CONFIGS
- and config[0] == "mps2/an521"
- and config[1] == "toolchain_GNUARM.cmake"):
- # Pushing data for AN521 and GNUARM
- print("Configuration " + config[2] + " is a reference")
- try :
- change_id = get_change_id(PATH_TO_TFM)
- except :
- change_id = -1
- bl2_sizes = get_file_size("bl2.axf")
- tfms_sizes = get_file_size("tfm_s.axf")
- if (bl2_sizes != -1 and change_id != -1) :
- send_file_size(change_id, config[2], bl2_sizes, tfms_sizes)
- else :
- #Directory or file weren't found
- if change_id == -1 :
- print("Error : trusted-firmware-m repo not found")
- else :
- print("Error : file not found")