[lxc-devel] [lxd/master] Explicitly pass shell type to shellcheck and remove shebangs from test files

albertodonato on Github lxc-bot at linuxcontainers.org
Thu Apr 27 21:39:46 UTC 2017


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/20170427/4e27980a/attachment.bin>
-------------- next part --------------
From 02aaffe66c6519a0b7db4a9759f4ba91b097fcf7 Mon Sep 17 00:00:00 2001
From: Alberto Donato <alberto.donato at canonical.com>
Date: Thu, 27 Apr 2017 20:38:30 +0200
Subject: [PATCH] Explicitly pass shell type to shellcheck.

Signed-off-by: Alberto Donato <alberto.donato at canonical.com>
---
 test/backends/btrfs.sh          | 2 --
 test/backends/dir.sh            | 1 -
 test/backends/lvm.sh            | 2 --
 test/backends/zfs.sh            | 2 --
 test/suites/backup.sh           | 2 --
 test/suites/basic.sh            | 2 --
 test/suites/concurrent.sh       | 2 --
 test/suites/config.sh           | 1 -
 test/suites/database_update.sh  | 2 --
 test/suites/deps.sh             | 2 --
 test/suites/devlxd.sh           | 2 --
 test/suites/exec.sh             | 2 --
 test/suites/fdleak.sh           | 2 --
 test/suites/filemanip.sh        | 2 --
 test/suites/fuidshift.sh        | 2 --
 test/suites/idmap.sh            | 2 --
 test/suites/image.sh            | 2 --
 test/suites/init.sh             | 2 --
 test/suites/migration.sh        | 2 --
 test/suites/network.sh          | 2 --
 test/suites/pki.sh              | 2 --
 test/suites/profiling.sh        | 2 --
 test/suites/remote.sh           | 2 --
 test/suites/security.sh         | 2 --
 test/suites/serverconfig.sh     | 2 --
 test/suites/snapshots.sh        | 2 --
 test/suites/static_analysis.sh  | 4 +---
 test/suites/storage.sh          | 2 --
 test/suites/storage_profiles.sh | 2 --
 test/suites/template.sh         | 2 --
 30 files changed, 1 insertion(+), 59 deletions(-)

diff --git a/test/backends/btrfs.sh b/test/backends/btrfs.sh
index ffae1cc..82bc9f4 100644
--- a/test/backends/btrfs.sh
+++ b/test/backends/btrfs.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 btrfs_setup() {
   # shellcheck disable=2039
   local LXD_DIR
diff --git a/test/backends/dir.sh b/test/backends/dir.sh
index 5a0cd53..f4f5af7 100644
--- a/test/backends/dir.sh
+++ b/test/backends/dir.sh
@@ -1,4 +1,3 @@
-#!/bin/sh
 # Nothing need be done for the dir backed, but we still need some functions.
 # This file can also serve as a skel file for what needs to be done to
 # implement a new backend.
diff --git a/test/backends/lvm.sh b/test/backends/lvm.sh
index 4c8ee9f..b9cbe84 100644
--- a/test/backends/lvm.sh
+++ b/test/backends/lvm.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 lvm_setup() {
   # shellcheck disable=2039
   local LXD_DIR
diff --git a/test/backends/zfs.sh b/test/backends/zfs.sh
index 52bd0a8..3545e58 100644
--- a/test/backends/zfs.sh
+++ b/test/backends/zfs.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 zfs_setup() {
   # shellcheck disable=2039
   local LXD_DIR
diff --git a/test/suites/backup.sh b/test/suites/backup.sh
index 25f4cf1..0db9e3f 100644
--- a/test/suites/backup.sh
+++ b/test/suites/backup.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_container_import() {
   ensure_import_testimage
 
diff --git a/test/suites/basic.sh b/test/suites/basic.sh
index 5c4aa8c..070b0c8 100644
--- a/test/suites/basic.sh
+++ b/test/suites/basic.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_basic_usage() {
   # shellcheck disable=2039
   local lxd_backend
diff --git a/test/suites/concurrent.sh b/test/suites/concurrent.sh
index 33362bc..107f4f0 100644
--- a/test/suites/concurrent.sh
+++ b/test/suites/concurrent.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_concurrent() {
   if [ -z "${LXD_CONCURRENT:-}" ]; then
     echo "==> SKIP: LXD_CONCURRENT isn't set"
diff --git a/test/suites/config.sh b/test/suites/config.sh
index f72d75b..d3e9a19 100644
--- a/test/suites/config.sh
+++ b/test/suites/config.sh
@@ -1,4 +1,3 @@
-#!/bin/sh
 ensure_removed() {
   bad=0
   lxc exec foo -- stat /dev/ttyS0 && bad=1
diff --git a/test/suites/database_update.sh b/test/suites/database_update.sh
index 4365f72..7b37374 100644
--- a/test/suites/database_update.sh
+++ b/test/suites/database_update.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_database_update(){
   LXD_MIGRATE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
   MIGRATE_DB=${LXD_MIGRATE_DIR}/lxd.db
diff --git a/test/suites/deps.sh b/test/suites/deps.sh
index 04a58f6..2ec30a9 100644
--- a/test/suites/deps.sh
+++ b/test/suites/deps.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_check_deps() {
   ! ldd "$(which lxc)" | grep -q liblxc
 }
diff --git a/test/suites/devlxd.sh b/test/suites/devlxd.sh
index 722d247..ea1a6e8 100644
--- a/test/suites/devlxd.sh
+++ b/test/suites/devlxd.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_devlxd() {
   ensure_import_testimage
 
diff --git a/test/suites/exec.sh b/test/suites/exec.sh
index 8adb7f3..db06ce6 100644
--- a/test/suites/exec.sh
+++ b/test/suites/exec.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_concurrent_exec() {
   if [ -z "${LXD_CONCURRENT:-}" ]; then
     echo "==> SKIP: LXD_CONCURRENT isn't set"
diff --git a/test/suites/fdleak.sh b/test/suites/fdleak.sh
index 78c518f..c2cdf48 100644
--- a/test/suites/fdleak.sh
+++ b/test/suites/fdleak.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_fdleak() {
   LXD_FDLEAK_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
   chmod +x "${LXD_FDLEAK_DIR}"
diff --git a/test/suites/filemanip.sh b/test/suites/filemanip.sh
index 6a4dd43..2ad9dd7 100644
--- a/test/suites/filemanip.sh
+++ b/test/suites/filemanip.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_filemanip() {
   # Workaround for shellcheck getting confused by "cd"
   set -e
diff --git a/test/suites/fuidshift.sh b/test/suites/fuidshift.sh
index c4a58a8..8b3a1f1 100644
--- a/test/suites/fuidshift.sh
+++ b/test/suites/fuidshift.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_common_fuidshift() {
   # test some bad arguments
   fail=0
diff --git a/test/suites/idmap.sh b/test/suites/idmap.sh
index e16b1b9..91fab5d 100644
--- a/test/suites/idmap.sh
+++ b/test/suites/idmap.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_idmap() {
   # Check that we have a big enough range for this test
   if [ ! -e /etc/subuid ] && [ ! -e /etc/subgid ]; then
diff --git a/test/suites/image.sh b/test/suites/image.sh
index f05e128..87a3af9 100644
--- a/test/suites/image.sh
+++ b/test/suites/image.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_image_expiry() {
   # shellcheck disable=2039
   local LXD2_DIR LXD2_ADDR
diff --git a/test/suites/init.sh b/test/suites/init.sh
index aa36253..8f5790d 100644
--- a/test/suites/init.sh
+++ b/test/suites/init.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_lxd_autoinit() {
   # - lxd init --auto --storage-backend zfs
   # and
diff --git a/test/suites/migration.sh b/test/suites/migration.sh
index bf97540..3fb3714 100644
--- a/test/suites/migration.sh
+++ b/test/suites/migration.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_migration() {
   # setup a second LXD
   # shellcheck disable=2039
diff --git a/test/suites/network.sh b/test/suites/network.sh
index fe66bea..9c849f1 100644
--- a/test/suites/network.sh
+++ b/test/suites/network.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_network() {
   ensure_import_testimage
   ensure_has_localhost_remote "${LXD_ADDR}"
diff --git a/test/suites/pki.sh b/test/suites/pki.sh
index aad7ee0..001067f 100644
--- a/test/suites/pki.sh
+++ b/test/suites/pki.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_pki() {
   if [ ! -d "/usr/share/easy-rsa/" ]; then
     echo "==> SKIP: The pki test requires easy-rsa to be installed"
diff --git a/test/suites/profiling.sh b/test/suites/profiling.sh
index c9ee794..769a558 100644
--- a/test/suites/profiling.sh
+++ b/test/suites/profiling.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_cpu_profiling() {
   LXD3_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
   chmod +x "${LXD3_DIR}"
diff --git a/test/suites/remote.sh b/test/suites/remote.sh
index 35afe72..845ef99 100644
--- a/test/suites/remote.sh
+++ b/test/suites/remote.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_remote_url() {
   # shellcheck disable=2153
   for url in "${LXD_ADDR}" "https://${LXD_ADDR}"; do
diff --git a/test/suites/security.sh b/test/suites/security.sh
index d2106f0..522dbad 100644
--- a/test/suites/security.sh
+++ b/test/suites/security.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_security() {
   ensure_import_testimage
   ensure_has_localhost_remote "${LXD_ADDR}"
diff --git a/test/suites/serverconfig.sh b/test/suites/serverconfig.sh
index 7b2a100..ba36f20 100644
--- a/test/suites/serverconfig.sh
+++ b/test/suites/serverconfig.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_server_config() {
   LXD_SERVERCONFIG_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
   spawn_lxd "${LXD_SERVERCONFIG_DIR}" true
diff --git a/test/suites/snapshots.sh b/test/suites/snapshots.sh
index efd941b..d3f8c59 100644
--- a/test/suites/snapshots.sh
+++ b/test/suites/snapshots.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_snapshots() {
   snapshots
 
diff --git a/test/suites/static_analysis.sh b/test/suites/static_analysis.sh
index f2f6dc7..fbeeff5 100644
--- a/test/suites/static_analysis.sh
+++ b/test/suites/static_analysis.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 safe_pot_hash() {
   sed -e "/Project-Id-Version/,/Content-Transfer-Encoding/d" -e "/^#/d" "po/lxd.pot" | md5sum | cut -f1 -d" "
 }
@@ -18,7 +16,7 @@ test_static_analysis() {
 
     # Shell static analysis
     if which shellcheck >/dev/null 2>&1; then
-      shellcheck test/main.sh test/suites/* test/backends/*
+      shellcheck --shell sh test/main.sh test/suites/* test/backends/*
     else
       echo "shellcheck not found, shell static analysis disabled"
     fi
diff --git a/test/suites/storage.sh b/test/suites/storage.sh
index 3a46b42..0efe42f 100644
--- a/test/suites/storage.sh
+++ b/test/suites/storage.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_storage() {
   # shellcheck disable=2039
   local LXD_STORAGE_DIR lxd_backend  
diff --git a/test/suites/storage_profiles.sh b/test/suites/storage_profiles.sh
index d0fb595..1b93432 100644
--- a/test/suites/storage_profiles.sh
+++ b/test/suites/storage_profiles.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_storage_profiles() {
   # shellcheck disable=2039
 
diff --git a/test/suites/template.sh b/test/suites/template.sh
index 398b79b..da6b1d5 100644
--- a/test/suites/template.sh
+++ b/test/suites/template.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 test_template() {
   # Import a template which only triggers on create
   deps/import-busybox --alias template-test --template create


More information about the lxc-devel mailing list