All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCHv5 07/11] android/ipc-tester: Add basic test cases for IPC's daemon site
Date: Mon, 20 Jan 2014 10:36:06 +0100	[thread overview]
Message-ID: <1390210570-28260-8-git-send-email-jakub.tyszkowski@tieto.com> (raw)
In-Reply-To: <1390210570-28260-1-git-send-email-jakub.tyszkowski@tieto.com>

This patch adds first few test cases checking for proper daemon
termination in case of receiving invalid IPC data.
---
 android/ipc-tester.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 816719c..c8bc9b8 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -569,15 +569,57 @@ struct regmod_msg register_bt_msg = {
 		},
 };
 
+struct regmod_msg register_bt_malformed_size_msg = {
+	.header = {
+		.service_id = HAL_SERVICE_ID_CORE,
+		.opcode = HAL_OP_REGISTER_MODULE,
+		/* wrong payload size declared */
+		.len = sizeof(struct hal_cmd_register_module) - 1,
+		},
+	.cmd = {
+		.service_id = HAL_SERVICE_ID_CORE,
+		},
+};
+
+struct hal_hdr enable_unknown_service_hdr = {
+	.service_id = HAL_SERVICE_ID_MAX + 1,
+	.opcode = HAL_OP_REGISTER_MODULE,
+	.len = 0,
+};
+
+struct hal_hdr enable_bt_service_hdr = {
+	.service_id = HAL_SERVICE_ID_BLUETOOTH,
+	.opcode = HAL_OP_ENABLE,
+	.len = 0,
+};
+
 int main(int argc, char *argv[])
 {
 	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
 
 	tester_init(&argc, &argv);
 
+	/* check general IPC errors */
 	test_generic("Too small data",
 				ipc_send_tc, setup, teardown,
 				&register_bt_msg, 1);
 
+	test_generic("Malformed data (wrong payload declared)",
+				ipc_send_tc, setup, teardown,
+				&register_bt_malformed_size_msg,
+				sizeof(register_bt_malformed_size_msg),
+				HAL_SERVICE_ID_BLUETOOTH);
+
+	test_generic("Invalid service",
+				ipc_send_tc, setup, teardown,
+				&enable_unknown_service_hdr,
+				sizeof(enable_unknown_service_hdr),
+				HAL_SERVICE_ID_BLUETOOTH);
+
+	test_generic("Enable unregistered service",
+				ipc_send_tc, setup, teardown,
+				&enable_bt_service_hdr,
+				sizeof(enable_bt_service_hdr));
+
 	return tester_run();
 }
-- 
1.8.5.2


  parent reply	other threads:[~2014-01-20  9:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 01/11] android/ipc-tester: Skeleton for ipc " Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 02/11] android/ipc-tester: Run daemon in separate process Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 03/11] android/ipc-tester: Add IPC initialization Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 04/11] android/ipc-tester: Add daemon shutdown handler Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 05/11] android/ipc-tester: Add sending test data with ipc Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 06/11] android/ipc-tester: Register services Jakub Tyszkowski
2014-01-20  9:36 ` Jakub Tyszkowski [this message]
2014-01-20  9:36 ` [PATCHv5 08/11] android/ipc-tester: Add more cases for malformed data Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 09/11] android/ipc-tester: Add cases for service opcode boundaries Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 10/11] android/ipc-tester: Add cases for Core message data size Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 11/11] android/ipc-tester: Add cases for BT " Jakub Tyszkowski
2014-01-20 22:26 ` [PATCHv5 00/11] IPC negative tester Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390210570-28260-8-git-send-email-jakub.tyszkowski@tieto.com \
    --to=jakub.tyszkowski@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.