<commit_before>#include "test_common.h"


using namespace XXX;
using namespace std;


void test_WS_destroyed_before_kernel(int port)
{
  cout << "---------- "<< __FUNCTION__ <<" ----------\n";

  callback_status = e_callback_not_invoked;

  {
    unique_ptr<kernel> the_kernel( new kernel({}, logger::nolog() ) );

    unique_ptr<tcp_socket> sock (new tcp_socket(the_kernel.get()));

    /* attempt to connect the socket */
    cout << "attemping socket connection ...\n";
    auto fut = sock->connect("127.0.0.1", port);

    auto connect_status = fut.wait_for(chrono::milliseconds(100));
    if (connect_status == future_status::timeout)
    {
      cout << "    failed to connect\n";
      return;
    }
    cout << "    got socket connection\n";

    /* attempt to create a session */
    cout << "attemping session creation ...\n";
    shared_ptr<wamp_session> session = wamp_session::create<rawsocket_protocol>(
      the_kernel.get(),
      std::move(sock),
      session_cb, {});

    cout << "    got session\n";

    cout << "calling: session->close().wait()\n";
    session->close().wait();
    cout << "trigger ~wamp_session\n";
    session.reset();
    cout << "exiting scope (will trigger kernel, io_loop, ev_loop destruction)...\n";

  }

  // ensure callback was invoked
  assert(callback_status == e_close_callback_with_sp);

  cout << "test success\n";
}


int main(int argc, char** argv)
{
  try
  {
    int starting_port_number = 21000;

    if (argc>1)
      starting_port_number = atoi(argv[1]);

    // share a common internal_server
    for (int i = 0; i < 50; i++)<commit_msg>more logging<commit_after>#include "test_common.h"


using namespace XXX;
using namespace std;


void test_WS_destroyed_before_kernel(int port)
{
  cout << "---------- "<< __FUNCTION__ <<" ----------\n";

  callback_status = e_callback_not_invoked;

  {
    unique_ptr<kernel> the_kernel( new kernel({}, logger::nolog() ) );

    unique_ptr<tcp_socket> sock (new tcp_socket(the_kernel.get()));

    /* attempt to connect the socket */
    cout << "attemping socket connection ...\n";
    auto fut = sock->connect("127.0.0.1", port);

    auto connect_status = fut.wait_for(chrono::milliseconds(100));
    if (connect_status == future_status::timeout)
    {
      cout << "    failed to connect\n";
      return;
    }
    cout << "    got socket connection\n";

    /* attempt to create a session */
    cout << "attemping session creation ...\n";
    shared_ptr<wamp_session> session = wamp_session::create<rawsocket_protocol>(
      the_kernel.get(),
      std::move(sock),
      session_cb, {});

    cout << "    got session\n";

    cout << "calling: session->close().wait()\n";
    session->close().wait();
    cout << "trigger ~wamp_session for " << session->unique_id() << "\n";
    session.reset();
    cout << "exiting scope (will trigger kernel, io_loop, ev_loop destruction)...\n";

  }

  // ensure callback was invoked
  assert(callback_status == e_close_callback_with_sp);

  cout << "test success\n";
}


int main(int argc, char** argv)
{
  try
  {
    int starting_port_number = 21000;

    if (argc>1)
      starting_port_number = atoi(argv[1]);

    // share a common internal_server
    for (int i = 0; i < 50; i++)
{'fraction_non_alphanumeric': 0.16131025957972805, 'fraction_numerical': 0.011742892459826947, 'mean_word_length': 3.0111524163568775, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6190927', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1031, 'n_words': 249}