2 * Copyright (c) 2023 Jiri Svoboda
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include "../tester.h"
42 static uint8_t rw_buf
[rw_buf_size
];
44 const char *test_readwrite(void)
46 ipc_test_t
*test
= NULL
;
50 rc
= ipc_test_create(&test
);
52 return "Error contacting IPC test service.";
54 rc
= ipc_test_set_rw_buf_size(test
, rw_buf_size
);
56 return "Error getting read-only area size.";
59 * Write all zeroes to remote buffer
61 memset(rw_buf
, 0x00, rw_buf_size
);
62 rc
= ipc_test_write(test
, rw_buf
, rw_buf_size
);
64 return "Error writing remote buffer.";
66 TPRINTF("Successfully wrote zeroes to remote buffer.\n");
69 * Read back contents of remote buffer and verify
73 * Make sure the contents of local buffer are different from what
76 memset(rw_buf
, 0xff, rw_buf_size
);
77 rc
= ipc_test_read(test
, rw_buf
, rw_buf_size
);
79 return "Error reading remote buffer.";
81 TPRINTF("Successfully read back remote buffer.\n");
83 /* Now verify what we have read */
84 for (i
= 0; i
< rw_buf_size
; i
++) {
85 if (rw_buf
[i
] != 0x00)
86 return "Failed verification of read data.";
89 TPRINTF("Read data succeeded verification.\n");
92 * Write all binary ones to remote buffer
94 memset(rw_buf
, 0xff, rw_buf_size
);
95 rc
= ipc_test_write(test
, rw_buf
, rw_buf_size
);
97 return "Error writing remote buffer.";
99 TPRINTF("Successfully wrote binary ones to remote buffer.\n");
102 * Read back contents of remote buffer and verify
106 * Make sure the contents of local buffer are different from what
109 memset(rw_buf
, 0x00, rw_buf_size
);
110 rc
= ipc_test_read(test
, rw_buf
, rw_buf_size
);
112 return "Error reading remote buffer.";
114 TPRINTF("Successfully read back remote buffer.\n");
116 /* Now verify what we have read */
117 for (i
= 0; i
< rw_buf_size
; i
++) {
118 if (rw_buf
[i
] != 0xff)
119 return "Failed verification of read data.";
122 TPRINTF("Read data succeeded verification.\n");
124 ipc_test_destroy(test
);