当前位置: 首页>>代码示例>>C++>>正文


C++ setup_test_environment函数代码示例

本文整理汇总了C++中setup_test_environment函数的典型用法代码示例。如果您正苦于以下问题:C++ setup_test_environment函数的具体用法?C++ setup_test_environment怎么用?C++ setup_test_environment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setup_test_environment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main (void)
{
    setup_test_environment();
    
    int count;

    // send 1000 msg on hwm 1000, receive 1000
    count = test_defaults (1000,1000);
    assert (count == 1000);

   // send 6000 msg on hwm 2000, drops above hwm, only receive hwm
    count = test_blocking (2000,6000);
    assert (count == 6000);

    return 0;
}
开发者ID:GengXuan,项目名称:my_zeromq,代码行数:16,代码来源:test_hwm_pubsub.cpp

示例2: main

int main ()
{
    setup_test_environment ();

    UNITY_BEGIN ();

    // repeat the test for both TCP, INPROC and IPC transports:

    RUN_TEST (test_tcp);
    RUN_TEST (test_inproc);
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_GNU)
    RUN_TEST (test_ipc);
#endif
    RUN_TEST (test_reset_hwm);
    return UNITY_END ();
}
开发者ID:CommanderBubble,项目名称:libzmq,代码行数:16,代码来源:test_hwm_pubsub.cpp

示例3: main

int main (void)
{
    setup_test_environment();

    // No filters
    run_test<int> (0, 0, 0, 1);

#if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
    // Get the group and supplimental groups of the process owner
    gid_t groups[100];
    int ngroups = getgroups(100, groups);
    assert (ngroups != -1);
    gid_t group = getgid(), supgroup = group, notgroup = group + 1;
    for (int i = 0; i < ngroups; i++) {
        if (supgroup == group && group != groups[i])
            supgroup = groups[i];
        if (notgroup <= groups[i])
            notgroup = groups[i] + 1;
    }

    // Test filter with UID of process owner
    run_test<uid_t> (ZMQ_IPC_FILTER_UID, getuid(), 0, 1);
    // Test filter with UID of another (possibly non-existent) user
    run_test<uid_t> (ZMQ_IPC_FILTER_UID, getuid() + 1, 0, -1);
    // Test filter with GID of process owner
    run_test<gid_t> (ZMQ_IPC_FILTER_GID, group, 0, 1);
    // Test filter with supplimental group of process owner
    run_test<gid_t> (ZMQ_IPC_FILTER_GID, supgroup, 0, 1);
    // Test filter with GID of another (possibly non-existent) group
    run_test<gid_t> (ZMQ_IPC_FILTER_GID, notgroup, 0, -1);
#   if defined ZMQ_HAVE_SO_PEERCRED
    // Test filter with PID of current process
    run_test<pid_t> (ZMQ_IPC_FILTER_PID, getpid(), 0, 1);
    // Test filter with PID of another (possibly non-existent) process
    run_test<pid_t> (ZMQ_IPC_FILTER_PID, getpid() + 1, 0, -1);
#   else
    // Setup of PID filter should fail with operation not supported error
    run_test<pid_t> (ZMQ_IPC_FILTER_PID, getpid(), EINVAL, 0);
#   endif
#else
    run_test<uid_t> (ZMQ_IPC_FILTER_UID, 0, EINVAL, 0);
    run_test<gid_t> (ZMQ_IPC_FILTER_GID, 0, EINVAL, 0);
    run_test<pid_t> (ZMQ_IPC_FILTER_PID, 0, EINVAL, 0);
#endif // defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED

    return 0 ;
}
开发者ID:HJoYer,项目名称:libzmq,代码行数:47,代码来源:test_filter_ipc.cpp

示例4: main

int main (void)
{
    setup_test_environment ();

    void *ctx = zmq_ctx_new ();
    assert (ctx);
    // client socket pings proxy over tcp
    void *req = zmq_socket (ctx, ZMQ_REQ);
    assert (req);
    int rc = zmq_connect (req, "tcp://127.0.0.1:5563");
    assert (rc == 0);

    // Control socket receives terminate command from main over inproc
    void *control = zmq_socket (ctx, ZMQ_PUB);
    assert (control);
    rc = zmq_bind (control, "inproc://control");
    assert (rc == 0);

    void *server_thread = zmq_threadstart(&server_task, ctx);

    char buf[255];
    rc = zmq_send(req, "msg1", 4, 0);
    assert (rc == 4);
    rc = zmq_recv(req, buf, 255, 0);
    assert (rc == 4);
    assert (memcmp (buf, "msg1", 4) == 0);

    rc = zmq_send(req, "msg22", 5, 0);
    assert (rc == 5);
    rc = zmq_recv(req, buf, 255, 0);
    assert (rc == 5);
    assert (memcmp (buf, "msg22", 5) == 0);

    rc = zmq_send (control, "TERMINATE", 9, 0);
    assert (rc == 9);

    rc = zmq_close (control);
    assert (rc == 0);
    rc = zmq_close (req);
    assert (rc == 0);

    zmq_threadclose (server_thread);

    rc = zmq_ctx_term (ctx);
    assert (rc == 0);
    return 0;
}
开发者ID:ALeschev,项目名称:tunel,代码行数:47,代码来源:test_proxy_single_socket.cpp

示例5: main

int main (void)
{
    setup_test_environment();
    void *s1;
    void *s2;
    int i;
    int j;
    int rc;
    void* threads [THREAD_COUNT];

    for (j = 0; j != 10; j++) {

        //  Check the shutdown with many parallel I/O threads.
        void *ctx = zmq_ctx_new ();
        assert (ctx);
        zmq_ctx_set (ctx, ZMQ_IO_THREADS, 7);

        s1 = zmq_socket (ctx, ZMQ_PUB);
        assert (s1);

        rc = zmq_bind (s1, "tcp://127.0.0.1:5560");
        assert (rc == 0);

        printf("Kicking off worker threads\n");
        for (i = 0; i != THREAD_COUNT; i++) {
            s2 = zmq_socket (ctx, ZMQ_SUB);
            assert (s2);
            threads [i] = zmq_threadstart(&worker, s2);
        }

        printf("Waiting on them to finish\n");
        for (i = 0; i != THREAD_COUNT; i++) {
            zmq_threadclose(threads [i]);
        }

        printf("Closing sockets\n");
        rc = zmq_close (s1);
        assert (rc == 0);

        printf("Releasing context\n");
        rc = zmq_ctx_term (ctx);
        assert (rc == 0);
    }

    return 0;
}
开发者ID:jimrthy,项目名称:libzmq,代码行数:46,代码来源:test_shutdown_stress.cpp

示例6: main

int main (void)
{
    setup_test_environment ();

    void *ctx = zmq_ctx_new ();
    assert (ctx);
    // Control socket receives terminate command from main over inproc
    void *control = zmq_socket (ctx, ZMQ_PUB);
    assert (control);
    int rc = zmq_bind (control, "inproc://control");
    assert (rc == 0);

    void *thread = zmq_threadstart(&server_task, ctx);
    msleep (500); // Run for 500 ms

    // Start a secondary publisher which writes data to the SUB-PUSH server socket
    void *publisher = zmq_socket (ctx, ZMQ_PUB);
    assert (publisher);
    rc = zmq_connect (publisher, "tcp://127.0.0.1:15564");
    assert (rc == 0);

    msleep (50);
    rc = zmq_send (publisher, "This is a test", 14, 0);
    assert (rc == 14);

    msleep (50);
    rc = zmq_send (publisher, "This is a test", 14, 0);
    assert (rc == 14);

    msleep (50);
    rc = zmq_send (publisher, "This is a test", 14, 0);
    assert (rc == 14);
    rc = zmq_send (control, "TERMINATE", 9, 0);
    assert (rc == 9);

    rc = zmq_close (publisher);
    assert (rc == 0);
    rc = zmq_close (control);
    assert (rc == 0);

    zmq_threadclose (thread);

    rc = zmq_ctx_term (ctx);
    assert (rc == 0);
    return 0;
}
开发者ID:AresTao,项目名称:zeromq4-x,代码行数:46,代码来源:test_proxy_terminate.cpp

示例7: main

int main (void)
{
    setup_test_environment ();

    test_bind_before_connect ();
    test_connect_before_bind ();
    test_connect_before_bind_pub_sub ();
    test_multiple_connects ();
    test_multiple_threads ();
    test_simultaneous_connect_bind_threads ();
    test_identity ();
    test_connect_only ();
    test_unbind ();
    test_shutdown_during_pend ();

    return 0;
}
开发者ID:GameFilebyOpenSourse,项目名称:libzmq,代码行数:17,代码来源:test_inproc_connect.cpp

示例8: main

int main (void)
{
    setup_test_environment();
    
    int count;

    // Default values are 1000 on send and 1000 one receive, so 2000 total
    count = test_defaults ();
    assert (count == 2000);

    // Infinite send and receive buffer
    count = test_inproc_bind_first (0, 0);
    assert (count == MAX_SENDS);
    count = test_inproc_connect_first (0, 0);
    assert (count == MAX_SENDS);

    // Infinite send buffer
    count = test_inproc_bind_first (1, 0);
    assert (count == MAX_SENDS);
    count = test_inproc_connect_first (1, 0);
    assert (count == MAX_SENDS);

    // Infinite receive buffer
    count = test_inproc_bind_first (0, 1);
    assert (count == MAX_SENDS);
    count = test_inproc_connect_first (0, 1);
    assert (count == MAX_SENDS);

    // Send and recv buffers hwm 1, so total that can be queued is 2
    count = test_inproc_bind_first (1, 1);
    assert (count == 2);
    count = test_inproc_connect_first (1, 1);
    assert (count == 2);

    // Send hwm of 1, send before bind so total that can be queued is 1
    count = test_inproc_connect_and_close_first (1, 0);
    assert (count == 1);

    // Send hwm of 1, send from bind side before connect so total that can be queued should be 1,
    // however currently all messages get thrown away before the connect.  BUG?
    count = test_inproc_bind_and_close_first (1, 0);
    //assert (count == 1);

    return 0;
}
开发者ID:0x6d686b,项目名称:libzmq,代码行数:45,代码来源:test_hwm.cpp

示例9: main

int main (void)
{
    setup_test_environment ();

    UNITY_BEGIN ();
    RUN_TEST (test_ctx_destroy);
    RUN_TEST (test_ctx_shutdown);
    RUN_TEST (test_zmq_ctx_term_null_fails);
    RUN_TEST (test_zmq_term_null_fails);
    RUN_TEST (test_zmq_ctx_shutdown_null_fails);

    RUN_TEST (
      test_poller_exists_with_socket_on_zmq_ctx_term_non_thread_safe_socket);
    RUN_TEST (
      test_poller_exists_with_socket_on_zmq_ctx_term_thread_safe_socket);

    return UNITY_END ();
}
开发者ID:somdoron,项目名称:libzmq,代码行数:18,代码来源:test_ctx_destroy.cpp

示例10: main

int main (void)
{
    setup_test_environment ();

    UNITY_BEGIN ();
    RUN_TEST (test_bind_before_connect);
    RUN_TEST (test_connect_before_bind);
    RUN_TEST (test_connect_before_bind_pub_sub);
    RUN_TEST (test_connect_before_bind_ctx_term);
    RUN_TEST (test_multiple_connects);
    RUN_TEST (test_multiple_threads);
    RUN_TEST (test_simultaneous_connect_bind_threads);
    RUN_TEST (test_routing_id);
    RUN_TEST (test_connect_only);
    RUN_TEST (test_unbind);
    RUN_TEST (test_shutdown_during_pend);
    return UNITY_END ();
}
开发者ID:dand-oss,项目名称:libzmq,代码行数:18,代码来源:test_inproc_connect.cpp

示例11: main

int main (void)
{
    setup_test_environment ();

    test_single_connect_ipv4 ();

    test_multi_connect_ipv4 ();

    test_multi_connect_ipv4_same_port ();

    test_single_connect_ipv6 ();

    test_multi_connect_ipv6 ();

    test_multi_connect_ipv6_same_port ();

    return 0 ;
}
开发者ID:Bitiquinho,项目名称:libzmq,代码行数:18,代码来源:test_reqrep_tcp.cpp

示例12: main

int main (void)
{
    setup_test_environment ();

    test_single_connect ("tcp://127.0.0.1:*");

    test_multi_connect ("tcp://127.0.0.1:*");

    test_multi_connect_same_port ("tcp://127.0.0.1:*");

    test_single_connect ("tcp://[::1]:*");

    test_multi_connect ("tcp://[::1]:*");

    test_multi_connect_same_port ("tcp://[::1]:*");

    return 0;
}
开发者ID:cuijw,项目名称:libzmq,代码行数:18,代码来源:test_reqrep_tcp.cpp

示例13: main

int main (void)
{
    UNITY_BEGIN ();

    zmq::initialize_network ();
    setup_test_environment ();

    RUN_TEST (test_create);
    RUN_TEST (test_add_fd_and_start_and_receive_data);
    RUN_TEST (test_add_fd_and_remove_by_timer);

#if defined _WIN32
    RUN_TEST (test_add_fd_with_pending_failing_connect);
#endif

    zmq::shutdown_network ();

    return UNITY_END ();
}
开发者ID:CommanderBubble,项目名称:libzmq,代码行数:19,代码来源:unittest_poller.cpp

示例14: main

int main (void)
{
    setup_test_environment();

    int count;

    // send 1000 msg on hwm 1000, receive 1000
    count = test_defaults (1000,1000);
    assert (count == 1000);

   // send 6000 msg on hwm 2000, drops above hwm, only receive hwm
    count = test_blocking (2000,6000);
    assert (count == 6000);

    // hwm should apply to the messages that have already been received
    test_reset_hwm ();

    return 0;
}
开发者ID:edigar007,项目名称:zeromq4-1,代码行数:19,代码来源:test_hwm_pubsub.cpp

示例15: main

int main (void)
{
    setup_test_environment();
    void *socket;
    int i;
    int j;
    int rc;
    void* threads [THREAD_COUNT];

    for (j = 0; j != 10; j++) {

        //  Check the shutdown with many parallel I/O threads.
        struct thread_data tdata;
        tdata.ctx = zmq_ctx_new ();
        assert (tdata.ctx);
        zmq_ctx_set (tdata.ctx, ZMQ_IO_THREADS, 7);

        socket = zmq_socket (tdata.ctx, ZMQ_PUB);
        assert (socket);

        rc = zmq_bind (socket, "tcp://127.0.0.1:*");
        assert (rc == 0);
        size_t len = MAX_SOCKET_STRING;
        rc = zmq_getsockopt (socket, ZMQ_LAST_ENDPOINT, tdata.endpoint, &len);
        assert (rc == 0);

        for (i = 0; i != THREAD_COUNT; i++) {
            threads [i] = zmq_threadstart(&worker, &tdata);
        }

        for (i = 0; i != THREAD_COUNT; i++) {
            zmq_threadclose(threads [i]);
        }

        rc = zmq_close (socket);
        assert (rc == 0);

        rc = zmq_ctx_term (tdata.ctx);
        assert (rc == 0);
    }

    return 0;
}
开发者ID:AmesianX,项目名称:libzmq,代码行数:43,代码来源:test_shutdown_stress.cpp


注:本文中的setup_test_environment函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。