summaryrefslogtreecommitdiffstats
path: root/unit/test-caif.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-01-28 12:47:08 +0100
committerMarcel Holtmann <marcel@holtmann.org>2010-01-28 12:47:08 +0100
commitc25347dc7e2a633843fe25769026d1f5699de848 (patch)
tree302b4be8a3cd03b179231135a9d8731c08980e88 /unit/test-caif.c
parent839988cfa372877f121d70e358ce3b6f9b67ccaa (diff)
downloadofono-c25347dc7e2a633843fe25769026d1f5699de848.tar.bz2
Add second CAIF test for using character interface
Diffstat (limited to 'unit/test-caif.c')
-rw-r--r--unit/test-caif.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/unit/test-caif.c b/unit/test-caif.c
index 9fd46e7d..a460fdae 100644
--- a/unit/test-caif.c
+++ b/unit/test-caif.c
@@ -24,6 +24,7 @@
#endif
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -38,6 +39,19 @@
static GMainLoop *mainloop;
+static int do_open(void)
+{
+ int fd;
+
+ fd = open("/dev/chnlat10", O_RDWR);
+ if (fd < 0) {
+ g_printerr("Open of chnlat10 failed (%d)\n", errno);
+ return -EIO;
+ }
+
+ return fd;
+}
+
static int do_connect(void)
{
struct sockaddr_caif addr;
@@ -86,18 +100,22 @@ static void caif_init(gboolean ok, GAtResult *result, gpointer data)
g_main_loop_quit(mainloop);
}
-static void test_connect(void)
+static void test_connect(gboolean use_socket)
{
GIOChannel *io;
GAtChat *chat;
GAtSyntax *syntax;
- int sk;
+ int fd;
- sk = do_connect();
- if (sk < 0)
+ if (use_socket == TRUE)
+ fd = do_connect();
+ else
+ fd = do_open();
+
+ if (fd < 0)
return;
- io = g_io_channel_unix_new(sk);
+ io = g_io_channel_unix_new(fd);
g_io_channel_set_close_on_unref(io, TRUE);
syntax = g_at_syntax_new_gsm_permissive();
@@ -123,7 +141,18 @@ static void test_connect(void)
static void test_basic(void)
{
if (g_test_trap_fork(60 * 1000 * 1000, 0) == TRUE) {
- test_connect();
+ test_connect(TRUE);
+ exit(0);
+ }
+
+ g_test_trap_assert_passed();
+ //g_test_trap_assert_stderr("failed");
+}
+
+static void test_chnlat(void)
+{
+ if (g_test_trap_fork(60 * 1000 * 1000, 0) == TRUE) {
+ test_connect(FALSE);
exit(0);
}
@@ -136,6 +165,7 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
g_test_add_func("/testcaif/basic", test_basic);
+ g_test_add_func("/testcaif/chnlat", test_chnlat);
return g_test_run();
}