mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccoll...@apache.org
Subject [45/50] [abbrv] incubator-mynewt-core git commit: boot_serial - Begin converting tests to use cbor
Date Thu, 10 Nov 2016 22:39:52 GMT
boot_serial - Begin converting tests to use cbor

Tests used to send JSON newtmgr commands.  This conversion is
incomplete, so some tests still fail.


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

Branch: refs/heads/master
Commit: 82631392b0969a4f1ae4071ed74a7acde16a02d0
Parents: 7102b02
Author: Christopher Collins <ccollins@apache.org>
Authored: Wed Nov 9 18:53:21 2016 -0800
Committer: Christopher Collins <ccollins@apache.org>
Committed: Wed Nov 9 18:53:21 2016 -0800

----------------------------------------------------------------------
 .../src/testcases/boot_serial_empty_img_msg.c   |  2 +-
 .../test/src/testcases/boot_serial_img_msg.c    | 27 ++++++++++++++------
 .../testcases/boot_serial_upload_bigger_image.c |  2 +-
 3 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82631392/boot/boot_serial/test/src/testcases/boot_serial_empty_img_msg.c
----------------------------------------------------------------------
diff --git a/boot/boot_serial/test/src/testcases/boot_serial_empty_img_msg.c b/boot/boot_serial/test/src/testcases/boot_serial_empty_img_msg.c
index 88a4ee8..ff69324 100644
--- a/boot/boot_serial/test/src/testcases/boot_serial_empty_img_msg.c
+++ b/boot/boot_serial/test/src/testcases/boot_serial_empty_img_msg.c
@@ -26,7 +26,7 @@ TEST_CASE(boot_serial_empty_img_msg)
     hdr = (struct nmgr_hdr *)buf;
     memset(hdr, 0, sizeof(*hdr));
     hdr->nh_op = NMGR_OP_WRITE;
-    hdr->nh_group = htons(NMGR_GROUP_ID_IMAGE);
+    hdr->nh_group = htons(MGMT_GROUP_ID_IMAGE);
     hdr->nh_id = IMGMGR_NMGR_OP_UPLOAD;
     hdr->nh_len = htons(2);
     strcpy((char *)(hdr + 1), "{}");

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82631392/boot/boot_serial/test/src/testcases/boot_serial_img_msg.c
----------------------------------------------------------------------
diff --git a/boot/boot_serial/test/src/testcases/boot_serial_img_msg.c b/boot/boot_serial/test/src/testcases/boot_serial_img_msg.c
index 7c5428f..0ecce37 100644
--- a/boot/boot_serial/test/src/testcases/boot_serial_img_msg.c
+++ b/boot/boot_serial/test/src/testcases/boot_serial_img_msg.c
@@ -28,22 +28,33 @@ TEST_CASE(boot_serial_img_msg)
     struct nmgr_hdr *hdr;
     const struct flash_area *fap;
 
+    /* 00000000  a3 64 64 61 74 61 58 10  |.ddataX.|
+     * 00000008  a5 a5 a5 a5 a5 a5 a5 a5  |........|
+     * 00000010  a5 a5 a5 a5 a5 a5 a5 a5  |........|
+     * 00000018  63 6c 65 6e 1a 00 01 14  |clen....|
+     * 00000020  e8 63 6f 66 66 00        |.coff.|
+     */
+    static const uint8_t payload[] = { 
+        0xa3, 0x64, 0x64, 0x61, 0x74, 0x61, 0x58, 0x10,
+        /* 16 bytes of image data starts here. */
+        0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
+        0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
+        0x63, 0x6c, 0x65, 0x6e, 0x1a, 0x00, 0x01, 0x14,
+        0xe8, 0x63, 0x6f, 0x66, 0x66, 0x00,
+    };
+
     memset(img, 0xa5, sizeof(img));
-    len = base64_encode(img, sizeof(img), enc_img, 1);
-    assert(len > 0);
 
     hdr = (struct nmgr_hdr *)buf;
     memset(hdr, 0, sizeof(*hdr));
     hdr->nh_op = NMGR_OP_WRITE;
-    hdr->nh_group = htons(NMGR_GROUP_ID_IMAGE);
+    hdr->nh_group = htons(MGMT_GROUP_ID_IMAGE);
     hdr->nh_id = IMGMGR_NMGR_OP_UPLOAD;
 
-    len = sprintf((char *)(hdr + 1),
-                  "{\"off\":0,\"len\":16,\"data\":\"%s\"}", enc_img);
-    hdr->nh_len = htons(len);
-
-    len = sizeof(*hdr) + len;
+    memcpy(hdr + 1, payload, sizeof payload);
+    hdr->nh_len = htons(sizeof payload);
 
+    len = sizeof(*hdr) + sizeof payload;
     tx_msg(buf, len);
 
     /*

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82631392/boot/boot_serial/test/src/testcases/boot_serial_upload_bigger_image.c
----------------------------------------------------------------------
diff --git a/boot/boot_serial/test/src/testcases/boot_serial_upload_bigger_image.c b/boot/boot_serial/test/src/testcases/boot_serial_upload_bigger_image.c
index b551bb2..1cd8c0e 100644
--- a/boot/boot_serial/test/src/testcases/boot_serial_upload_bigger_image.c
+++ b/boot/boot_serial/test/src/testcases/boot_serial_upload_bigger_image.c
@@ -41,7 +41,7 @@ TEST_CASE(boot_serial_upload_bigger_image)
         hdr = (struct nmgr_hdr *)buf;
         memset(hdr, 0, sizeof(*hdr));
         hdr->nh_op = NMGR_OP_WRITE;
-        hdr->nh_group = htons(NMGR_GROUP_ID_IMAGE);
+        hdr->nh_group = htons(MGMT_GROUP_ID_IMAGE);
         hdr->nh_id = IMGMGR_NMGR_OP_UPLOAD;
 
         if (off) {


Mime
View raw message