From 21b537a65179ec89a999dcd755fd9b41a37578f0 Mon Sep 17 00:00:00 2001 From: Ao Xu Date: Tue, 15 May 2018 15:59:14 +0800 Subject: [PATCH] script: amlogic: add code scan script PD#166377: script: amlogic: add code scan script Add code scan script. Usage: ./script/amlogic/code_scan.sh [path] Examples: # scan all code ./script/amlogic/code_scan.sh # scan specified directory ./script/amlogic/code_scan.sh drivers/amlogic scan result is in src code's parent directory, named coverity_html Change-Id: I069cd99d08014cc50a3bf127e199690649e196c8 Signed-off-by: Ao Xu --- scripts/amlogic/code_scan.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/amlogic/code_scan.sh diff --git a/scripts/amlogic/code_scan.sh b/scripts/amlogic/code_scan.sh new file mode 100755 index 0000000..4c2da917 --- /dev/null +++ b/scripts/amlogic/code_scan.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +export PATH=/proj/coverity/cov-analysis/bin/:$PATH +export CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- +export KERNEL_PATH=`pwd` +export KERNEL_OUTPUT_PATH="$KERNEL_PATH/../kernel_output/" +export COVERITY_OUTPUT_PATH="$KERNEL_PATH/../coverity_output/" +export COVERITY_HTML_PATH="$KERNEL_PATH/../coverity_html/" + +if [ -n "$1" ]; then + if [ -d "$KERNEL_PATH/$1" ]; then + echo "scan path: $1" + else + echo "you should input a right module path" + exit 1 + fi +fi + +echo "kernel distclean" +make ARCH=arm64 O="$KERNEL_OUTPUT_PATH" distclean +rm -rf "$COVERITY_HTML_PATH" + + +make ARCH=arm64 O="$KERNEL_OUTPUT_PATH" meson64_defconfig +cov-build --dir $COVERITY_OUTPUT_PATH make ARCH=arm64 O="$KERNEL_OUTPUT_PATH" -j8 Image UIMAGE_LOADADDR=0x1080000 || echo "Compile Image Fail !!" +if [ -n "$1" ]; then + cov-analyze --dir "$COVERITY_OUTPUT_PATH" --strip-path "$KERNEL_PATH" --tu-pattern "file(\"$1\")" --all +else + cov-analyze --dir "$COVERITY_OUTPUT_PATH" --strip-path "$KERNEL_PATH" --all +fi +cov-format-errors --dir "$COVERITY_OUTPUT_PATH" --strip-path "$KERNEL_PATH" --html-output "$COVERITY_HTML_PATH" --filesort -x + +rm -rf "$COVERITY_HTML_PATH/emit" -- 2.7.4