blob: 713c62bd3027e6e00a391237321b7a28244985d6 [file] [log] [blame]
Andrew Jeffery5f374bc2017-04-12 22:06:06 +09301/*
2 * MBox Daemon Test File
3 *
4 * Copyright 2017 IBM
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#include <assert.h>
21
22#include "mbox.h"
23#include "mboxd_msg.h"
24
25#include "test/mbox.h"
26#include "test/system.h"
27
28static const uint8_t get_info[] = {
29 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
31};
32
33static const uint8_t create_read_window[] = {
34 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
36};
37
38static const uint8_t response[] = {
39 0x04, 0x01, 0xfd, 0xff, 0x03, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
41};
42
43uint8_t data[3] = { 0xaa, 0x55, 0xaa };
44
45#define MEM_SIZE sizeof(data)
46#define ERASE_SIZE 1
47#define N_WINDOWS 1
48#define WINDOW_SIZE sizeof(data)
49
50int main(void)
51{
52 struct mbox_context *ctx;
53 int rc;
54
55 system_set_reserved_size(MEM_SIZE);
56 system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
57
58 ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
59 rc = mbox_set_mtd_data(ctx, data, sizeof(data));
60 assert(rc == 0);
61
62 rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
63 assert(rc == 1);
64
65 rc = mbox_command_dispatch(ctx, create_read_window,
66 sizeof(create_read_window));
67 assert(rc == 1);
68
69 rc = mbox_cmp(ctx, response, sizeof(response));
70 assert(rc == 0);
71
72 return rc;
73};