Esempio n. 1
0
static struct ptunit_result encoder_init_null(void)
{
	struct pt_encoder encoder;
	struct pt_config config;
	int errcode;

	errcode = pt_encoder_init(NULL, &config);
	ptu_int_eq(errcode, -pte_invalid);

	errcode = pt_encoder_init(&encoder, NULL);
	ptu_int_eq(errcode, -pte_invalid);

	return ptu_passed();
}
static struct ptunit_result ffix_init(struct fetch_fixture *ffix)
{
	memset(ffix->buffer, pt_opc_bad, sizeof(ffix->buffer));

	memset(&ffix->config, 0, sizeof(ffix->config));
	ffix->config.size = sizeof(ffix->config);
	ffix->config.begin = ffix->buffer;
	ffix->config.end = ffix->buffer + sizeof(ffix->buffer);

	pt_encoder_init(&ffix->encoder, &ffix->config);

	return ptu_passed();
}
Esempio n. 3
0
struct pt_encoder *pt_alloc_encoder(const struct pt_config *config)
{
	struct pt_encoder *encoder;
	int errcode;

	encoder = malloc(sizeof(*encoder));
	if (!encoder)
		return NULL;

	errcode = pt_encoder_init(encoder, config);
	if (errcode < 0) {
		free(encoder);
		return NULL;
	}

	return encoder;
}
Esempio n. 4
0
static struct ptunit_result tfix_init(struct test_fixture *tfix)
{
	struct pt_config *config;
	uint8_t *buffer;
	int errcode;

	config = &tfix->config;
	buffer = tfix->buffer;

	memset(buffer, 0, sizeof(tfix->buffer));

	pt_config_init(config);
	config->begin = buffer;
	config->end = buffer + sizeof(tfix->buffer);

	errcode = pt_encoder_init(&tfix->encoder, config);
	ptu_int_eq(errcode, 0);

	return ptu_passed();
}
static struct ptunit_result pfix_init(struct packet_fixture *pfix)
{
	int errcode;

	memset(pfix->buffer, 0, sizeof(pfix->buffer));
	memset(pfix->packet, 0, sizeof(pfix->packet));
	memset(&pfix->config, 0, sizeof(pfix->config));
	pfix->config.size = sizeof(pfix->config);
	pfix->config.begin = pfix->buffer;
	pfix->config.end = pfix->buffer + sizeof(pfix->buffer);
	pfix->config.decode.callback = pfix_decode_unknown;
	pfix->config.decode.context = pfix;

	pt_encoder_init(&pfix->encoder, &pfix->config);
	pt_pkt_decoder_init(&pfix->decoder, &pfix->config);

	errcode = pt_pkt_sync_set(&pfix->decoder, 0x0ull);
	ptu_int_eq(errcode, 0);

	pfix->unknown = 0;

	return ptu_passed();
}