tests: use -z / -n to test for string empty / non-empty
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 2 Aug 2022 19:21:21 +0000 (15:21 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 16 Aug 2022 19:50:22 +0000 (15:50 -0400)
shellcheck gives many warnings of this kind

    In env.sh.in line 44:
    if [ "x${BT_TESTS_CC_BIN:-}" = "x" ]; then
         ^---------------------^ SC2268 (style): Avoid x-prefix in comparisons as it no longer serves a purpose.

    Did you mean:
    if [ "${BT_TESTS_CC_BIN:-}" = "" ]; then

Fix them by using test's -z and -n switches, which test for empty and
non-empty strings, respectively.  In some cases, we are checking for the
string to have a specific value ( = "x1"), in which case I left the
comparison, but just removed the leading x's.

Change-Id: I3cd841d881916696419d540ed629e685d2edce9d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8635
Tested-by: jenkins <jenkins@lttng.org>
48 files changed:
tests/bindings/python/bt2/test_python_bt2
tests/cli/convert/test_auto_source_discovery_grouping
tests/cli/convert/test_auto_source_discovery_log_level
tests/cli/convert/test_auto_source_discovery_params
tests/cli/convert/test_convert_args
tests/cli/list-plugins/test_list_plugins
tests/cli/params/test_params
tests/cli/query/test_query
tests/cli/test_exit_status
tests/cli/test_help
tests/cli/test_intersection
tests/cli/test_output_ctf_metadata
tests/cli/test_output_path_ctf_non_lttng_trace
tests/cli/test_packet_seq_num
tests/cli/test_trace_copy
tests/cli/test_trace_read
tests/cli/test_trimmer
tests/ctf-writer/test_ctf_writer
tests/lib/conds/test_conds
tests/lib/test_plugin
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_succeed
tests/plugins/flt.utils.muxer/succeed/test_succeed
tests/plugins/flt.utils.trimmer/test_trimming
tests/plugins/sink.ctf.fs/succeed/test_succeed
tests/plugins/sink.ctf.fs/test_assume_single_trace
tests/plugins/sink.ctf.fs/test_stream_names
tests/plugins/sink.text.details/succeed/test_succeed
tests/plugins/sink.text.pretty/test_enum
tests/plugins/sink.text.pretty/test_pretty_python
tests/plugins/src.ctf.fs/fail/test_fail
tests/plugins/src.ctf.fs/query/test_query_metadata_info
tests/plugins/src.ctf.fs/query/test_query_support_info
tests/plugins/src.ctf.fs/query/test_query_trace_info
tests/plugins/src.ctf.fs/succeed/test_succeed
tests/plugins/src.ctf.fs/test_deterministic_ordering
tests/plugins/src.ctf.lttng-live/test_live
tests/python-plugin-provider/test_python_plugin_provider
tests/utils/env.sh.in
tests/utils/run_python_bt2
tests/utils/utils.sh

index 540065887d641ca3f7508573a3d888b825b020b5..a32362f3d8784a56ca591b7c27f49ceae1f92bb0 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index ba7f558a9e0d3878ca04b5ab0ff481a8e83aabe6..e476c96cb435a6448575c444c9b28d37c48df25b 100755 (executable)
@@ -7,7 +7,7 @@
 
 # Test the auto source disovery mechanism of the CLI.
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index b7163234eb6d3bcb723f3024f4550d5687465a74..56df66fab33d855f8edfcef7ce569d3bb8f1114f 100755 (executable)
@@ -8,7 +8,7 @@
 # Test how log level options are applied to sources auto-discovered by the
 # convert command.
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 446e6c426d25cc3f8023de006dd93c8c4c49cdcf..65ef536fb1d0aafde4dc4d6e1fc0dc9c1616615b 100755 (executable)
@@ -8,7 +8,7 @@
 # Test how parameters are applied to sources auto-discovered by the convert
 # command.
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 7ac9843e0b9275d2d5c1bcfd4f2daa57b7731eac..cd7aab242f909bdb43eb96aebec443c892b982d9 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 3e42d1adc4aec0bc44d2a1e1f896611d37b384ee..595eb4db3db3b500ebc263955c0ca1c81dff5c33 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2019 EfficiOS Inc.
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 8f13ca60e7a5cccdcc207512292bee39baf4be1d..c207532a50e888f2a908dbdf9f777f3c60e35f6e 100755 (executable)
@@ -8,7 +8,7 @@
 # Test how parameters are applied to sources auto-discovered by the convert
 # command.
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 21a3546758b4521722e843ff8ea015d77cc383be..e44d67779b629417291dca8a403d833db0ed41c0 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index d76d5214e6c9973dd462e4d2dcecfaf5a6bc5c7c..905a2eb37a370aa12f4b36802229ffe88b5e2c26 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index fb7cb59834adb78bb3e471b7f4071db454f6badc..dca6cfe58dc11f5cce127b8d47327c2dad191670 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index 2077ab94836e194ab567537f81987856d07a9c34..df0f6504ad2c63411740f3121d1740a790eea0d3 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index a97af1df2f222a825592f9a6b7469a60a03daec2..58969f8a9b9db7b777b099abdba82ef451ffdffc 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index d7700931be8c19995848460e15e1e66abae77ffa..fc0158bfc777dd4453e8537f9a978291c2dd0ceb 100755 (executable)
@@ -17,7 +17,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index c74b2957e1ae036f6f4251739c489b63b5e24a51..341a9c26eaa3a2e1af9cd0e1dab329ee0f058562 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index 761465e5da9c43b503018bf8ee4bccabe6af8175..e8c9b2c86210a391089953e89733a240ed341d34 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index ce874af16b3b4586edae267c0e30d204219bbd62..474015e08e5a2dccc246d9c339a616c5dfe373ae 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index c40db035c370fbb26269614c9a15c075f9799952..4b415b475a98f01187daea52d247bf6cac99212b 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index 15ad2e32a6a34d7164f764b71512815f543af6b0..7616b691643f05ead02e729117e2a8e44740a8e8 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index 851079a4e7aa3876cf9c23404cd42cf448104274..af66f6d299fe2cac951b65a63f1bee873bde8a7f 100755 (executable)
@@ -4,7 +4,7 @@
 #
 # Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index f16f1bd0520e98fab1565ee671fcff4d083423a9..b9a3fcdafc7aca2fc9eb60e56680e629589de335 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index 781d4889ba4bf88f0b92e6e7c932db4c8eb3bc61..2703f3e71c293920cd9929f9334778d558ae3a8c 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 30e7e7a3094426e07c7f5cd51f5e56626caea7d8..d8f7ab43961a51f212c6e4548f06a3986c9ff4c1 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 7abf70c38125eac9b95a23fda4efe6d2d58bdd79..60407c50ffafe595842e3adc28640524a32e7298 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 404ffe587d4a1477e31604c03fc87eb7b8655c2f..d0e59e280b7c99ec7350d1f2b8982bd8279d96e0 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index fa26488737b8a7d2f0118b8671bfed8ec215005d..03380c553ae04e21b0bf01e4969557a362fea316 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 2e71d00c7dbb39cb8c9f6a0e5c71747004eca116..d60e08c558c2a77055cc299916363a7a01d8f24c 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 0248299c1e6e4b2400e36c9a2a8b61513b194379..8656272d9bbd5803978d03e9af6dda698b04843e 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index b8deff283dbfe2abfa884187b554d549a6409f8a..8a7a3ebbfa6e2ffeb64c69efc18785f13000e683 100755 (executable)
@@ -6,7 +6,7 @@
 # Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 3825b8987fda5e71007a07f8bfa80910f18c8928..1df6fbb2f0cf7b086e18ccf81e33a70cd8c5c6b6 100755 (executable)
@@ -14,7 +14,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 98cd6b95772c9355e2000920835f8a84b68a82bc..578ac223600ce80e5af30320fe722a9f9145699f 100755 (executable)
@@ -9,7 +9,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index f7ae8cecc595a4f3fafd06dc08624c6610a60f33..f46fe31f00d4d22d7a498aa0e1b177029d126eb2 100755 (executable)
@@ -10,7 +10,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index ffca9bdac862f35f95ea96d2c7daea827fe35191..6d47c09e2a6e18a35b79cd30c80bafc4c910e99c 100755 (executable)
@@ -13,7 +13,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index dd84e04474e16d3bf040466b001befbf213747b3..6af7aa05cfe83b2e7b4843b1f3f3d7f54c17cbdb 100755 (executable)
@@ -9,7 +9,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index a60a1dbf97cd3ecebf0f3256fa36338e4b9ab4f4..c071eb173c71d4e42eb074e5a1a35f58152a9f39 100755 (executable)
@@ -12,7 +12,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 6250b46d592159bf5a171df1fc33261ced79b605..9c21155dce364fe753f203fd1c594986d5354149 100755 (executable)
@@ -7,7 +7,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index b943efc0190a3d6f4215b089058b24afd341ba8f..723448b72ea85768ed828866f5a7704892869c29 100755 (executable)
@@ -8,7 +8,7 @@
 # not all covered by the main babeltrace tests with traces.
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 3fdac62ceaed84cd92177501c78c6ed655b0a499..fe395e773b5514b5e7ec84db87c608b4d5a8d613 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 652ec6f4bd302a87cb3271e8bceb8d1ab6c5653f..1c75a0d28a6391fafa48ffe390b6075cb908732d 100755 (executable)
@@ -10,7 +10,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index 9c2e4d0afd9dcea49229eda0e3cd2a65d6dbdbed..6db90091d321198da45332fc2679ed9e91cfeed7 100755 (executable)
@@ -8,7 +8,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index f1d72cb35c8d6b04bb33ea8005cf796da4eee6ea..51044628d71be5bc1c7f1283f45866f3e5597bc9 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index f7e3ce5e0da0f3520bf99ccba49c5b00fb4324e2..49f316bb85a960513455e88d23c5e3935e23a364 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index 16fac9abd5b5ccf579110395a5c23608286eff31..81d87593e3ee7e824c736644e121205b79ec5937 100755 (executable)
@@ -13,7 +13,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
index 02a76c20a92581f1ede08c121bcd414746e0e0c2..9eb8b8f64b6994408d41bb2a4356c442a9e87d74 100755 (executable)
@@ -28,7 +28,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index f5ba914b5af8af44f272583febe2c9b0427e8dc5..e1766e158653039f80a2fb0984e5f073afc97a22 100755 (executable)
@@ -13,7 +13,7 @@
 
 SH_TAP=1
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
index 1e66c6ae8c9cc94f450668f22f71d5073a00f787..542c174874363c3f00b0ca819df8b1915fce10a7 100755 (executable)
@@ -5,7 +5,7 @@
 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
 #
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
index 96f4fc0995b3e5526457e03e7d9ecedcc20c0fd3..ab5b47e783714804a7ed747e165cddd328c88cc3 100644 (file)
@@ -4,44 +4,44 @@
 #
 
 ### Base paths to test suite ###
-if [ "x${BT_TESTS_SRCDIR:-}" = "x" ]; then
+if [ -z "${BT_TESTS_SRCDIR:-}" ]; then
        BT_TESTS_SRCDIR="@abs_top_srcdir@/tests"
 fi
 export BT_TESTS_SRCDIR
 
-if [ "x${BT_TESTS_BUILDDIR:-}" = "x" ]; then
+if [ -z "${BT_TESTS_BUILDDIR:-}" ]; then
        BT_TESTS_BUILDDIR="@abs_top_builddir@/tests"
 fi
 export BT_TESTS_BUILDDIR
 
 
 ### External Tools ###
-if [ "x${BT_TESTS_AWK_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_AWK_BIN:-}" ]; then
        BT_TESTS_AWK_BIN="@AWK@"
 fi
 export BT_TESTS_AWK_BIN
 
-if [ "x${BT_TESTS_GREP_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_GREP_BIN:-}" ]; then
        BT_TESTS_GREP_BIN="@GREP@"
 fi
 export BT_TESTS_GREP_BIN
 
-if [ "x${BT_TESTS_PYTHON_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_PYTHON_BIN:-}" ]; then
        BT_TESTS_PYTHON_BIN="@PYTHON@"
 fi
 export BT_TESTS_PYTHON_BIN
 
-if [ "x${BT_TESTS_PYTHON_CONFIG_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_PYTHON_CONFIG_BIN:-}" ]; then
        BT_TESTS_PYTHON_CONFIG_BIN="@PYTHON_CONFIG@"
 fi
 export BT_TESTS_PYTHON_CONFIG_BIN
 
-if [ "x${BT_TESTS_SED_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_SED_BIN:-}" ]; then
        BT_TESTS_SED_BIN="@SED@"
 fi
 export BT_TESTS_SED_BIN
 
-if [ "x${BT_TESTS_CC_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_CC_BIN:-}" ]; then
        BT_TESTS_CC_BIN="@CC@"
 fi
 export BT_TESTS_CC_BIN
@@ -49,7 +49,7 @@ export BT_TESTS_CC_BIN
 
 ### Optional features ###
 
-if [ "x${BT_TESTS_ENABLE_ASAN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_ENABLE_ASAN:-}" ]; then
        BT_TESTS_ENABLE_ASAN="@ENABLE_ASAN@"
 fi
 export BT_TESTS_ENABLE_ASAN
index fa5dd0cc4e5bca51a6302ece2e0c80907bbc9e59..574900a2c48c586484ec25c712b5cfd14d06b94c 100755 (executable)
@@ -14,7 +14,7 @@
 #     -t test_value.MapValueTestCase.test_deepcopy \
 #     ./tests/bindings/python/bt2
 
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
        UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
 else
        UTILSSH="$(dirname "$0")/../utils/utils.sh"
@@ -33,7 +33,7 @@ usage() {
        echo "the path to the built 'tests' directory."
 }
 
-if [ "x$*" = "x" ]; then
+if [ -z "$*" ]; then
        usage
        exit 1
 fi
index 3cbea1609d07666d0c046e65fe726422b35a7f37..6107a610453e3dff10cfe3138cb556a2ebee113d 100644 (file)
@@ -25,7 +25,7 @@ fi
 # We do a bit of translation to ease our life down the road for comparison.
 # Export it so that called executables can use it.
 # [1] https://en.wikipedia.org/wiki/Uname#Examples
-if [ "x${BT_TESTS_OS_TYPE:-}" = "x" ]; then
+if [ -z "${BT_TESTS_OS_TYPE:-}" ]; then
        BT_TESTS_OS_TYPE="$(uname -s)"
        case "$BT_TESTS_OS_TYPE" in
        MINGW*)
@@ -48,12 +48,12 @@ fi
 export BT_TESTS_OS_TYPE
 
 # Allow overriding the source and build directories
-if [ "x${BT_TESTS_SRCDIR:-}" = "x" ]; then
+if [ -z "${BT_TESTS_SRCDIR:-}" ]; then
        BT_TESTS_SRCDIR="$testsdir"
 fi
 export BT_TESTS_SRCDIR
 
-if [ "x${BT_TESTS_BUILDDIR:-}" = "x" ]; then
+if [ -z "${BT_TESTS_BUILDDIR:-}" ]; then
        BT_TESTS_BUILDDIR="$testsdir"
 fi
 export BT_TESTS_BUILDDIR
@@ -66,7 +66,7 @@ if [ -f "${BT_TESTS_BUILDDIR}/utils/env.sh" ]; then
 fi
 
 # Allow overriding the babeltrace2 executables
-if [ "x${BT_TESTS_BT2_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_BT2_BIN:-}" ]; then
        BT_TESTS_BT2_BIN="$BT_TESTS_BUILDDIR/../src/cli/babeltrace2"
        if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
                BT_TESTS_BT2_BIN="${BT_TESTS_BT2_BIN}.exe"
@@ -78,50 +78,50 @@ export BT_TESTS_BT2_BIN
 BT_PLUGINS_PATH="${BT_TESTS_BUILDDIR}/../src/plugins"
 
 # Allow overriding the babeltrace2 plugin path
-if [ "x${BT_TESTS_BABELTRACE_PLUGIN_PATH:-}" = "x" ]; then
+if [ -z "${BT_TESTS_BABELTRACE_PLUGIN_PATH:-}" ]; then
        BT_TESTS_BABELTRACE_PLUGIN_PATH="${BT_PLUGINS_PATH}/ctf:${BT_PLUGINS_PATH}/utils:${BT_PLUGINS_PATH}/text:${BT_PLUGINS_PATH}/lttng-utils"
 fi
 export BT_TESTS_BABELTRACE_PLUGIN_PATH
 
-if [ "x${BT_TESTS_PROVIDER_DIR:-}" = "x" ]; then
+if [ -z "${BT_TESTS_PROVIDER_DIR:-}" ]; then
        BT_TESTS_PROVIDER_DIR="${BT_TESTS_BUILDDIR}/../src/python-plugin-provider/.libs"
 fi
 export BT_TESTS_PROVIDER_DIR
 
 # Allow overriding the babeltrace2 executables
-if [ "x${BT_TESTS_PYTHONPATH:-}" = "x" ]; then
+if [ -z "${BT_TESTS_PYTHONPATH:-}" ]; then
        BT_TESTS_PYTHONPATH="${BT_TESTS_BUILDDIR}/../src/bindings/python/bt2/build/build_lib"
 fi
 export BT_TESTS_PYTHONPATH
 
 
 ### External Tools ###
-if [ "x${BT_TESTS_AWK_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_AWK_BIN:-}" ]; then
        BT_TESTS_AWK_BIN="awk"
 fi
 export BT_TESTS_AWK_BIN
 
-if [ "x${BT_TESTS_GREP_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_GREP_BIN:-}" ]; then
        BT_TESTS_GREP_BIN="grep"
 fi
 export BT_TESTS_GREP_BIN
 
-if [ "x${BT_TESTS_PYTHON_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_PYTHON_BIN:-}" ]; then
        BT_TESTS_PYTHON_BIN="python3"
 fi
 export BT_TESTS_PYTHON_BIN
 
-if [ "x${BT_TESTS_PYTHON_CONFIG_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_PYTHON_CONFIG_BIN:-}" ]; then
        BT_TESTS_PYTHON_CONFIG_BIN="python3-config"
 fi
 export BT_TESTS_PYTHON_CONFIG_BIN
 
-if [ "x${BT_TESTS_SED_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_SED_BIN:-}" ]; then
        BT_TESTS_SED_BIN="sed"
 fi
 export BT_TESTS_SED_BIN
 
-if [ "x${BT_TESTS_CC_BIN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_CC_BIN:-}" ]; then
        BT_TESTS_CC_BIN="cc"
 fi
 export BT_TESTS_CC_BIN
@@ -129,7 +129,7 @@ export BT_TESTS_CC_BIN
 
 ### Optional features ###
 
-if [ "x${BT_TESTS_ENABLE_ASAN:-}" = "x" ]; then
+if [ -z "${BT_TESTS_ENABLE_ASAN:-}" ]; then
        BT_TESTS_ENABLE_ASAN="0"
 fi
 export BT_TESTS_ENABLE_ASAN
@@ -142,7 +142,7 @@ BT_CTF_TRACES_PATH="${BT_TESTS_DATADIR}/ctf-traces"
 # By default, it will not source tap.sh.  If you want to output tap directly
 # from the test script, define the 'SH_TAP' variable to '1' before sourcing
 # this script.
-if [ "x${SH_TAP:-}" = x1 ]; then
+if [ "${SH_TAP:-}" = 1 ]; then
        # shellcheck source=./tap/tap.sh
        . "${BT_TESTS_SRCDIR}/utils/tap/tap.sh"
 fi
@@ -343,7 +343,7 @@ run_python_bt2() {
        # leaks, so we must unfortunately disable leak detection.  Append it to
        # existing ASAN_OPTIONS, such that we override the user's value if it
        # contains detect_leaks=1.
-       if [ "x${BT_TESTS_ENABLE_ASAN:-}" = "x1" ]; then
+       if [ "${BT_TESTS_ENABLE_ASAN:-}" = "1" ]; then
                lib_asan=$(${BT_TESTS_CC_BIN} -print-file-name=libasan.so)
 
                env_args+=("LD_PRELOAD=${lib_asan}:${LD_PRELOAD:-}")
@@ -365,11 +365,11 @@ run_python_bt2_test() {
        local test_runner_args=()
 
        test_runner_args+=("$test_dir")
-       if [ "x${test_pattern}" != "x" ]; then
+       if [ -n "${test_pattern}" ]; then
                test_runner_args+=("${test_pattern}")
        fi
 
-       if test "x${BT_TESTS_COVERAGE:-}" = "x1"; then
+       if test "${BT_TESTS_COVERAGE:-}" = "1"; then
                python_exec="check_coverage"
        else
                python_exec="${BT_TESTS_PYTHON_BIN}"
@@ -383,11 +383,11 @@ run_python_bt2_test() {
 
        ret=$?
 
-       if test "x${BT_TESTS_COVERAGE_REPORT:-}" = "x1"; then
+       if test "${BT_TESTS_COVERAGE_REPORT:-}" = "1"; then
                coverage report -m
        fi
 
-       if test "x${BT_TESTS_COVERAGE_HTML:-}" = "x1"; then
+       if test "${BT_TESTS_COVERAGE_HTML:-}" = "1"; then
                coverage html
        fi
 
This page took 0.04504 seconds and 4 git commands to generate.