Skip to content

Commit

Permalink
refactor!: remove rollup refs from abi-multi test to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed May 2, 2024
1 parent be884e2 commit 79018d1
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 148 deletions.
1 change: 0 additions & 1 deletion sys-utils/libcmt/src/io-mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,3 @@ int cmt_io_yield(cmt_io_driver_t *_me, struct cmt_io_yield *rr) {
}
return rc;
}

30 changes: 6 additions & 24 deletions sys-utils/libcmt/src/merkle.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "merkle.h"
#include "util.h"

#include <errno.h>
#include <stdbool.h>
Expand Down Expand Up @@ -131,17 +132,10 @@ int cmt_merkle_load(cmt_merkle_t *me, const char *filepath) {
if (!me) {
return -EINVAL;
}
FILE *fin = fopen(filepath, "rb");
if (!fin) {
return -errno;
}
size_t read = fread(me, 1, sizeof(*me), fin);
int rc = 0;
if (read < sizeof(*me)) {
rc = -ENOBUFS;
}
if (fclose(fin) != 0 && rc == 0) {
return -errno;
size_t length = 0;
int rc = cmt_util_read_whole_file(filepath, sizeof *me, me, &length);
if (length != sizeof *me) {
return -EINVAL;
}
return rc;
}
Expand All @@ -150,19 +144,7 @@ int cmt_merkle_save(cmt_merkle_t *me, const char *filepath) {
if (!me) {
return -EINVAL;
}
FILE *fout = fopen(filepath, "wb");
if (!fout) {
return -errno;
}
size_t written = fwrite(me, 1, sizeof(*me), fout);
int rc = 0;
if (written < sizeof(*me)) {
rc = -EIO;
}
if (fclose(fout) != 0 && rc == 0) {
return -errno;
}
return rc;
return cmt_util_write_whole_file(filepath, sizeof *me, me);
}

uint64_t cmt_merkle_get_leaf_count(cmt_merkle_t *me) {
Expand Down
10 changes: 4 additions & 6 deletions sys-utils/libcmt/src/util.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand All @@ -24,10 +23,10 @@ int cmt_util_read_whole_file(const char *name, size_t max, void *data, size_t *l
if (!file) {
return -errno;
}

*length = fread(data, 1, max, file);
if (!feof(file)) {
rc = -ENOBUFS;
int eof = (fseek(file, 0, SEEK_END) == 0) && (*length == (size_t) ftell(file));
if (!eof) {
rc = -EIO;
}
if (fclose(file) != 0) {
rc = -errno;
Expand All @@ -51,4 +50,3 @@ int cmt_util_write_whole_file(const char *name, size_t length, const void *data)
}
return rc;
}

112 changes: 46 additions & 66 deletions sys-utils/libcmt/tests/abi-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
#include <stdint.h>
#include <stdio.h>

// EvmAdvance(address,uint256,uint256,uint256,bytes)
#define ADVANCE CMT_ABI_FUNSEL(0xd2, 0x0c, 0x60, 0xb4)
// Request(address,uint256,uint256,uint256,bytes)
#define REQUEST CMT_ABI_FUNSEL(0xf2, 0xbd, 0x3e, 0x8e)

// Voucher(address,bytes)
#define VOUCHER CMT_ABI_FUNSEL(0xef, 0x61, 0x5e, 0x2f)

// Notice(bytes)
#define NOTICE CMT_ABI_FUNSEL(0xc2, 0x58, 0xd6, 0xe5)
// Reply(address,bytes)
#define REPLY CMT_ABI_FUNSEL(0x88, 0x6c, 0xbf, 0xaa)

static int memeq(uint8_t *x, uint8_t *y, size_t n, const char *file, int line) {
for (size_t i = 0; i < n; ++i) {
Expand All @@ -40,22 +37,27 @@ static int memeq(uint8_t *x, uint8_t *y, size_t n, const char *file, int line) {
return 0;
}

static int advance(void) {
// cast calldata "EvmAdvance(address,uint256,uint256,uint256,bytes)" `cast address-zero` 1 2 3 0xdeadbeef | xxd -r
// -p | xxd -n advance -i
uint8_t evm_advance[] = {0xd2, 0x0c, 0x60, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static int test_request(void) {
// cast calldata "Request(address,uint256,uint256,uint256,bytes)" `cast address-zero` 1 2 3 0xdeadbeef | xxd -r -p | xxd -n request -i
unsigned char request[] = {
// clang-format off
0xf2, 0xbd, 0x3e, 0x8e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
// clang-format on
};
uint8_t mem[256];
cmt_buf_t bb[1] = {{mem, mem + sizeof mem}};
cmt_buf_t wr[1] = {*bb};
Expand All @@ -64,7 +66,7 @@ static int advance(void) {
uint8_t address[20] = {0};
uint8_t bytes[] = {0xde, 0xad, 0xbe, 0xef};

cmt_abi_put_funsel(wr, ADVANCE);
cmt_abi_put_funsel(wr, REQUEST);
uint8_t *frame = wr->begin; // dynamic frame begins after funsel
cmt_abi_put_address(wr, address);
cmt_abi_put_uint(wr, sizeof(int), &(int[]){1});
Expand All @@ -73,20 +75,24 @@ static int advance(void) {
cmt_abi_put_bytes_s(wr, of);
cmt_abi_put_bytes_d(wr, of, sizeof bytes, bytes, frame);

return sizeof evm_advance != (wr->begin - bb->begin) ||
memeq(evm_advance, bb->begin, sizeof evm_advance, __FILE__, __LINE__);
return sizeof request != (wr->begin - bb->begin) || memeq(request, bb->begin, sizeof request, __FILE__, __LINE__);
}

static int voucher(void) {
// cast calldata "Voucher(address,bytes)" `cast address-zero` 0xdeadbeef | xxd -r -p | xxd -n voucher -i
unsigned char evm_voucher[] = {0xef, 0x61, 0x5e, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xde, 0xad, 0xbe, 0xef,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static int test_reply(void) {
// cast calldata "Reply(address,bytes)" `cast address-zero` 0xdeadbeef | xxd -r -p | xxd -n reply -i
unsigned char reply[] = {
// clang-format off
0x88, 0x6c, 0xbf, 0xaa,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
// clang-format on
};

uint8_t mem[256];
cmt_buf_t bb[1] = {{mem, mem + sizeof mem}};
Expand All @@ -96,43 +102,17 @@ static int voucher(void) {
uint8_t address[20] = {0};
uint8_t bytes[] = {0xde, 0xad, 0xbe, 0xef};

cmt_abi_put_funsel(wr, VOUCHER);
cmt_abi_put_funsel(wr, REPLY);
uint8_t *frame = wr->begin; // dynamic frame begins after funsel
cmt_abi_put_address(wr, address);
cmt_abi_put_bytes_s(wr, of);
cmt_abi_put_bytes_d(wr, of, sizeof bytes, bytes, frame);

return sizeof evm_voucher != (wr->begin - bb->begin) ||
memeq(evm_voucher, bb->begin, sizeof evm_voucher, __FILE__, __LINE__);
}

static int notice(void) {
unsigned char evm_notice[] = {0xc2, 0x58, 0xd6, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

uint8_t mem[256];
cmt_buf_t bb[1] = {{mem, mem + sizeof mem}};
cmt_buf_t wr[1] = {*bb};
cmt_buf_t of[1];

uint8_t bytes[] = {0xde, 0xad, 0xbe, 0xef};

cmt_abi_put_funsel(wr, NOTICE);
uint8_t *frame = wr->begin; // dynamic frame begins after funsel
cmt_abi_put_bytes_s(wr, of);
cmt_abi_put_bytes_d(wr, of, sizeof bytes, bytes, frame);

return sizeof evm_notice != (wr->begin - bb->begin) ||
memeq(evm_notice, bb->begin, sizeof evm_notice, __FILE__, __LINE__);
return sizeof reply != (wr->begin - bb->begin) || memeq(reply, bb->begin, sizeof reply, __FILE__, __LINE__);
}

int main(void) {
assert(advance() == 0);
assert(voucher() == 0);
assert(notice() == 0);
assert(test_request() == 0);
assert(test_reply() == 0);
return 0;
}
28 changes: 12 additions & 16 deletions sys-utils/libcmt/tests/abi-single.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@
/** Declare a cmt_buf_t with stack backed memory.
* @param [in] N - size in bytes
* @note don't port */
#define CMT_BUF_DECL(S, L) \
cmt_buf_t S[1] = {{.begin = (uint8_t[L]){0}, \
.end = (S)->begin + (L)}} // NOLINT(clang-analyzer-core.UndefinedBinaryOperatorResult)
#define CMT_BUF_DECL(S, L) cmt_buf_t S[1] = {{.begin = (uint8_t[L]){0}, .end = (S)->begin + (L)}}

/** Declare a cmt_buf_t with parameters backed memory.
* @param [in] L - size in bytes
* @note don't port */
#define CMT_BUF_DECL3(S, L, P) \
cmt_buf_t S[1] = { \
{.begin = (P), .end = (S)->begin + (L)}} // NOLINT(clang-analyzer-core.UndefinedBinaryOperatorResult)
#define CMT_BUF_DECL3(S, L, P) cmt_buf_t S[1] = {{.begin = (P), .end = (S)->begin + (L)}}

// funsel(address)
#define FUNSEL CMT_ABI_FUNSEL(0xe6, 0x36, 0xe3, 0x33)
Expand Down Expand Up @@ -211,12 +207,12 @@ static void decode_uint_edom(void) {
}

{
uint8_t x [CMT_WORD_LENGTH+1] = {0};
uint8_t x[CMT_WORD_LENGTH + 1] = {0};
assert(cmt_abi_decode_uint_nr(be, sizeof(x), x) == -EDOM);
}

{
uint8_t x [CMT_WORD_LENGTH+1] = {0};
uint8_t x[CMT_WORD_LENGTH + 1] = {0};
assert(cmt_abi_decode_uint_nn(be, sizeof(x), x) == -EDOM);
}
}
Expand Down Expand Up @@ -265,7 +261,7 @@ static void put_uint_enobufs(void) {
}

static void put_uint_edom(void) {
uint64_t x[CMT_WORD_LENGTH+1] = {0};
uint64_t x[CMT_WORD_LENGTH + 1] = {0};
CMT_BUF_DECL(b, CMT_WORD_LENGTH);
cmt_buf_t it[1] = {*b};

Expand Down Expand Up @@ -309,7 +305,7 @@ static void put_address(void) {

static void put_address_enobufs(void) {
uint8_t x[CMT_ADDRESS_LENGTH] = {0};
CMT_BUF_DECL(b, CMT_WORD_LENGTH-1);
CMT_BUF_DECL(b, CMT_WORD_LENGTH - 1);
cmt_buf_t it[1] = {*b};

assert(cmt_abi_put_address(it, x) == -ENOBUFS);
Expand Down Expand Up @@ -395,7 +391,7 @@ static void get_uint_enobufs(void) {
}

static void get_uint_edom(void) {
uint64_t x[CMT_WORD_LENGTH+1] = {0};
uint64_t x[CMT_WORD_LENGTH + 1] = {0};
CMT_BUF_DECL(b, CMT_WORD_LENGTH);
cmt_buf_t it[1] = {*b};

Expand Down Expand Up @@ -437,7 +433,7 @@ static void get_bool(void) {

static void get_bool_enobufs(void) {
bool x = false;
uint8_t be[CMT_WORD_LENGTH-1] = {
uint8_t be[CMT_WORD_LENGTH - 1] = {
// clang-format off
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -472,7 +468,7 @@ static void get_address(void) {

static void get_address_enobufs(void) {
uint8_t x[CMT_ADDRESS_LENGTH];
uint8_t be[CMT_WORD_LENGTH-1] = {
uint8_t be[CMT_WORD_LENGTH - 1] = {
// clang-format off
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x23, 0x45, 0x67,
0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45,
Expand Down Expand Up @@ -515,7 +511,7 @@ static void get_bytes_enobufs(void) {
// clang-format on
};

{ // when offset of dynamic reagion failed
{ // when offset of dynamic reagion failed
CMT_BUF_DECL3(b, 1 * CMT_WORD_LENGTH - 1, be);
cmt_buf_t it[1] = {*b};
cmt_buf_t of[1] = {0};
Expand All @@ -524,7 +520,7 @@ static void get_bytes_enobufs(void) {
assert(cmt_abi_peek_bytes_d(it, of, bytes) == -ENOBUFS);
}

{ // dynamic reagion is too small to peek bytes
{ // dynamic reagion is too small to peek bytes
CMT_BUF_DECL3(b, 3 * CMT_WORD_LENGTH - 1, be);
cmt_buf_t it[1] = {*b};
cmt_buf_t of[1] = {0};
Expand All @@ -534,7 +530,7 @@ static void get_bytes_enobufs(void) {
assert(cmt_abi_peek_bytes_d(it, of, bytes) == -ENOBUFS);
}

{ // dynamic reagion is too small to copy bytes
{ // dynamic reagion is too small to copy bytes
CMT_BUF_DECL3(b, 3 * CMT_WORD_LENGTH - 1, be);
cmt_buf_t it[1] = {*b};
cmt_buf_t of[1] = {0};
Expand Down
9 changes: 4 additions & 5 deletions sys-utils/libcmt/tests/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,15 @@ static void split_by_comma_until_the_end(void) {
cmt_buf_init(&x, sizeof _ - 1, _);
cmt_buf_init(&xs, sizeof _ - 1, _);
assert(cmt_buf_split_by_comma(&x, &xs) == true);
assert(strncmp((char *)x.begin, "a", 1UL) == 0);
assert(strncmp((char *) x.begin, "a", 1UL) == 0);
assert(cmt_buf_split_by_comma(&x, &xs) == true);
assert(strncmp((char *)x.begin, "b", 1UL) == 0);
assert(strncmp((char *) x.begin, "b", 1UL) == 0);
assert(cmt_buf_split_by_comma(&x, &xs) == true);
assert(strncmp((char *)x.begin, "c", 1UL) == 0);
assert(strncmp((char *) x.begin, "c", 1UL) == 0);
assert(cmt_buf_split_by_comma(&x, &xs) == false);
}

static void xxd(void)
{
static void xxd(void) {
uint8_t _[] = "";
cmt_buf_xxd(_, _ + sizeof _, 0);
cmt_buf_xxd(_, _ + sizeof _, 1);
Expand Down
13 changes: 6 additions & 7 deletions sys-utils/libcmt/tests/gio.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include <string.h>
#include <stdlib.h>
#include "data.h"
#include "rollup.h"
#include "util.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include "rollup.h"
#include "data.h"
#include "util.h"
#include <stdlib.h>
#include <string.h>

int main(void)
{
int main(void) {
uint8_t buffer[1024];
size_t buffer_length = 0;
cmt_rollup_t rollup;
Expand Down

0 comments on commit 79018d1

Please sign in to comment.