blob: 7fb37034b30a4dd3b01daacc741432c2da2ff4ca [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
Andrew Jeffery182d4fe2017-04-12 14:39:24 +09303
4#include <assert.h>
5
6#include "mbox.h"
Andrew Jeffery457a6e52018-08-08 11:21:08 +09307#include "transport_mbox.h"
Andrew Jeffery182d4fe2017-04-12 14:39:24 +09308
9#include "test/mbox.h"
10#include "test/system.h"
11
12static const uint8_t get_info[] = {
13 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
14 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
15};
16
17static const uint8_t get_flash_info[] = {
18 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20};
21
22static const uint8_t response[] = {
23 0x03, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
25};
26
27#define MEM_SIZE 3
28#define ERASE_SIZE 1
29#define N_WINDOWS 1
30#define WINDOW_SIZE 1
31
32int main(void)
33{
34 struct mbox_context *ctx;
35 int rc;
36
37 system_set_reserved_size(MEM_SIZE);
38 system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
39
40 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
41
42 rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
43 assert(rc == 1);
44
45 rc = mbox_command_dispatch(ctx, get_flash_info, sizeof(get_flash_info));
46 assert(rc == 1);
47
48 rc = mbox_cmp(ctx, response, sizeof(response));
49 assert(rc == 0);
50
51 return rc;
52};