You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2015/11/05 21:18:18 UTC

[1/2] incubator-mynewt-larva git commit: Initial basic test for net/nimble/host.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 38067a3df -> 7fe4d2255


Initial basic test for net/nimble/host.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/b860779e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/b860779e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/b860779e

Branch: refs/heads/master
Commit: b860779e1c603cb6909cf8a74e1000e7745e89cb
Parents: 38067a3
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Nov 5 12:17:27 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Nov 5 12:17:27 2015 -0800

----------------------------------------------------------------------
 net/nimble/host/egg.yml                  |  3 ++
 net/nimble/host/include/host/host_test.h | 23 ++++++++
 net/nimble/host/src/ble_l2cap.c          | 23 ++++++--
 net/nimble/host/src/ble_l2cap.h          |  6 +++
 net/nimble/host/src/test/l2cap_test.c    | 75 +++++++++++++++++++++++++++
 5 files changed, 127 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/b860779e/net/nimble/host/egg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/egg.yml b/net/nimble/host/egg.yml
index 55d6c63..2169681 100644
--- a/net/nimble/host/egg.yml
+++ b/net/nimble/host/egg.yml
@@ -5,3 +5,6 @@ egg.deps:
     - net/nimble
 egg.req_caps:
     - console
+
+# Satisfy capability dependencies for the self-contained test executable.
+egg.deps.test: libs/console/stub

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/b860779e/net/nimble/host/include/host/host_test.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/host_test.h b/net/nimble/host/include/host/host_test.h
new file mode 100644
index 0000000..92d020e
--- /dev/null
+++ b/net/nimble/host/include/host/host_test.h
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_HOST_TEST_
+#define H_HOST_TEST_
+
+int l2cap_test_all(void);
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/b860779e/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index 8ca851c..afcc2ac 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -67,7 +67,7 @@ ble_l2cap_chan_free(struct ble_l2cap_chan *chan)
     assert(rc == 0);
 }
 
-static int
+int
 ble_l2cap_parse_hdr(void *pkt, uint16_t len, struct ble_l2cap_hdr *l2cap_hdr)
 {
     uint8_t *u8ptr;
@@ -86,11 +86,28 @@ ble_l2cap_parse_hdr(void *pkt, uint16_t len, struct ble_l2cap_hdr *l2cap_hdr)
     l2cap_hdr->blh_cid = le16toh(u8ptr + off);
     off += 2;
 
-    if (len < BLE_L2CAP_HDR_SZ + l2cap_hdr->blh_len) {
+    return 0;
+}
+
+void
+ble_l2cap_write_hdr(void *dst, uint16_t len,
+                    const struct ble_l2cap_hdr *l2cap_hdr)
+{
+    uint8_t *u8ptr;
+    uint16_t off;
+
+    if (len < BLE_L2CAP_HDR_SZ) {
         return EMSGSIZE;
     }
 
-    return 0;
+    off = 0;
+    u8ptr = dst;
+
+    htole16(u8ptr + off, l2cap_hdr->blh_len);
+    off += 2;
+
+    htole16(u8ptr + off, l2cap_hdr->blh_cid);
+    off += 2;
 }
 
 static struct ble_l2cap_chan *

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/b860779e/net/nimble/host/src/ble_l2cap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.h b/net/nimble/host/src/ble_l2cap.h
index 5f07dd9..5fd950d 100644
--- a/net/nimble/host/src/ble_l2cap.h
+++ b/net/nimble/host/src/ble_l2cap.h
@@ -18,6 +18,7 @@
 #define H_L2CAP_
 
 #include <inttypes.h>
+#include "os/queue.h"
 #include "os/os_mbuf.h"
 struct ble_hs_conn;
 struct hci_data_hdr;
@@ -58,6 +59,11 @@ struct ble_l2cap_chan *ble_l2cap_chan_alloc(void);
 void ble_l2cap_chan_free(struct ble_l2cap_chan *chan);
 
 
+int ble_l2cap_parse_hdr(void *pkt, uint16_t len,
+                        struct ble_l2cap_hdr *l2cap_hdr);
+void ble_l2cap_write_hdr(void *dst, uint16_t len,
+                         const struct ble_l2cap_hdr *l2cap_hdr);
+
 int ble_l2cap_rx(struct ble_hs_conn *connection,
                  struct hci_data_hdr *hci_hdr,
                  void *pkt);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/b860779e/net/nimble/host/src/test/l2cap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/l2cap_test.c b/net/nimble/host/src/test/l2cap_test.c
new file mode 100644
index 0000000..2cf17f2
--- /dev/null
+++ b/net/nimble/host/src/test/l2cap_test.c
@@ -0,0 +1,75 @@
+#include <stddef.h>
+#include <errno.h>
+#include "nimble/hci_common.h"
+#include "ble_hs_conn.h"
+#include "ble_l2cap.h"
+#include "host/host_task.h"
+#include "host/host_test.h"
+#include "testutil/testutil.h"
+
+TEST_CASE(l2cap_test_bad_header)
+{
+    struct ble_l2cap_hdr l2cap_hdr;
+    struct hci_data_hdr hci_hdr;
+    struct ble_hs_conn *conn;
+    uint8_t pkt[8];
+    int rc;
+
+    conn = ble_hs_conn_alloc();
+    TEST_ASSERT_FATAL(conn != NULL);
+
+    hci_hdr.hdh_handle_pb_bc = 0;
+    hci_hdr.hdh_len = 10;
+
+    /* HCI header indicates a length of 10, but L2CAP header has a length
+     * of 0.
+     */
+    l2cap_hdr.blh_len = 0;
+    l2cap_hdr.blh_cid = 0;
+    ble_l2cap_write_hdr(pkt, sizeof pkt, &l2cap_hdr);
+    rc = ble_l2cap_rx(conn, &hci_hdr, pkt);
+    TEST_ASSERT(rc == EMSGSIZE);
+
+    /* Length is correct; specified channel doesn't exist. */
+    l2cap_hdr.blh_len = 6;
+    l2cap_hdr.blh_cid = 0;
+    ble_l2cap_write_hdr(pkt, sizeof pkt, &l2cap_hdr);
+    rc = ble_l2cap_rx(conn, &hci_hdr, pkt);
+    TEST_ASSERT(rc == ENOENT);
+
+    ble_hs_conn_free(conn);
+}
+
+TEST_SUITE(l2cap_gen)
+{
+    int rc;
+
+    rc = host_init();
+    TEST_ASSERT_FATAL(rc == 0);
+
+    l2cap_test_bad_header();
+}
+
+int
+l2cap_test_all(void)
+{
+    l2cap_gen();
+
+    return tu_any_failed;
+}
+
+#ifdef PKG_TEST
+
+int
+main(void)
+{
+    tu_config.tc_print_results = 1;
+    tu_init();
+
+    l2cap_test_all();
+
+    return tu_any_failed;
+}
+
+#endif
+


[2/2] incubator-mynewt-larva git commit: Minor fix of include path for nffs test code.

Posted by cc...@apache.org.
Minor fix of include path for nffs test code.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/7fe4d225
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/7fe4d225
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/7fe4d225

Branch: refs/heads/master
Commit: 7fe4d225586bde345d75ce13550618cb804ef33f
Parents: b860779
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Nov 5 12:17:47 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Nov 5 12:17:47 2015 -0800

----------------------------------------------------------------------
 libs/nffs/src/test/arch/sim/nffs_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7fe4d225/libs/nffs/src/test/arch/sim/nffs_test.c
----------------------------------------------------------------------
diff --git a/libs/nffs/src/test/arch/sim/nffs_test.c b/libs/nffs/src/test/arch/sim/nffs_test.c
index 75f0680..2b5d595 100644
--- a/libs/nffs/src/test/arch/sim/nffs_test.c
+++ b/libs/nffs/src/test/arch/sim/nffs_test.c
@@ -24,7 +24,7 @@
 #include "nffs/nffs.h"
 #include "nffs/nffs_test.h"
 #include "nffs_test_priv.h"
-#include "../src/nffs_priv.h"
+#include "nffs_priv.h"
 
 int flash_native_memset(uint32_t offset, uint8_t c, uint32_t len);