Skip to content

Commit 821018e

Browse files
tests
1 parent e3dea9b commit 821018e

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

tests/src/test_intrusive_header.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ static void test_header_v2(void)
1717
.sender_uid = 0x1122334455667788ULL,
1818
.topic_hash = 0x99AABBCCDDEEFF00ULL,
1919
};
20-
header_serialize(buffer, meta_in, true, 0x00123456, 0x00654321, 0x11223344);
20+
header_serialize(buffer, meta_in, 0x00123456, 0x00654321, 0x11223344);
2121

2222
// >>> from pycyphal.transport.commons.crc import CRC32C
2323
// >>> list(CRC32C.new(data).value_as_bytes)
2424
// clang-format off
2525
const byte_t reference[48] = {
2626
(2U | ((size_t)udpard_prio_high << 5U)), // version | priority
27-
(HEADER_FLAG_EOT), // flags
27+
0, // flags
2828
0, 0, // reserved
2929
0x56, 0x34, 0x12, 0x00, // frame_index
3030
0x21, 0x43, 0x65, 0x00, // frame_payload_offset
@@ -33,20 +33,18 @@ static void test_header_v2(void)
3333
0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, // sender_uid
3434
0x00, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, // topic_hash
3535
0x44, 0x33, 0x22, 0x11, // prefix_crc
36-
113, 119, 83, 71 // header CRC
36+
224, 92, 8, 213 // header CRC
3737
};
3838
// clang-format on
3939
TEST_ASSERT_EQUAL_MEMORY(reference, buffer, HEADER_SIZE_BYTES);
4040

4141
meta_t meta_out;
4242
udpard_bytes_mut_t payload_out;
43-
bool flag_eot = false;
4443
uint32_t frame_index = 0;
4544
uint32_t frame_payload_offset = 0;
4645
uint32_t prefix_crc = 0;
4746
TEST_ASSERT(header_deserialize((udpard_bytes_mut_t){ .size = sizeof(buffer), .data = buffer },
4847
&meta_out,
49-
&flag_eot,
5048
&frame_index,
5149
&frame_payload_offset,
5250
&prefix_crc,
@@ -55,7 +53,6 @@ static void test_header_v2(void)
5553
TEST_ASSERT_EQUAL(&buffer[HEADER_SIZE_BYTES], payload_out.data);
5654

5755
TEST_ASSERT_EQUAL_UINT8(meta_in.priority, meta_out.priority);
58-
TEST_ASSERT_TRUE(flag_eot);
5956
TEST_ASSERT_FALSE(meta_out.flag_ack);
6057
TEST_ASSERT_EQUAL_UINT32(0x00123456, frame_index);
6158
TEST_ASSERT_EQUAL_UINT32(0x00654321, frame_payload_offset);
@@ -67,23 +64,20 @@ static void test_header_v2(void)
6764

6865
TEST_ASSERT_FALSE(header_deserialize((udpard_bytes_mut_t){ .size = 23, .data = buffer },
6966
&meta_out,
70-
&flag_eot,
7167
&frame_index,
7268
&frame_payload_offset,
7369
&prefix_crc,
7470
&payload_out));
7571

7672
TEST_ASSERT(header_deserialize((udpard_bytes_mut_t){ .size = sizeof(buffer), .data = buffer },
7773
&meta_out,
78-
&flag_eot,
7974
&frame_index,
8075
&frame_payload_offset,
8176
&prefix_crc,
8277
&payload_out));
8378
buffer[HEADER_SIZE_BYTES - 1] ^= 0xFFU; // Corrupt the CRC.
8479
TEST_ASSERT_FALSE(header_deserialize((udpard_bytes_mut_t){ .size = sizeof(buffer), .data = buffer },
8580
&meta_out,
86-
&flag_eot,
8781
&frame_index,
8882
&frame_payload_offset,
8983
&prefix_crc,

tests/src/test_intrusive_tx.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,12 @@ static void test_tx_serialize_header(void)
3838
.sender_uid = 0x0123456789ABCDEFULL,
3939
.topic_hash = 0xFEDCBA9876543210ULL,
4040
};
41-
(void)header_serialize(buffer.data, meta, false, 12345, 0, 0);
41+
(void)header_serialize(buffer.data, meta, 12345, 0, 0);
4242
TEST_ASSERT_EQUAL(HEADER_SIZE_BYTES, sizeof(buffer.data));
4343
// Verify version and priority in first byte
4444
TEST_ASSERT_EQUAL((HEADER_VERSION | ((unsigned)udpard_prio_fast << 5U)), buffer.data[0]);
4545
}
46-
// Test case 2: End of transfer flag
47-
{
48-
header_buffer_t buffer;
49-
const meta_t meta = {
50-
.priority = udpard_prio_low,
51-
.flag_ack = false,
52-
.transfer_payload_size = 1234,
53-
.transfer_id = 0x0BADC0DE0BADC0DEULL,
54-
.sender_uid = 0xFEDCBA9876543210ULL,
55-
.topic_hash = 0x0123456789ABCDEFULL,
56-
};
57-
(void)header_serialize(buffer.data, meta, true, 0x7FFF, 100, 0);
58-
TEST_ASSERT_EQUAL((HEADER_VERSION | ((unsigned)udpard_prio_low << 5U)), buffer.data[0]);
59-
TEST_ASSERT_EQUAL(HEADER_FLAG_EOT, buffer.data[1]);
60-
}
61-
// Test case 3: Ack flag
46+
// Test case 2: Ack flag
6247
{
6348
header_buffer_t buffer;
6449
const meta_t meta = {
@@ -69,7 +54,7 @@ static void test_tx_serialize_header(void)
6954
.sender_uid = 0xBBBBBBBBBBBBBBBBULL,
7055
.topic_hash = 0xCCCCCCCCCCCCCCCCULL,
7156
};
72-
(void)header_serialize(buffer.data, meta, false, 100, 200, 0);
57+
(void)header_serialize(buffer.data, meta, 100, 200, 0);
7358
TEST_ASSERT_EQUAL((HEADER_VERSION | ((unsigned)udpard_prio_nominal << 5U)), buffer.data[0]);
7459
TEST_ASSERT_EQUAL(HEADER_FLAG_ACK, buffer.data[1]);
7560
}

0 commit comments

Comments
 (0)