From nobody Sun May 19 11:37:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17019492164601017.8671305165138; Thu, 7 Dec 2023 03:40:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.649797.1014715 (Exim 4.92) (envelope-from ) id 1rBCjP-00076K-1u; Thu, 07 Dec 2023 11:39:51 +0000 Received: by outflank-mailman (output) from mailman id 649797.1014715; Thu, 07 Dec 2023 11:39:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rBCjO-00076D-VA; Thu, 07 Dec 2023 11:39:50 +0000 Received: by outflank-mailman (input) for mailman id 649797; Thu, 07 Dec 2023 11:39:49 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rBCjN-000767-Ud for xen-devel@lists.xenproject.org; Thu, 07 Dec 2023 11:39:49 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5310376c-94f5-11ee-9b0f-b553b5be7939; Thu, 07 Dec 2023 12:39:47 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 99CC14EE073A; Thu, 7 Dec 2023 12:39:46 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5310376c-94f5-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Simone Ballarin , Doug Goldstein , Stefano Stabellini , "Daniel P. Smith" Subject: [XEN PATCH] automation/eclair_analysis: file exclusion automation Date: Thu, 7 Dec 2023 12:39:43 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1701949218410100001 Content-Type: text/plain; charset="utf-8" The file exclude-list.json contains files that are classified as adopted code for MISRA compliance. Therefore, this file is used to automatically generate a suitable .ecl configuration for ECLAIR. As such, many entries in out_of_scope.ecl can be removed, as they would be duplicates. Signed-off-by: Nicola Vetrini --- automation/eclair_analysis/ECLAIR/adopted.sh | 30 +++++++++ .../eclair_analysis/ECLAIR/analysis.ecl | 3 + automation/eclair_analysis/ECLAIR/analyze.sh | 3 + .../eclair_analysis/ECLAIR/generate_ecl.sh | 15 +++++ .../eclair_analysis/ECLAIR/out_of_scope.ecl | 64 +------------------ .../ECLAIR/print_analyzed_files.sh | 4 +- 6 files changed, 56 insertions(+), 63 deletions(-) create mode 100755 automation/eclair_analysis/ECLAIR/adopted.sh create mode 100755 automation/eclair_analysis/ECLAIR/generate_ecl.sh diff --git a/automation/eclair_analysis/ECLAIR/adopted.sh b/automation/ecla= ir_analysis/ECLAIR/adopted.sh new file mode 100755 index 000000000000..9adbc4e58218 --- /dev/null +++ b/automation/eclair_analysis/ECLAIR/adopted.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Generates the adopted.ecl file + +set -eu + +script_name=3D"$(basename "$0")" +script_dir=3D"$( + cd "$(dirname "$0")" + echo "${PWD}" +)" + +fatal() { + echo "${script_name}: $*" >&2 + exit 1 +} + +usage() { + fatal "Usage: ${script_name}" +} + +exclude_list=3D$1 +outfile=3D${script_dir}/adopted.ecl + +( + echo "-doc_begin=3D\"Adopted files.\"" >"${outfile}" + sed -n -E -e 's|^\s+"rel_path":\s+"([^"]*).*$|-file_tag+=3D{adopted,"^xe= n/\1$"}|p' "${exclude_list}" | + sed -E -e 's|\.([ch])|\\\\.\1|g' -e 's|\*|.*|g' >>"${outfile}" + printf "%s\n" "-doc_end" >>"${outfile}" +) diff --git a/automation/eclair_analysis/ECLAIR/analysis.ecl b/automation/ec= lair_analysis/ECLAIR/analysis.ecl index f8d4cc8c9990..a604582da335 100644 --- a/automation/eclair_analysis/ECLAIR/analysis.ecl +++ b/automation/eclair_analysis/ECLAIR/analysis.ecl @@ -21,6 +21,9 @@ map_strings("scheduled-analysis",analysis_kind) =20 -eval_file=3Dtoolchain.ecl -eval_file=3Dpublic_APIs.ecl +if(not(scheduled_analysis), + eval_file("adopted.ecl") +) if(not(scheduled_analysis), eval_file("out_of_scope.ecl") ) diff --git a/automation/eclair_analysis/ECLAIR/analyze.sh b/automation/ecla= ir_analysis/ECLAIR/analyze.sh index 47cdbb03cee7..a127e7aaed2d 100755 --- a/automation/eclair_analysis/ECLAIR/analyze.sh +++ b/automation/eclair_analysis/ECLAIR/analyze.sh @@ -82,6 +82,9 @@ export ECLAIR_PROJECT_ROOT=3D"${PWD}" rm -rf "${ECLAIR_OUTPUT_DIR:?}/*" mkdir -p "${ECLAIR_DATA_DIR}" =20 +# Generate additional configuration files=20 +"${SCRIPT_DIR}/generate_ecl.sh" + # Perform the build (from scratch) in an ECLAIR environment. "${ECLAIR_BIN_DIR}eclair_env" \ "-config_file=3D'${SCRIPT_DIR}/analysis.ecl'" \ diff --git a/automation/eclair_analysis/ECLAIR/generate_ecl.sh b/automation= /eclair_analysis/ECLAIR/generate_ecl.sh new file mode 100755 index 000000000000..de20728eb1f9 --- /dev/null +++ b/automation/eclair_analysis/ECLAIR/generate_ecl.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Generates the .ecl files + +set -eu + +script_dir=3D"$( + cd "$(dirname "$0")" + echo "${PWD}" +)" + +exclude_list=3D"${ECLAIR_PROJECT_ROOT}/docs/misra/exclude-list.json" + +# Generate the exclude list file +"${script_dir}/adopted.sh" "${exclude_list}" diff --git a/automation/eclair_analysis/ECLAIR/out_of_scope.ecl b/automatio= n/eclair_analysis/ECLAIR/out_of_scope.ecl index e1ec4a607c63..2245ca8c3df5 100644 --- a/automation/eclair_analysis/ECLAIR/out_of_scope.ecl +++ b/automation/eclair_analysis/ECLAIR/out_of_scope.ecl @@ -1,53 +1,5 @@ --doc_begin=3D"Imported from Linux: ignore for now." --file_tag+=3D{adopted,"^xen/common/libfdt/.*$"} --file_tag+=3D{adopted,"^xen/include/xen/libfdt/.*$"} --file_tag+=3D{adopted,"^xen/common/xz/.*$"} --file_tag+=3D{adopted,"^xen/common/zstd/.*$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/apei/.*$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/tables/.*$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/utilities/.*$"} --file_tag+=3D{adopted,"^xen/drivers/video/font_.*$"} --file_tag+=3D{adopted,"^xen/arch/arm/arm64/cpufeature\\.c$"} --file_tag+=3D{adopted,"^xen/arch/arm/arm64/insn\\.c$"} --file_tag+=3D{adopted,"^xen/arch/arm/arm64/lib/find_next_bit\\.c$"} --file_tag+=3D{adopted,"^xen/common/bitmap\\.c$"} --file_tag+=3D{adopted,"^xen/common/bunzip2\\.c$"} --file_tag+=3D{adopted,"^xen/common/earlycpio\\.c$"} --file_tag+=3D{adopted,"^xen/common/inflate\\.c$"} --file_tag+=3D{adopted,"^xen/common/lzo\\.c$"} --file_tag+=3D{adopted,"^xen/common/lz4/decompress\\.c$"} --file_tag+=3D{adopted,"^xen/common/radix-tree\\.c$"} --file_tag+=3D{adopted,"^xen/common/ubsan/ubsan\\.c$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/hwregs\\.c$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/numa\\.c$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/osl\\.c$"} --file_tag+=3D{adopted,"^xen/drivers/acpi/tables\\.c$"} --file_tag+=3D{adopted,"^xen/include/xen/acpi\\.h$"} --file_tag+=3D{adopted,"^xen/include/acpi/acpiosxf\\.h$"} --file_tag+=3D{adopted,"^xen/include/acpi/acpixf\\.h$"} --file_tag+=3D{adopted,"^xen/lib/list-sort\\.c$"} --file_tag+=3D{adopted,"^xen/lib/rbtree\\.c$"} --file_tag+=3D{adopted,"^xen/lib/xxhash.*\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/acpi/boot\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/acpi/cpu_idle\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/acpi/cpufreq/cpufreq\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/acpi/cpuidle_menu\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/acpi/lib\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/amd\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/centaur\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/common\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/hygon\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/intel\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/intel_cacheinfo\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/mcheck/non-fatal\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/mtrr/.*$"} --file_tag+=3D{adopted,"^xen/arch/x86/cpu/mwait-idle\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/delay\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/dmi_scan\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/mpparse\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/srat\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/time\\.c$"} --file_tag+=3D{adopted,"^xen/arch/x86/x86_64/mmconf-fam10h\\.c$"} +-doc_begin=3D"libfdt is out of scope." +-file_tag+=3D{out_of_scope,"^xen/include/xen/libfdt/.*$"} -doc_end =20 -doc_begin=3D"Intel specific source files are out of scope." @@ -69,18 +21,6 @@ -file_tag+=3D{out_of_scope,"^xen/arch/x86/include/asm/intel-family\\.h$"} -doc_end =20 --doc_begin=3D"Not in scope initially as it generates many violations and i= t is not enabled in safety configurations." --file_tag+=3D{adopted,"^xen/xsm/flask/.*$"} --doc_end - --doc_begin=3D"unlz4.c implementation by Yann Collet, the others un* are fr= om Linux, ignore for now." --file_tag+=3D{adopted,"^xen/common/un.*\\.c$"} --doc_end - --doc_begin=3D"Origin is external and documented in xen/crypto/README.sourc= e ." --file_tag+=3D{adopted,"^xen/crypto/.*$"} --doc_end - -doc_begin=3D"Files imported from the gnu-efi package" -file_tag+=3D{adopted,"^xen/include/efi/.*$"} -file_tag+=3D{adopted,"^xen/arch/x86/include/asm/x86_64/efibind\\.h$"} diff --git a/automation/eclair_analysis/ECLAIR/print_analyzed_files.sh b/au= tomation/eclair_analysis/ECLAIR/print_analyzed_files.sh index c19a8ecbd061..7d231271617c 100755 --- a/automation/eclair_analysis/ECLAIR/print_analyzed_files.sh +++ b/automation/eclair_analysis/ECLAIR/print_analyzed_files.sh @@ -46,7 +46,9 @@ fi "${ECLAIR_BIN_DIR}eclair_report" -db=3D"${DB}" -files_txt=3D"${files_txt}" =20 { - # Extracting out of scope code + # Extracting out of scope and adopted code + adopted_ecl=3D"${script_dir}/adopted.ecl" + extrapolate_regex adopted, "${adopted_ecl}" out_of_scope_ecl=3D"${script_dir}/out_of_scope.ecl" extrapolate_regex adopted, "${out_of_scope_ecl}" extrapolate_regex out_of_scope_tools, "${out_of_scope_ecl}" --=20 2.34.1