Changeset 9520af7 in mainline for uspace/srv/net/tcp/test/conn.c


Ignore:
Timestamp:
2017-09-12T15:48:01Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d40c93d
Parents:
0a1e7e4
Message:

Allow TCP conn tests that involve transferring data by enabling an internal loopback. Add simple →SYN, ←RST test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/test/conn.c

    r0a1e7e4 r9520af7  
    3333
    3434#include "../conn.h"
     35#include "../rqueue.h"
     36#include "../ucall.h"
    3537
    3638PCUT_INIT
    3739
    3840PCUT_TEST_SUITE(conn);
     41
     42static tcp_rqueue_cb_t test_rqueue_cb = {
     43        .seg_received = tcp_as_segment_arrived
     44};
    3945
    4046PCUT_TEST_BEFORE
     
    4854        rc = tcp_conns_init();
    4955        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     56
     57        tcp_rqueue_init(&test_rqueue_cb);
     58        tcp_rqueue_fibril_start();
    5059}
    5160
    5261PCUT_TEST_AFTER
    5362{
     63        tcp_rqueue_fini();
    5464        tcp_conns_fini();
    5565}
     
    7181}
    7282
    73 /** Test adding, finding and removing a connection */
    74 PCUT_TEST(add_find_remove)
     83/** Test adding, finding and deleting a connection */
     84PCUT_TEST(add_find_delete)
    7585{
    7686        tcp_conn_t *conn, *cfound;
     
    101111}
    102112
     113/** Test trying to connect to endpoint that sends RST back */
     114PCUT_TEST(connect_rst)
     115{
     116        tcp_conn_t *conn;
     117        inet_ep2_t epp;
     118        int rc;
     119
     120        tcp_conn_lb = tcp_lb_segment;
     121
     122        inet_ep2_init(&epp);
     123        inet_addr(&epp.local.addr, 127, 0, 0, 1);
     124        inet_addr(&epp.remote.addr, 127, 0, 0, 1);
     125        epp.remote.port = inet_port_user_lo;
     126
     127        conn = tcp_conn_new(&epp);
     128        PCUT_ASSERT_NOT_NULL(conn);
     129
     130        rc = tcp_conn_add(conn);
     131        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     132
     133        PCUT_ASSERT_INT_EQUALS(st_listen, conn->cstate);
     134
     135        tcp_conn_lock(conn);
     136        tcp_conn_sync(conn);
     137        PCUT_ASSERT_INT_EQUALS(st_syn_sent, conn->cstate);
     138
     139        while (conn->cstate == st_syn_sent)
     140                fibril_condvar_wait(&conn->cstate_cv, &conn->lock);
     141
     142        PCUT_ASSERT_INT_EQUALS(st_closed, conn->cstate);
     143
     144        tcp_conn_unlock(conn);
     145        tcp_conn_delete(conn);
     146}
     147
    103148PCUT_EXPORT(conn);
Note: See TracChangeset for help on using the changeset viewer.