Check file permissions in the check_format script

Change-Id: I572b24b2f4f149333f2e4b04f6f4961de9c23373
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/427539
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Ben Walker 2018-10-01 11:47:23 -07:00 committed by Jim Harris
parent 48f70f48cf
commit d705ab93e1
11 changed files with 48 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#! /usr/bin/python3
#!/usr/bin/python3
import shutil
import subprocess

View File

@ -8,6 +8,51 @@ set -e
rc=0
echo -n "Checking file permissions..."
while read -r perm _res0 _res1 path; do
if [ ! -f "$path" ]; then
continue
fi
fname=$(basename -- "$path")
case ${fname##*.} in
c|h|cpp|cc|cxx|hh|hpp|md|html|js|json|svg|Doxyfile|yml|LICENSE|README|conf|in|Makefile|mk|gitignore|go|txt)
# These file types should never be executable
if [ "$perm" -eq 100755 ]; then
echo "ERROR: $path is marked executable but is a code file."
rc=1
fi
;;
*)
shebang=$(head -n 1 $path | cut -c1-3)
# git only tracks the execute bit, so will only ever return 755 or 644 as the permission.
if [ "$perm" -eq 100755 ]; then
# If the file has execute permission, it should start with a shebang.
if [ "$shebang" != "#!/" ]; then
echo "ERROR: $path is marked executable but does not start with a shebang."
rc=1
fi
else
# If the file doesnot have execute permissions, it should not start with a shebang.
if [ "$shebang" = "#!/" ]; then
echo "ERROR: $path is not marked executable but starts with a shebang."
rc=1
fi
fi
;;
esac
done <<< $(git grep -I --name-only --untracked -e . | git ls-files -s)
if [ $rc -eq 0 ]; then
echo " OK"
fi
exit 0
if hash astyle; then
echo -n "Checking coding style..."
if [ "$(astyle -V)" \< "Artistic Style Version 3" ]

View File

@ -1,4 +1,4 @@
#! /usr/bin/env bash
#!/usr/bin/env bash
# Please run this script as root.
set -e

0
scripts/rpc/bdev.py Executable file → Normal file
View File

0
test/bdev/bdevperf/bdevperf.c Executable file → Normal file
View File

View File

@ -1,4 +1,4 @@
#! /usr/bin/env bash
#!/usr/bin/env bash
# Virtual Machine environment requirements:
# 8 GiB of RAM (for DPDK)

0
test/json_config/common.sh Executable file → Normal file
View File

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python3
import io
import time
import sys

View File

@ -1,5 +1,3 @@
#!/usr/bin/env bash
BASE_DIR=$(readlink -f $(dirname $0))
[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../ && pwd)"
rpc_py="$TEST_DIR/scripts/rpc.py "

View File

@ -1,4 +1,3 @@
#!/usr/bin/env bash
set -xe
testdir=$(readlink -f $(dirname $0))

0
test/unit/lib/bdev/crypto.c/crypto_ut.c Executable file → Normal file
View File