obmc-console: fix segfault on missing config
The `obmc-console-client` allow to not specify configuration file for
active session. But at the same time it does not tolerate null pointer
passed as config. This leads to a segmentation fault due to a missing
configuration file.
Fix this small inconvenience.
Added testcase to make sure that obmc-console-client doesn't segfault
when invoked without any arguments.
Output without the fix:
'''
+ /home/dev/obmc-console/build/obmc-console-client
+ grep Connection refused
Segmentation fault (core dumped)
'''
Output with the fix:
'''
+ /home/ninad/dev/1110_ghe/obmc-console/build/obmc-console-client
+ grep Connection refused
+ cleanup
+ cd -
+ rm -rf /tmp/test_console_client_no_args_3245394.DZqk0S
'''
Change-Id: Ia83da8bca30e2be94e00066f20f2cbe2ccba23b6
Tested-by: Ninad Palsule <ninad@linux.ibm.com>
Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>
Signed-off-by: Igor Kononenko <i.kononenko.e@gmail.com>
diff --git a/test/meson.build b/test/meson.build
index d36d15c..61411b8 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -55,6 +55,7 @@
client_tests = [
'test-console-client-can-read',
'test-console-client-can-write',
+ 'test-console-client-no-args',
]
foreach ct : client_tests
diff --git a/test/test-console-client-no-args b/test/test-console-client-no-args
new file mode 100755
index 0000000..f90b5c0
--- /dev/null
+++ b/test/test-console-client-no-args
@@ -0,0 +1,21 @@
+#!/usr/bin/sh
+
+set -eux
+
+CLIENT="$3"
+
+# Meet DBus bus and path name constraints, append own PID for parallel runs
+TEST_NAME="$(basename "$0" | tr '-' '_')"_${$}
+TEST_DIR="$(mktemp --tmpdir --directory "${TEST_NAME}.XXXXXX")"
+
+cd "$TEST_DIR"
+
+cleanup()
+{
+ cd -
+ rm -rf "$TEST_DIR"
+}
+
+trap cleanup EXIT
+
+$CLIENT 2>&1 >/dev/null | grep 'Connection refused'