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