diff --git a/docs/kw_cfg/analysis_profile_SA_plus_MISRAC_2012_HIS.pconf b/docs/kw_cfg/analysis_profile_SA_plus_MISRAC_2012_HIS.pconf deleted file mode 100644 index 578ec8a..0000000 --- a/docs/kw_cfg/analysis_profile_SA_plus_MISRAC_2012_HIS.pconf +++ /dev/null @@ -1,892 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/kw_cfg/analysis_profile_SA_plus_MISRAC_2012_HIS_modified.pconf b/docs/kw_cfg/analysis_profile_SA_plus_MISRAC_2012_HIS_modified.pconf deleted file mode 100644 index 13798ed..0000000 --- a/docs/kw_cfg/analysis_profile_SA_plus_MISRAC_2012_HIS_modified.pconf +++ /dev/null @@ -1,892 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/kw_cfg/his_metrics_community_old.mconf b/docs/kw_cfg/his_metrics_community_old.mconf deleted file mode 100644 index 52f90fc..0000000 --- a/docs/kw_cfg/his_metrics_community_old.mconf +++ /dev/null @@ -1,40 +0,0 @@ -# Klocwork C and C++ Community Metrics - HIS Metrics 1.3.1 -# -# Each line of this file, except comment lines and header lines, is a rule that -# sets a threshold for one of the default or custom metrics. -# -# Format of each rule: -# Name;Entity-Type;Metric-Expression;Error-Threshold;Warning-Threshold -# -# Name - the name of rule; ill be displayed if the rule is violated -# Entity-Type - the FUNCTION, CLASS-METHOD, CLASS or FILE where the metric is -# applicable -# Metric-Expression - can contain +,-,*,/,%,(), function calls, numbers, basic -# metrics and aliases -# Function calls: log, sin, exp, int, abs, cos, atan2, sqrt, rand :) -# Error-Threshold: comparison expression; if violated, an Error is displayed -# Warning-Threshold: comparison expression; if violated, a Warning is displayed -# -# Categories - You can use header lines to group your rules into categories. -# For example: -# WARNING.SEVERITY=4 ERROR.SEVERITY=2 WARNING.CATEGORY="User Defined Warning Category 1" ERROR.CATEGORY="User Defined Error Category 1" -# -# Aliases - The #!alias syntax allows you to substitute text in the rules. -# Syntax: #!alias = -# Following the #!alias line, will be substituted as . -# -#################################################################################################################### -# [8/6/2021] Samip Banker -# Below metrics have been commented out after alignment with SQA team. -#################################################################################################################### -#HIS Metrics - Comment density COMF;FILE;LINESCOMM/(RNOSTAT + 0.000001);<0.0;<0.2 -#HIS Metrics - Number of calls CALLS;FUNCTION,CLASS-METHOD;NOCALLS;7;7 -#HIS Metrics - Number of instructions per func STMT;FUNCTION,CLASS-METHOD;NOSTAT;50;50 -#HIS Metrics - Number of return points RETURN;FUNCTION,CLASS-METHOD;NORET;1;1 -#HIS Metrics - Language scope VOCF;FUNCTION,CLASS-METHOD;(NOOPRUSED + NOOPUSED)/(NODISOPRUSED + NODISOPUSED + 0.000001);4;4 - -WARNING.SEVERITY=4 ERROR.SEVERITY=3 WARNING.CATEGORY="HIS Metrics Warning" ERROR.CATEGORY="HIS Metrics Error" -HIS Metrics - Number of paths PATH;FUNCTION,CLASS-METHOD;exp(NOINDPATHS);80.0;80.0 -HIS Metrics - Cyclomatic v(G);FUNCTION,CLASS-METHOD;CYCLOMATIC;10;10 -HIS Metrics - Number of parameters PARAM;FUNCTION,CLASS-METHOD;NOPARMS;5;5 -HIS Metrics - Max nesting level LEVEL;FUNCTION,CLASS-METHOD;MAXLEVEL;4;4 diff --git a/scripts/kwSetup.py b/scripts/kwSetup.py deleted file mode 100644 index a50a4de..0000000 --- a/scripts/kwSetup.py +++ /dev/null @@ -1,95 +0,0 @@ -############################################################################# -# Copyright (c) 2023-2024 Texas Instruments Incorporated - http://www.ti.com -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# -# Neither the name of Texas Instruments Incorporated nor the names of -# its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -############################################################################# -import os -import platform -import subprocess - -if __name__ == "__main__": - success = 0 - kwlpFile = ".kwlp" - kwpsFile = ".kwps" - kwReport = "kw_report.xml" - kwOutput = "kwinject.out" - - if (platform.system() == "Windows"): - pconfFile = "..\\pmic-lld\\docs\\kw_cfg\\analysis_profile_SA_MISRA_HIS_2022.pconf" - mconfFile = "..\\pmic-lld\\docs\\kw_cfg\\his_metrics_community.mconf" - sconfFile = "..\\pmic-lld\\docs\\kw_cfg\\kw_filter.sconf" - elif (platform.system() == "Linux"): - pconfFile = "../pmic-lld/docs/kw_cfg/analysis_profile_SA_MISRA_HIS_2022.pconf" - mconfFile = "../pmic-lld/docs/kw_cfg/his_metrics_community.mconf" - sconfFile = "../pmic-lld/docs/kw_cfg/kw_filter.sconf" - else: - print("Error: unsupported system") - exit(-1) - - # If Klocwork local project does not exist... - if ((not os.path.exists(kwlpFile)) and (not os.path.exists(kwpsFile))): - try: - # Create local project - status = subprocess.run(["kwcheck", "create"]) - status.check_returncode() - - # Set license host and port - status = subprocess.run(["kwcheck", "set", "license.host=kw-lic.ent.ti.com", "license.port=27005"]) - status.check_returncode() - - # Import .pconf file - if (os.path.exists(pconfFile)): - status = subprocess.run(["kwcheck", "import", pconfFile]) - status.check_returncode() - else: - raise FileNotFoundError(pconfFile) - - # Import .mconf file - if (os.path.exists(mconfFile)): - status = subprocess.run(["kwcheck", "import", mconfFile]) - status.check_returncode() - else: - raise FileNotFoundError(mconfFile) - - # Import .sconf file - if (os.path.exists(sconfFile)): - status = subprocess.run(["kwcheck", "import", sconfFile]) - status.check_returncode() - else: - raise FileNotFoundError(sconfFile) - except Exception as e: - print("\"" + str(e) + "\" exception at line number " + str(e.__traceback__.tb_lineno)) - exit(-1) - - # Delete existing KW report and KW build specification (i.e., KW output) - try: os.remove(kwReport) - except: print("Could not find an existing " + kwReport + " to delete") - try: os.remove(kwOutput) - except: print("Could not find an existing " + kwOutput + " to delete") - \ No newline at end of file diff --git a/scripts/kw_cfg/TI_HIS_Metrics_2022.4.tconf b/scripts/kw_cfg/TI_HIS_Metrics_2022.4.tconf new file mode 100644 index 0000000..c23d294 --- /dev/null +++ b/scripts/kw_cfg/TI_HIS_Metrics_2022.4.tconf @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/kw_cfg/TI_MISRAC_2012_2022.4.tconf b/scripts/kw_cfg/TI_MISRAC_2012_2022.4.tconf new file mode 100644 index 0000000..8c659a1 --- /dev/null +++ b/scripts/kw_cfg/TI_MISRAC_2012_2022.4.tconf @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/kw_cfg/TI_StaticAnalysis_2022.4.tconf b/scripts/kw_cfg/TI_StaticAnalysis_2022.4.tconf new file mode 100644 index 0000000..7598c43 --- /dev/null +++ b/scripts/kw_cfg/TI_StaticAnalysis_2022.4.tconf @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/kw_cfg/analysis_profile_SA_MISRA_HIS_2022.pconf b/scripts/kw_cfg/analysis_profile_SA_MISRA_HIS_2022.pconf similarity index 100% rename from docs/kw_cfg/analysis_profile_SA_MISRA_HIS_2022.pconf rename to scripts/kw_cfg/analysis_profile_SA_MISRA_HIS_2022.pconf diff --git a/docs/kw_cfg/his_metrics_community.mconf b/scripts/kw_cfg/his_metrics_community.mconf similarity index 100% rename from docs/kw_cfg/his_metrics_community.mconf rename to scripts/kw_cfg/his_metrics_community.mconf diff --git a/docs/kw_cfg/kw_filter.sconf b/scripts/kw_cfg/kw_filter.sconf similarity index 100% rename from docs/kw_cfg/kw_filter.sconf rename to scripts/kw_cfg/kw_filter.sconf diff --git a/scripts/kw_cfg/kwreadme.txt b/scripts/kw_cfg/kwreadme.txt new file mode 100644 index 0000000..ecaea23 --- /dev/null +++ b/scripts/kw_cfg/kwreadme.txt @@ -0,0 +1,5 @@ +All Klocwork checker and configuration files are obtained from the below repository: + +https://bitbucket.itg.ti.com/projects/ITOOLS/repos/klocwork/browse + +The files are meant to be used with Klocwork version 2022.4. \ No newline at end of file diff --git a/scripts/kwsetup.py b/scripts/kwsetup.py new file mode 100644 index 0000000..f03e433 --- /dev/null +++ b/scripts/kwsetup.py @@ -0,0 +1,104 @@ +"""Copyright (c) 2023-2024 Texas Instruments Incorporated - http://www.ti.com + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the +distribution. + +Neither the name of Texas Instruments Incorporated nor the names of +its contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.""" +import os +import sys +import subprocess +import argparse + +if __name__ == "__main__": + success = 0 + kwlpFile = ".kwlp" + kwpsFile = ".kwps" + kwReport = "kw_report.xml" + kwOutput = "kwinject.out" + + parser = argparse.ArgumentParser("kwsetup") + parser.add_argument('kwCfgPath', help='Path to Klockwork configuration file directory.') + args = parser.parse_args() + + # Get all KW file paths relative to where the script is run + kwCfgPath = args.kwCfgPath + pconfFile = os.path.join(kwCfgPath, "analysis_profile_SA_MISRA_HIS_2022.pconf") + mconfFile = os.path.join(kwCfgPath, "his_metrics_community.mconf") + sconfFile = os.path.join(kwCfgPath, "kw_filter.sconf") + hisMetricsTConfFile = os.path.join(kwCfgPath, "TI_HIS_Metrics_2022.4.tconf") + misracTConfFile = os.path.join(kwCfgPath, "TI_MISRAC_2012_2022.4.tconf") + saTConfFile = os.path.join(kwCfgPath, "TI_StaticAnalysis_2022.4.tconf") + + # If Klocwork local project does not exist... + if ((not os.path.exists(kwlpFile)) and (not os.path.exists(kwpsFile))): + # Create local project + subprocess.run(["kwcheck", "create"], check = True) + + # Set license host and port + subprocess.run(["kwcheck", "set", "license.host=kw-lic.ent.ti.com", "license.port=27005"], check = True) + + # Import .pconf file + if (os.path.exists(pconfFile)): + subprocess.run(["kwcheck", "import", pconfFile], check = True) + else: + raise FileNotFoundError(pconfFile) + + # Import .mconf file + if (os.path.exists(mconfFile)): + subprocess.run(["kwcheck", "import", mconfFile], check = True) + else: + raise FileNotFoundError(mconfFile) + + # Import .sconf file + if (os.path.exists(sconfFile)): + subprocess.run(["kwcheck", "import", sconfFile], check = True) + else: + raise FileNotFoundError(sconfFile) + + # Import HIS Metrics .tconf file + if (os.path.exists(hisMetricsTConfFile)): + subprocess.run(["kwcheck", "import", hisMetricsTConfFile], check = True) + else: + raise FileNotFoundError(hisMetricsTConfFile) + + # Import MISRA-C .tconf file + if (os.path.exists(misracTConfFile)): + subprocess.run(["kwcheck", "import", misracTConfFile], check = True) + else: + raise FileNotFoundError(misracTConfFile) + + # Import static analysis .tconf file + if (os.path.exists(saTConfFile)): + subprocess.run(["kwcheck", "import", saTConfFile], check = True) + else: + raise FileNotFoundError(saTConfFile) + + # Delete existing KW report and KW build specification (i.e., KW output) + try: os.remove(kwReport) + except: print("Could not find an existing " + kwReport + " to delete") + try: os.remove(kwOutput) + except: print("Could not find an existing " + kwOutput + " to delete") +