Skip to content

Commit 704a5d7

Browse files
committed
tests(axiom): Adds test if log fowarded labels is NULL
1 parent a3d230c commit 704a5d7

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

axiom/tests/test_cmd_txndata.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,66 @@ static void test_encode_log_forwarding_labels(void) {
11751175
nro_delete(obj);
11761176
}
11771177

1178+
static void test_encode_log_forwarding_labels_null(void) {
1179+
nrtxn_t txn;
1180+
nr_flatbuffers_table_t tbl;
1181+
nrobj_t* obj;
1182+
nr_flatbuffer_t* fb;
1183+
int data_type;
1184+
int did_pass;
1185+
const char* input = "alpha:beta;gamma:delta";
1186+
1187+
obj = nr_labels_parse(input);
1188+
1189+
nr_memset(&txn, 0, sizeof(txn));
1190+
txn.status.recording = 1;
1191+
txn.options.log_forwarding_enabled = 1;
1192+
txn.options.log_forwarding_labels_enabled = 1;
1193+
txn.log_forwarding_labels = NULL;
1194+
1195+
fb = nr_txndata_encode(&txn);
1196+
1197+
nr_flatbuffers_table_init_root(&tbl, nr_flatbuffers_data(fb),
1198+
nr_flatbuffers_len(fb));
1199+
1200+
data_type = nr_flatbuffers_table_read_i8(&tbl, MESSAGE_FIELD_DATA_TYPE,
1201+
MESSAGE_BODY_NONE);
1202+
did_pass = tlib_pass_if_true(__func__, MESSAGE_BODY_TXN == data_type,
1203+
"data_type=%d", data_type);
1204+
if (0 != did_pass) {
1205+
goto done;
1206+
}
1207+
1208+
did_pass = tlib_pass_if_true(
1209+
__func__,
1210+
0 != nr_flatbuffers_table_read_union(&tbl, &tbl, MESSAGE_FIELD_DATA),
1211+
"transaction data missing");
1212+
if (0 != did_pass) {
1213+
goto done;
1214+
}
1215+
1216+
did_pass
1217+
= tlib_pass_if_true(__func__,
1218+
0
1219+
!= nr_flatbuffers_table_read_union(
1220+
&tbl, &tbl, TRANSACTION_FIELD_LOG_LABELS),
1221+
"log labels missing");
1222+
if (0 != did_pass) {
1223+
goto done;
1224+
}
1225+
1226+
tlib_pass_if_bytes_equal_f(
1227+
__func__, NR_PSTR("[]"),
1228+
nr_flatbuffers_table_read_bytes(&tbl, EVENT_FIELD_DATA),
1229+
nr_flatbuffers_table_read_vector_len(&tbl, EVENT_FIELD_DATA), __FILE__,
1230+
__LINE__);
1231+
1232+
done:
1233+
nr_flatbuffers_destroy(&fb);
1234+
nr_txn_destroy_fields(&txn);
1235+
nro_delete(obj);
1236+
}
1237+
11781238
static void test_encode_php_packages(void) {
11791239
nrtxn_t txn;
11801240
nr_flatbuffers_table_t tbl;
@@ -1343,6 +1403,7 @@ void test_main(void* p NRUNUSED) {
13431403
test_encode_txn_event();
13441404
test_encode_log_events();
13451405
test_encode_log_forwarding_labels();
1406+
test_encode_log_forwarding_labels_null();
13461407
test_encode_php_packages();
13471408

13481409
test_bad_daemon_fd();

0 commit comments

Comments
 (0)