==> tests/copies.c <==1/* jobs.rs's `copies` test. */
2#include "mesh/jobs/copies.h"
3#include "mesh/check.h"
4
5static uint32_t c(uint32_t me, uint32_t n, uint32_t leader, uint32_t alive, uint32_t refused) {
6 uint32_t w = 0xdead;
7 CHECK(mj_copies_for(me, n, true, leader, alive, refused, &w));
8 return w;
9}
10
11int main(void) {
12 /* 4 members, leader 0: member 1's payload at 1, 0 and 2; the leader's at 0, 1, 2; with 2 down, 3 instead. */
13 CHECK_U(c(1, 4, 0, 0xf, 0), 0x7);
14 CHECK_U(c(0, 4, 0, 0xf, 0), 0x7);
15 CHECK_U(c(1, 4, 0, 0xb, 0), 0xb);
16 CHECK_U(c(3, 4, 0, 0xf, 0), 0xb);
17 /* A refusal (a full store) is skipped, but never the leader's; no leader: none. */
18 CHECK_U(c(1, 4, 0, 0xf, 0x6), 0x9);
19 CHECK_U(c(1, 4, 0, 0xf, 0x1), 0x7);
20 CHECK_U(c(0, 1, 0, 0x1, 0), 0x1);
21 uint32_t w;
22 CHECK(!mj_copies_for(1, 4, false, 0, 0xf, 0, &w));
23 return mesh_check_done();
24}