static struct ptunit_result sync_fwd_null(struct sync_fixture *sfix) { const uint8_t *sync; int errcode; errcode = pt_sync_forward(NULL, sfix->config.begin, &sfix->config); ptu_int_eq(errcode, -pte_internal); errcode = pt_sync_forward(&sync, NULL, &sfix->config); ptu_int_eq(errcode, -pte_internal); errcode = pt_sync_forward(&sync, sfix->config.begin, NULL); ptu_int_eq(errcode, -pte_internal); return ptu_passed(); }
int pt_pkt_sync_forward(struct pt_packet_decoder *decoder) { const uint8_t *pos, *sync; int errcode; if (!decoder) return -pte_invalid; sync = decoder->sync; pos = decoder->pos; if (!pos) pos = decoder->config.begin; if (pos == sync) pos += ptps_psb; errcode = pt_sync_forward(&sync, pos, &decoder->config); if (errcode < 0) return errcode; decoder->sync = sync; decoder->pos = sync; return 0; }
static struct ptunit_result sync_fwd_empty(struct sync_fixture *sfix) { const uint8_t *sync; int errcode; sfix->config.end = sfix->config.begin; errcode = pt_sync_forward(&sync, sfix->config.begin, &sfix->config); ptu_int_eq(errcode, -pte_eos); return ptu_passed(); }
static struct ptunit_result sync_fwd_past(struct sync_fixture *sfix) { const uint8_t *sync; int errcode; sfix_encode_psb(sfix->config.begin); errcode = pt_sync_forward(&sync, sfix->config.begin + ptps_psb, &sfix->config); ptu_int_eq(errcode, -pte_eos); return ptu_passed(); }
static struct ptunit_result sync_fwd(struct sync_fixture *sfix) { const uint8_t *sync; int errcode; sfix_encode_psb(sfix->config.begin + 0x23); errcode = pt_sync_forward(&sync, sfix->config.begin, &sfix->config); ptu_int_eq(errcode, 0); ptu_ptr_eq(sync, sfix->config.begin + 0x23); return ptu_passed(); }