blob: c296f5a1a2dbf41f361c255b44fb11c2d93ef3b4 [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
Suraj Jitindar Singh29b3e8a2017-05-01 16:00:39 +10003
4#include <assert.h>
5
6#include "mbox.h"
Andrew Jeffery457a6e52018-08-08 11:21:08 +09307#include "transport_mbox.h"
Suraj Jitindar Singh29b3e8a2017-05-01 16:00:39 +10008
9#include "test/mbox.h"
10#include "test/system.h"
11
12static const uint8_t command[] = {
13 0x02, 0xaa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
14 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
15};
16
17static const uint8_t response[] = {
18 0x02, 0xaa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
19 /* Window size == 1MB -> suggested timeout == 8 (seconds) */
20 0x08, 0x00, 0x00, 0x00, 0x00, 0x01,
21};
22
23/*
24 * Suggested timeout is based on a milliseconds-per-MB constant. Thus to
25 * get a non-zero value we need a window of size atleast 1MB.
26 */
27#define MEM_SIZE 1 << 20
28#define ERASE_SIZE 1
29#define N_WINDOWS 1
30#define WINDOW_SIZE 1 << 20
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, command, sizeof(command));
43 assert(rc == 1);
44
45 rc = mbox_cmp(ctx, response, sizeof(response));
46 assert(rc == 0);
47
48 return rc;
49}