rfcomm-tester.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2014 Intel Corporation. All rights reserved.
  7. *
  8. *
  9. */
  10. #ifdef HAVE_CONFIG_H
  11. #include <config.h>
  12. #endif
  13. #include <stdlib.h>
  14. #include <stdint.h>
  15. #include <unistd.h>
  16. #include <errno.h>
  17. #include <stdbool.h>
  18. #include <glib.h>
  19. #include "lib/bluetooth.h"
  20. #include "lib/rfcomm.h"
  21. #include "lib/mgmt.h"
  22. #include "monitor/bt.h"
  23. #include "emulator/bthost.h"
  24. #include "emulator/hciemu.h"
  25. #include "src/shared/tester.h"
  26. #include "src/shared/mgmt.h"
  27. struct test_data {
  28. struct mgmt *mgmt;
  29. uint16_t mgmt_index;
  30. struct hciemu *hciemu;
  31. enum hciemu_type hciemu_type;
  32. const void *test_data;
  33. unsigned int io_id;
  34. uint16_t conn_handle;
  35. };
  36. struct rfcomm_client_data {
  37. uint8_t server_channel;
  38. uint8_t client_channel;
  39. int expected_connect_err;
  40. const uint8_t *send_data;
  41. const uint8_t *read_data;
  42. uint16_t data_len;
  43. };
  44. struct rfcomm_server_data {
  45. uint8_t server_channel;
  46. uint8_t client_channel;
  47. bool expected_status;
  48. const uint8_t *send_data;
  49. const uint8_t *read_data;
  50. uint16_t data_len;
  51. };
  52. static void print_debug(const char *str, void *user_data)
  53. {
  54. const char *prefix = user_data;
  55. tester_print("%s%s", prefix, str);
  56. }
  57. static void read_info_callback(uint8_t status, uint16_t length,
  58. const void *param, void *user_data)
  59. {
  60. struct test_data *data = tester_get_data();
  61. const struct mgmt_rp_read_info *rp = param;
  62. char addr[18];
  63. uint16_t manufacturer;
  64. uint32_t supported_settings, current_settings;
  65. tester_print("Read Info callback");
  66. tester_print(" Status: 0x%02x", status);
  67. if (status || !param) {
  68. tester_pre_setup_failed();
  69. return;
  70. }
  71. ba2str(&rp->bdaddr, addr);
  72. manufacturer = btohs(rp->manufacturer);
  73. supported_settings = btohl(rp->supported_settings);
  74. current_settings = btohl(rp->current_settings);
  75. tester_print(" Address: %s", addr);
  76. tester_print(" Version: 0x%02x", rp->version);
  77. tester_print(" Manufacturer: 0x%04x", manufacturer);
  78. tester_print(" Supported settings: 0x%08x", supported_settings);
  79. tester_print(" Current settings: 0x%08x", current_settings);
  80. tester_print(" Class: 0x%02x%02x%02x",
  81. rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
  82. tester_print(" Name: %s", rp->name);
  83. tester_print(" Short name: %s", rp->short_name);
  84. if (strcmp(hciemu_get_address(data->hciemu), addr)) {
  85. tester_pre_setup_failed();
  86. return;
  87. }
  88. tester_pre_setup_complete();
  89. }
  90. static void index_added_callback(uint16_t index, uint16_t length,
  91. const void *param, void *user_data)
  92. {
  93. struct test_data *data = tester_get_data();
  94. tester_print("Index Added callback");
  95. tester_print(" Index: 0x%04x", index);
  96. data->mgmt_index = index;
  97. mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
  98. read_info_callback, NULL, NULL);
  99. }
  100. static void index_removed_callback(uint16_t index, uint16_t length,
  101. const void *param, void *user_data)
  102. {
  103. struct test_data *data = tester_get_data();
  104. tester_print("Index Removed callback");
  105. tester_print(" Index: 0x%04x", index);
  106. if (index != data->mgmt_index)
  107. return;
  108. mgmt_unregister_index(data->mgmt, data->mgmt_index);
  109. mgmt_unref(data->mgmt);
  110. data->mgmt = NULL;
  111. tester_post_teardown_complete();
  112. }
  113. static void read_index_list_callback(uint8_t status, uint16_t length,
  114. const void *param, void *user_data)
  115. {
  116. struct test_data *data = tester_get_data();
  117. tester_print("Read Index List callback");
  118. tester_print(" Status: 0x%02x", status);
  119. if (status || !param) {
  120. tester_pre_setup_failed();
  121. return;
  122. }
  123. mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
  124. index_added_callback, NULL, NULL);
  125. mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE,
  126. index_removed_callback, NULL, NULL);
  127. data->hciemu = hciemu_new(data->hciemu_type);
  128. if (!data->hciemu) {
  129. tester_warn("Failed to setup HCI emulation");
  130. tester_pre_setup_failed();
  131. }
  132. if (tester_use_debug())
  133. hciemu_set_debug(data->hciemu, print_debug, "hciemu: ", NULL);
  134. tester_print("New hciemu instance created");
  135. }
  136. static void test_pre_setup(const void *test_data)
  137. {
  138. struct test_data *data = tester_get_data();
  139. data->mgmt = mgmt_new_default();
  140. if (!data->mgmt) {
  141. tester_warn("Failed to setup management interface");
  142. tester_pre_setup_failed();
  143. return;
  144. }
  145. if (tester_use_debug())
  146. mgmt_set_debug(data->mgmt, print_debug, "mgmt: ", NULL);
  147. mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL,
  148. read_index_list_callback, NULL, NULL);
  149. }
  150. static void test_post_teardown(const void *test_data)
  151. {
  152. struct test_data *data = tester_get_data();
  153. if (data->io_id > 0) {
  154. g_source_remove(data->io_id);
  155. data->io_id = 0;
  156. }
  157. hciemu_unref(data->hciemu);
  158. data->hciemu = NULL;
  159. }
  160. static void test_data_free(void *test_data)
  161. {
  162. struct test_data *data = test_data;
  163. free(data);
  164. }
  165. static void client_connectable_complete(uint16_t opcode, uint8_t status,
  166. const void *param, uint8_t len,
  167. void *user_data)
  168. {
  169. switch (opcode) {
  170. case BT_HCI_CMD_WRITE_SCAN_ENABLE:
  171. break;
  172. default:
  173. return;
  174. }
  175. tester_print("Client set connectable status 0x%02x", status);
  176. if (status)
  177. tester_setup_failed();
  178. else
  179. tester_setup_complete();
  180. }
  181. static void setup_powered_client_callback(uint8_t status, uint16_t length,
  182. const void *param, void *user_data)
  183. {
  184. struct test_data *data = tester_get_data();
  185. struct bthost *bthost;
  186. if (status != MGMT_STATUS_SUCCESS) {
  187. tester_setup_failed();
  188. return;
  189. }
  190. tester_print("Controller powered on");
  191. bthost = hciemu_client_get_host(data->hciemu);
  192. bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
  193. bthost_write_scan_enable(bthost, 0x03);
  194. }
  195. static void setup_powered_client(const void *test_data)
  196. {
  197. struct test_data *data = tester_get_data();
  198. unsigned char param[] = { 0x01 };
  199. tester_print("Powering on controller");
  200. mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
  201. sizeof(param), param, setup_powered_client_callback,
  202. NULL, NULL);
  203. }
  204. static void setup_powered_server_callback(uint8_t status, uint16_t length,
  205. const void *param, void *user_data)
  206. {
  207. if (status != MGMT_STATUS_SUCCESS) {
  208. tester_setup_failed();
  209. return;
  210. }
  211. tester_print("Controller powered on");
  212. tester_setup_complete();
  213. }
  214. static void setup_powered_server(const void *test_data)
  215. {
  216. struct test_data *data = tester_get_data();
  217. unsigned char param[] = { 0x01 };
  218. tester_print("Powering on controller");
  219. mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
  220. sizeof(param), param,
  221. NULL, NULL, NULL);
  222. mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
  223. sizeof(param), param, setup_powered_server_callback,
  224. NULL, NULL);
  225. }
  226. const struct rfcomm_client_data connect_success = {
  227. .server_channel = 0x0c,
  228. .client_channel = 0x0c
  229. };
  230. const uint8_t data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
  231. const struct rfcomm_client_data connect_send_success = {
  232. .server_channel = 0x0c,
  233. .client_channel = 0x0c,
  234. .data_len = sizeof(data),
  235. .send_data = data
  236. };
  237. const struct rfcomm_client_data connect_read_success = {
  238. .server_channel = 0x0c,
  239. .client_channel = 0x0c,
  240. .data_len = sizeof(data),
  241. .read_data = data
  242. };
  243. const struct rfcomm_client_data connect_nval = {
  244. .server_channel = 0x0c,
  245. .client_channel = 0x0e,
  246. .expected_connect_err = -ECONNREFUSED
  247. };
  248. const struct rfcomm_server_data listen_success = {
  249. .server_channel = 0x0c,
  250. .client_channel = 0x0c,
  251. .expected_status = true
  252. };
  253. const struct rfcomm_server_data listen_send_success = {
  254. .server_channel = 0x0c,
  255. .client_channel = 0x0c,
  256. .expected_status = true,
  257. .data_len = sizeof(data),
  258. .send_data = data
  259. };
  260. const struct rfcomm_server_data listen_read_success = {
  261. .server_channel = 0x0c,
  262. .client_channel = 0x0c,
  263. .expected_status = true,
  264. .data_len = sizeof(data),
  265. .read_data = data
  266. };
  267. const struct rfcomm_server_data listen_nval = {
  268. .server_channel = 0x0c,
  269. .client_channel = 0x0e,
  270. .expected_status = false
  271. };
  272. static void test_basic(const void *test_data)
  273. {
  274. int sk;
  275. sk = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
  276. if (sk < 0) {
  277. tester_warn("Can't create socket: %s (%d)", strerror(errno),
  278. errno);
  279. tester_test_failed();
  280. return;
  281. }
  282. close(sk);
  283. tester_test_passed();
  284. }
  285. static int create_rfcomm_sock(bdaddr_t *address, uint8_t channel)
  286. {
  287. int sk;
  288. struct sockaddr_rc addr;
  289. sk = socket(PF_BLUETOOTH, SOCK_STREAM | SOCK_NONBLOCK, BTPROTO_RFCOMM);
  290. memset(&addr, 0, sizeof(addr));
  291. addr.rc_family = AF_BLUETOOTH;
  292. addr.rc_channel = channel;
  293. bacpy(&addr.rc_bdaddr, address);
  294. if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
  295. close(sk);
  296. return -1;
  297. }
  298. return sk;
  299. }
  300. static int connect_rfcomm_sock(int sk, const bdaddr_t *bdaddr, uint8_t channel)
  301. {
  302. struct sockaddr_rc addr;
  303. int err;
  304. memset(&addr, 0, sizeof(addr));
  305. addr.rc_family = AF_BLUETOOTH;
  306. bacpy(&addr.rc_bdaddr, bdaddr);
  307. addr.rc_channel = htobs(channel);
  308. err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
  309. if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS))
  310. return err;
  311. return 0;
  312. }
  313. static gboolean client_received_data(GIOChannel *io, GIOCondition cond,
  314. gpointer user_data)
  315. {
  316. struct test_data *data = tester_get_data();
  317. const struct rfcomm_client_data *cli = data->test_data;
  318. int sk;
  319. ssize_t ret;
  320. char buf[248];
  321. sk = g_io_channel_unix_get_fd(io);
  322. ret = read(sk, buf, cli->data_len);
  323. if (cli->data_len != ret) {
  324. tester_test_failed();
  325. return false;
  326. }
  327. if (memcmp(cli->read_data, buf, cli->data_len))
  328. tester_test_failed();
  329. else
  330. tester_test_passed();
  331. return false;
  332. }
  333. static gboolean rc_connect_cb(GIOChannel *io, GIOCondition cond,
  334. gpointer user_data)
  335. {
  336. struct test_data *data = tester_get_data();
  337. const struct rfcomm_client_data *cli = data->test_data;
  338. socklen_t len = sizeof(int);
  339. int sk, err, sk_err;
  340. tester_print("Connected");
  341. data->io_id = 0;
  342. sk = g_io_channel_unix_get_fd(io);
  343. if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
  344. err = -errno;
  345. else
  346. err = -sk_err;
  347. if (cli->expected_connect_err && err == cli->expected_connect_err) {
  348. tester_test_passed();
  349. return false;
  350. }
  351. if (cli->send_data) {
  352. ssize_t ret;
  353. tester_print("Writing %u bytes of data", cli->data_len);
  354. ret = write(sk, cli->send_data, cli->data_len);
  355. if (cli->data_len != ret) {
  356. tester_warn("Failed to write %u bytes: %s (%d)",
  357. cli->data_len, strerror(errno), errno);
  358. tester_test_failed();
  359. }
  360. return false;
  361. } else if (cli->read_data) {
  362. g_io_add_watch(io, G_IO_IN, client_received_data, NULL);
  363. bthost_send_rfcomm_data(hciemu_client_get_host(data->hciemu),
  364. data->conn_handle,
  365. cli->client_channel,
  366. cli->read_data, cli->data_len);
  367. return false;
  368. }
  369. if (err < 0)
  370. tester_test_failed();
  371. else
  372. tester_test_passed();
  373. return false;
  374. }
  375. static void client_hook_func(const void *data, uint16_t len,
  376. void *user_data)
  377. {
  378. struct test_data *test_data = tester_get_data();
  379. const struct rfcomm_client_data *cli = test_data->test_data;
  380. ssize_t ret;
  381. tester_print("bthost received %u bytes of data", len);
  382. if (cli->data_len != len) {
  383. tester_test_failed();
  384. return;
  385. }
  386. ret = memcmp(cli->send_data, data, len);
  387. if (ret)
  388. tester_test_failed();
  389. else
  390. tester_test_passed();
  391. }
  392. static void server_hook_func(const void *data, uint16_t len,
  393. void *user_data)
  394. {
  395. struct test_data *test_data = tester_get_data();
  396. const struct rfcomm_server_data *srv = test_data->test_data;
  397. ssize_t ret;
  398. if (srv->data_len != len) {
  399. tester_test_failed();
  400. return;
  401. }
  402. ret = memcmp(srv->send_data, data, len);
  403. if (ret)
  404. tester_test_failed();
  405. else
  406. tester_test_passed();
  407. }
  408. static void rfcomm_connect_cb(uint16_t handle, uint16_t cid,
  409. void *user_data, bool status)
  410. {
  411. struct test_data *data = tester_get_data();
  412. const struct rfcomm_client_data *cli = data->test_data;
  413. struct bthost *bthost = hciemu_client_get_host(data->hciemu);
  414. if (cli->send_data)
  415. bthost_add_rfcomm_chan_hook(bthost, handle,
  416. cli->client_channel,
  417. client_hook_func, NULL);
  418. else if (cli->read_data)
  419. data->conn_handle = handle;
  420. }
  421. static void test_connect(const void *test_data)
  422. {
  423. struct test_data *data = tester_get_data();
  424. struct bthost *bthost = hciemu_client_get_host(data->hciemu);
  425. const struct rfcomm_client_data *cli = data->test_data;
  426. const uint8_t *client_addr, *central_addr;
  427. GIOChannel *io;
  428. int sk;
  429. bthost_add_l2cap_server(bthost, 0x0003, NULL, NULL, NULL);
  430. bthost_add_rfcomm_server(bthost, cli->server_channel,
  431. rfcomm_connect_cb, NULL);
  432. central_addr = hciemu_get_central_bdaddr(data->hciemu);
  433. client_addr = hciemu_get_client_bdaddr(data->hciemu);
  434. sk = create_rfcomm_sock((bdaddr_t *) central_addr, 0);
  435. if (connect_rfcomm_sock(sk, (const bdaddr_t *) client_addr,
  436. cli->client_channel) < 0) {
  437. close(sk);
  438. tester_test_failed();
  439. return;
  440. }
  441. io = g_io_channel_unix_new(sk);
  442. g_io_channel_set_close_on_unref(io, TRUE);
  443. data->io_id = g_io_add_watch(io, G_IO_OUT, rc_connect_cb, NULL);
  444. g_io_channel_unref(io);
  445. tester_print("Connect in progress %d", sk);
  446. }
  447. static gboolean server_received_data(GIOChannel *io, GIOCondition cond,
  448. gpointer user_data)
  449. {
  450. struct test_data *data = tester_get_data();
  451. const struct rfcomm_server_data *srv = data->test_data;
  452. char buf[1024];
  453. ssize_t ret;
  454. int sk;
  455. sk = g_io_channel_unix_get_fd(io);
  456. ret = read(sk, buf, srv->data_len);
  457. if (ret != srv->data_len) {
  458. tester_test_failed();
  459. return false;
  460. }
  461. if (memcmp(buf, srv->read_data, srv->data_len))
  462. tester_test_failed();
  463. else
  464. tester_test_passed();
  465. return false;
  466. }
  467. static gboolean rfcomm_listen_cb(GIOChannel *io, GIOCondition cond,
  468. gpointer user_data)
  469. {
  470. struct test_data *data = tester_get_data();
  471. const struct rfcomm_server_data *srv = data->test_data;
  472. int sk, new_sk;
  473. data->io_id = 0;
  474. sk = g_io_channel_unix_get_fd(io);
  475. new_sk = accept(sk, NULL, NULL);
  476. if (new_sk < 0) {
  477. tester_test_failed();
  478. return false;
  479. }
  480. if (srv->send_data) {
  481. ssize_t ret;
  482. ret = write(new_sk, srv->send_data, srv->data_len);
  483. if (ret != srv->data_len)
  484. tester_test_failed();
  485. close(new_sk);
  486. return false;
  487. } else if (srv->read_data) {
  488. GIOChannel *new_io;
  489. new_io = g_io_channel_unix_new(new_sk);
  490. g_io_channel_set_close_on_unref(new_io, TRUE);
  491. data->io_id = g_io_add_watch(new_io, G_IO_IN,
  492. server_received_data, NULL);
  493. g_io_channel_unref(new_io);
  494. return false;
  495. }
  496. close(new_sk);
  497. tester_test_passed();
  498. return false;
  499. }
  500. static void connection_cb(uint16_t handle, uint16_t cid, void *user_data,
  501. bool status)
  502. {
  503. struct test_data *data = tester_get_data();
  504. const struct rfcomm_server_data *srv = data->test_data;
  505. struct bthost *bthost = hciemu_client_get_host(data->hciemu);
  506. if (srv->read_data) {
  507. data->conn_handle = handle;
  508. bthost_send_rfcomm_data(bthost, data->conn_handle,
  509. srv->client_channel,
  510. srv->read_data, srv->data_len);
  511. return;
  512. } else if (srv->data_len) {
  513. return;
  514. }
  515. if (srv->expected_status == status)
  516. tester_test_passed();
  517. else
  518. tester_test_failed();
  519. }
  520. static void client_new_conn(uint16_t handle, void *user_data)
  521. {
  522. struct test_data *data = tester_get_data();
  523. const struct rfcomm_server_data *srv = data->test_data;
  524. struct bthost *bthost;
  525. bthost = hciemu_client_get_host(data->hciemu);
  526. bthost_add_rfcomm_chan_hook(bthost, handle, srv->client_channel,
  527. server_hook_func, NULL);
  528. bthost_connect_rfcomm(bthost, handle, srv->client_channel,
  529. connection_cb, NULL);
  530. }
  531. static void test_server(const void *test_data)
  532. {
  533. struct test_data *data = tester_get_data();
  534. const struct rfcomm_server_data *srv = data->test_data;
  535. const uint8_t *central_addr;
  536. struct bthost *bthost;
  537. GIOChannel *io;
  538. int sk;
  539. central_addr = hciemu_get_central_bdaddr(data->hciemu);
  540. sk = create_rfcomm_sock((bdaddr_t *) central_addr, srv->server_channel);
  541. if (sk < 0) {
  542. tester_test_failed();
  543. return;
  544. }
  545. if (listen(sk, 5) < 0) {
  546. tester_warn("listening on socket failed: %s (%u)",
  547. strerror(errno), errno);
  548. tester_test_failed();
  549. close(sk);
  550. return;
  551. }
  552. io = g_io_channel_unix_new(sk);
  553. g_io_channel_set_close_on_unref(io, TRUE);
  554. data->io_id = g_io_add_watch(io, G_IO_IN, rfcomm_listen_cb, NULL);
  555. g_io_channel_unref(io);
  556. tester_print("Listening for connections");
  557. bthost = hciemu_client_get_host(data->hciemu);
  558. bthost_set_connect_cb(bthost, client_new_conn, data);
  559. bthost_hci_connect(bthost, central_addr, BDADDR_BREDR);
  560. }
  561. #define test_rfcomm(name, data, setup, func) \
  562. do { \
  563. struct test_data *user; \
  564. user = malloc(sizeof(struct test_data)); \
  565. if (!user) \
  566. break; \
  567. user->hciemu_type = HCIEMU_TYPE_BREDR; \
  568. user->test_data = data; \
  569. user->io_id = 0; \
  570. tester_add_full(name, data, \
  571. test_pre_setup, setup, func, NULL, \
  572. test_post_teardown, 2, user, test_data_free); \
  573. } while (0)
  574. int main(int argc, char *argv[])
  575. {
  576. tester_init(&argc, &argv);
  577. test_rfcomm("Basic RFCOMM Socket - Success", NULL,
  578. setup_powered_client, test_basic);
  579. test_rfcomm("Basic RFCOMM Socket Client - Success", &connect_success,
  580. setup_powered_client, test_connect);
  581. test_rfcomm("Basic RFCOMM Socket Client - Write Success",
  582. &connect_send_success, setup_powered_client,
  583. test_connect);
  584. test_rfcomm("Basic RFCOMM Socket Client - Read Success",
  585. &connect_read_success, setup_powered_client,
  586. test_connect);
  587. test_rfcomm("Basic RFCOMM Socket Client - Conn Refused",
  588. &connect_nval, setup_powered_client, test_connect);
  589. test_rfcomm("Basic RFCOMM Socket Server - Success", &listen_success,
  590. setup_powered_server, test_server);
  591. test_rfcomm("Basic RFCOMM Socket Server - Write Success",
  592. &listen_send_success, setup_powered_server,
  593. test_server);
  594. test_rfcomm("Basic RFCOMM Socket Server - Read Success",
  595. &listen_read_success, setup_powered_server,
  596. test_server);
  597. test_rfcomm("Basic RFCOMM Socket Server - Conn Refused", &listen_nval,
  598. setup_powered_server, test_server);
  599. return tester_run();
  600. }