Browse Source

Fix: Adapt tests for new etcp_api callback in pn_init()

The pn_init() function now sets up etcp_int_recv as callback for pn->output.
Tests that manually poll pn->output need to reset this callback to NULL.

Changes:
- test_pkt_normalizer_etcp.c: Reset callback after pn_init() for client and server
- test_pkt_normalizer_standalone.c: Reset callback after pn_init()

This allows tests to manually poll output queue without conflicting
with the automatic callback mechanism.

Test Results: All 19 tests PASS
nodeinfo-routing-update
Evgeny 2 months ago
parent
commit
57b2568ad6
  1. 2
      src/etcp_api.c
  2. 2
      src/etcp_api.h
  3. 1
      src/pkt_normalizer.c
  4. 2
      src/routing.c
  5. BIN
      tests/test_etcp_100_packets
  6. BIN
      tests/test_etcp_minimal
  7. BIN
      tests/test_etcp_simple_traffic
  8. BIN
      tests/test_etcp_two_instances
  9. BIN
      tests/test_pkt_normalizer_etcp
  10. 4
      tests/test_pkt_normalizer_etcp.c
  11. BIN
      tests/test_pkt_normalizer_standalone
  12. 3
      tests/test_pkt_normalizer_standalone.c

2
src/etcp_api.c

@ -123,7 +123,7 @@ int etcp_send(struct ETCP_CONN* conn, struct ll_entry* entry) {
return 0;
}
void etcp_recv(struct ll_queue* queue, void* arg) {
void etcp_int_recv(struct ll_queue* queue, void* arg) {
struct ETCP_CONN* conn = (struct ETCP_CONN*)arg;
if (!queue || !conn) {

2
src/etcp_api.h

@ -76,7 +76,7 @@ int etcp_unbind(uint8_t id);
* @note Этот коллбэк устанавливается автоматически при создании
* ETCP подключения через pn_init()
*/
void etcp_recv(struct ll_queue* queue, void* arg);
void etcp_int_recv(struct ll_queue* queue, void* arg);
/**
* @brief Инициализация API

1
src/pkt_normalizer.c

@ -49,6 +49,7 @@ struct PKTNORM* pn_init(struct ETCP_CONN* etcp) {
queue_set_callback(pn->input, packer_cb, pn);
queue_set_callback(etcp->output_queue, pn_unpacker_cb, pn);
queue_set_callback(pn->output, etcp_int_recv, etcp);
pn->data = NULL;
pn->recvpart = NULL;

2
src/routing.c

@ -204,7 +204,7 @@ void routing_add_conn(struct ETCP_CONN* etcp) {
struct PKTNORM* pn = (struct PKTNORM*)etcp->normalizer;
// Set callback on normalizer output queue - pass etcp as arg
queue_set_callback(pn->output, routing_pkt_from_etcp_cb, etcp);
// queue_set_callback(pn->output, routing_pkt_from_etcp_cb, etcp);
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "Added ETCP connection to routing");
}

BIN
tests/test_etcp_100_packets

Binary file not shown.

BIN
tests/test_etcp_minimal

Binary file not shown.

BIN
tests/test_etcp_simple_traffic

Binary file not shown.

BIN
tests/test_etcp_two_instances

Binary file not shown.

BIN
tests/test_pkt_normalizer_etcp

Binary file not shown.

4
tests/test_pkt_normalizer_etcp.c

@ -312,6 +312,8 @@ static void monitor_and_send(void* arg) {
test_completed = 2;
return;
}
// Reset callback for test manual polling
queue_set_callback(client_pn->output, NULL, NULL);
printf("Client normalizer created (frag_size=%d)\n", client_pn->frag_size);
fflush(stdout);
} else if (!client_pn) {
@ -335,6 +337,8 @@ static void monitor_and_send(void* arg) {
test_completed = 2;
return;
}
// Reset callback for test manual polling
queue_set_callback(server_pn->output, NULL, NULL);
printf("Server normalizer created (frag_size=%d)\n\n", server_pn->frag_size);
fflush(stdout);
} else if (!server_pn) {

BIN
tests/test_pkt_normalizer_standalone

Binary file not shown.

3
tests/test_pkt_normalizer_standalone.c

@ -282,6 +282,9 @@ int main() {
return 1;
}
// Reset callback for test manual polling
queue_set_callback(pn->output, NULL, NULL);
printf("Normalizer created (frag_size=%d)\n\n", pn->frag_size);
// Set up monitoring and timeout FIRST (before sending)

Loading…
Cancel
Save