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 2016/11/10 22:39:53 UTC
[46/50] [abbrv] incubator-mynewt-core git commit: boot_serial -
Continue conversion of tests to cbor
boot_serial - Continue conversion of tests to cbor
Tests used to send JSON newtmgr commands; now they use CBOR. All tests
pass, but there are still some tests which use JSON:
* boot_serial_empty_img_msg
* boot_serial_empty_msg
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/858f94e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/858f94e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/858f94e1
Branch: refs/heads/master
Commit: 858f94e103944f286d30212b42aaa6ece5d79338
Parents: 8263139
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 10 09:00:01 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 10 09:08:22 2016 -0800
----------------------------------------------------------------------
.../test/src/testcases/boot_serial_img_msg.c | 1 +
.../testcases/boot_serial_upload_bigger_image.c | 58 +++++++++++++++++---
2 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/858f94e1/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 0ecce37..c978650 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
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
#include "boot_test.h"
TEST_CASE(boot_serial_img_msg)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/858f94e1/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 1cd8c0e..9f326b8 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
@@ -16,6 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
+#include <tinycbor/cborconstants_p.h>
+
#include "boot_test.h"
TEST_CASE(boot_serial_upload_bigger_image)
@@ -30,14 +33,52 @@ TEST_CASE(boot_serial_upload_bigger_image)
const struct flash_area *fap;
int i;
+ const int payload_off = sizeof *hdr;
+ const int img_data_off = payload_off + 8;
+
+ /* 00000000 a3 64 64 61 74 61 58 20 |.ddataX.|
+ * 00000008 00 00 00 00 00 00 00 00 |........|
+ * 00000010 00 00 00 00 00 00 00 00 |........|
+ * 00000018 00 00 00 00 00 00 00 00 |........|
+ * 00000020 00 00 00 00 00 00 00 00 |........|
+ * 00000028 63 6c 65 6e 1a 00 01 14 |clen....|
+ * 00000030 e8 63 6f 66 66 00 |.coff.|
+ */
+ static const uint8_t payload_first[] = {
+ 0xa3, 0x64, 0x64, 0x61, 0x74, 0x61, 0x58, 0x20,
+ /* 32 bytes of image data starts here. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x63, 0x6c, 0x65, 0x6e, 0x1a, 0x00, 0x01, 0x14,
+ 0xe8, 0x63, 0x6f, 0x66, 0x66, 0x00,
+ };
+
+ /* 00000000 a3 64 64 61 74 61 58 20 |.ddataX.|
+ * 00000008 00 00 00 00 00 00 00 00 |........|
+ * 00000010 00 00 00 00 00 00 00 00 |........|
+ * 00000018 00 00 00 00 00 00 00 00 |........|
+ * 00000020 00 00 00 00 00 00 00 00 |........|
+ * 00000028 63 6f 66 66 00 00 |coff..|
+ */
+ static const uint8_t payload_next[] = {
+ 0xa2, 0x64, 0x64, 0x61, 0x74, 0x61, 0x58, 0x20,
+ /* 32 bytes of image data starts here. */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x63, 0x6f, 0x66, 0x66,
+ /* 2 bytes of offset value starts here. */
+ 0x00, 0x00
+ };
+
for (i = 0; i < sizeof(img); i++) {
img[i] = i;
}
for (off = 0; off < sizeof(img); off += 32) {
- len = base64_encode(&img[off], 32, enc_img, 1);
- assert(len > 0);
-
hdr = (struct nmgr_hdr *)buf;
memset(hdr, 0, sizeof(*hdr));
hdr->nh_op = NMGR_OP_WRITE;
@@ -45,12 +86,15 @@ TEST_CASE(boot_serial_upload_bigger_image)
hdr->nh_id = IMGMGR_NMGR_OP_UPLOAD;
if (off) {
- len = sprintf((char *)(hdr + 1), "{\"off\":%d,\"data\":\"%s\"}",
- off, enc_img);
+ memcpy(buf + payload_off, payload_next, sizeof payload_next);
+ len = sizeof payload_next;
+ buf[payload_off + len - 2] = Value8Bit;
+ buf[payload_off + len - 1] = off;
} else {
- len = sprintf((char *)(hdr + 1), "{\"off\": 0 ,\"len\":%ld, "
- "\"data\":\"%s\"}", (long)sizeof(img), enc_img);
+ memcpy(buf + payload_off, payload_first, sizeof payload_first);
+ len = sizeof payload_first;
}
+ memcpy(buf + img_data_off, img + off, 32);
hdr->nh_len = htons(len);
len = sizeof(*hdr) + len;