summaryrefslogtreecommitdiff
path: root/unit/rilmodem-test-engine.h
diff options
context:
space:
mode:
authorAlfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>2016-10-24 12:57:04 +0200
committerDenis Kenzior <denkenz@gmail.com>2016-10-25 11:51:43 -0500
commit6429e9178d46643778147528831c7bebce137705 (patch)
tree4487c1d4e9d9a8d56f44fa55e956ff9a5c3243b5 /unit/rilmodem-test-engine.h
parent503775992d0342dab301092b99792b96c996c85a (diff)
downloadofono-6429e9178d46643778147528831c7bebce137705.tar.gz
unit: add rilmodem test engine
Add rilmodem test engine. This engine is an improvement on the rilmodem test server that allows us to test generic interactions with the rilmodem driver. Instead of just be able to check content of received/ sent bytes on the rild socket, we can now specify a set of steps for a test that include interactions with the atom. The step types are - TST_ACTION_SEND: The harness sends a parcel - TST_ACTION_CALL: The harness calls a driver function - TST_EVENT_RECEIVE: The driver sends a parcel - TST_EVENT_CALL: The driver calls a harness (atom) function
Diffstat (limited to 'unit/rilmodem-test-engine.h')
-rw-r--r--unit/rilmodem-test-engine.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/unit/rilmodem-test-engine.h b/unit/rilmodem-test-engine.h
new file mode 100644
index 00000000..185d9bce
--- /dev/null
+++ b/unit/rilmodem-test-engine.h
@@ -0,0 +1,74 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2016 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+struct engine_data;
+
+enum test_step_type {
+ TST_ACTION_SEND,
+ TST_ACTION_CALL,
+ TST_EVENT_RECEIVE,
+ TST_EVENT_CALL,
+};
+
+typedef void (*rilmodem_test_engine_cb_t)(void *data);
+
+struct rilmodem_test_step {
+ enum test_step_type type;
+
+ union {
+ /* For TST_ACTION_CALL */
+ rilmodem_test_engine_cb_t call_action;
+ /* For TST_ACTION_SEND or TST_EVENT_RECEIVE */
+ struct {
+ const char *parcel_data;
+ const size_t parcel_size;
+ };
+ /* For TST_EVENT_CALL */
+ struct {
+ void (*call_func)(void);
+ void (*check_func)(void);
+ };
+ };
+};
+
+struct rilmodem_test_data {
+ const struct rilmodem_test_step *steps;
+ int num_steps;
+};
+
+void rilmodem_test_engine_remove(struct engine_data *ed);
+
+struct engine_data *rilmodem_test_engine_create(
+ rilmodem_test_engine_cb_t connect,
+ const struct rilmodem_test_data *test_data,
+ void *data);
+
+void rilmodem_test_engine_write_socket(struct engine_data *ed,
+ const unsigned char *buf,
+ const size_t buf_len);
+
+const char *rilmodem_test_engine_get_socket_name(struct engine_data *ed);
+
+void rilmodem_test_engine_next_step(struct engine_data *ed);
+const struct rilmodem_test_step *rilmodem_test_engine_get_current_step(
+ struct engine_data *ed);
+
+void rilmodem_test_engine_start(struct engine_data *ed);