[lxc-devel] [lxd/master] More tests static analysis

stgraber on Github lxc-bot at linuxcontainers.org
Fri Feb 2 10:23:47 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180202/d866f979/attachment.bin>
-------------- next part --------------
From 8cf30e6f16ef15a74431a514161159a060e936dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 2 Feb 2018 11:21:41 +0100
Subject: [PATCH 1/2] tests: Check for mixed tabs/spaces and trailing
 whitespaces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 test/suites/static_analysis.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/test/suites/static_analysis.sh b/test/suites/static_analysis.sh
index b0d8672ce..81b8dd67f 100644
--- a/test/suites/static_analysis.sh
+++ b/test/suites/static_analysis.sh
@@ -29,6 +29,20 @@ test_static_analysis() {
       false
     fi
 
+    ## Mixed tabs/spaces in scripts
+    OUT=$(grep -Pr "\t" . | grep "\.sh:" || true)
+    if [ -n "${OUT}" ]; then
+      echo "ERROR: mixed tabs and spaces in script: ${OUT}"
+      false
+    fi
+
+    ## Trailing whitespace in scripts
+    OUT=$(grep -r " $" . | grep "\.sh:" || true)
+    if [ -n "${OUT}" ]; then
+      echo "ERROR: trailing whitespace in script: ${OUT}"
+      false
+    fi
+
     ## go vet, if it exists
     if go help vet >/dev/null 2>&1; then
       go vet ./...

From e4eeb81f4bfc0555a5a6ecda3cf6f167357b2775 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 2 Feb 2018 11:22:25 +0100
Subject: [PATCH 2/2] tests: Cleanup trailing whitespaces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 test/suites/init_preseed.sh        | 2 +-
 test/suites/kernel_limits.sh       | 2 +-
 test/suites/proxy.sh               | 1 -
 test/suites/storage.sh             | 2 +-
 test/suites/storage_driver_ceph.sh | 2 +-
 5 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/test/suites/init_preseed.sh b/test/suites/init_preseed.sh
index e078304e0..4245ac596 100644
--- a/test/suites/init_preseed.sh
+++ b/test/suites/init_preseed.sh
@@ -59,7 +59,7 @@ profiles:
       parent: lxdt$$
       type: nic
 EOF
-  
+
     lxc info | grep -q 'core.https_address: 127.0.0.1:9999'
     lxc info | grep -q 'images.auto_update_interval: "15"'
     lxc network list | grep -q "lxdt$$"
diff --git a/test/suites/kernel_limits.sh b/test/suites/kernel_limits.sh
index 0515be572..19490d533 100644
--- a/test/suites/kernel_limits.sh
+++ b/test/suites/kernel_limits.sh
@@ -20,7 +20,7 @@ test_kernel_limits() {
   soft=$(grep ^"Max open files" /proc/"${pid}"/limits | awk '{print $4}')
   hard=$(grep ^"Max open files" /proc/"${pid}"/limits | awk '{print $5}')
 
-  lxc delete --force limits 
+  lxc delete --force limits
 
   [ "${soft}" = "3000" ] && [ "${hard}" = "3000" ]
 }
diff --git a/test/suites/proxy.sh b/test/suites/proxy.sh
index 324c407eb..9017c253e 100755
--- a/test/suites/proxy.sh
+++ b/test/suites/proxy.sh
@@ -1,5 +1,4 @@
 test_proxy_device() {
-  
   MESSAGE="Proxy device test string"
   HOST_TCP_PORT=$(local_tcp_port)
 
diff --git a/test/suites/storage.sh b/test/suites/storage.sh
index bb089c2bb..88ba169b3 100644
--- a/test/suites/storage.sh
+++ b/test/suites/storage.sh
@@ -2,7 +2,7 @@ test_storage() {
   ensure_import_testimage
 
   # shellcheck disable=2039
-  local LXD_STORAGE_DIR lxd_backend  
+  local LXD_STORAGE_DIR lxd_backend
 
   lxd_backend=$(storage_backend "$LXD_DIR")
   LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX)
diff --git a/test/suites/storage_driver_ceph.sh b/test/suites/storage_driver_ceph.sh
index 2c28a7e88..b4211e693 100644
--- a/test/suites/storage_driver_ceph.sh
+++ b/test/suites/storage_driver_ceph.sh
@@ -2,7 +2,7 @@ test_storage_driver_ceph() {
   ensure_import_testimage
 
   # shellcheck disable=2039
-  local LXD_STORAGE_DIR lxd_backend  
+  local LXD_STORAGE_DIR lxd_backend
 
   lxd_backend=$(storage_backend "$LXD_DIR")
   LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX)


More information about the lxc-devel mailing list