• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setup_test_environment函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

int main (void)
{
    setup_test_environment();
    void *ctx = zmq_ctx_new ();
    assert (ctx);

    const char *binds [] = { "inproc://a", "tcp://127.0.0.1:5555" };
    const char *connects [] = { "inproc://a", "tcp://localhost:5555" };

    for (int transport = 0; transport < 2; transport++) {
        bind_address = binds [transport];
        connect_address = connects [transport];

        // SHALL route outgoing messages to connected peers using a round-robin
        // strategy.
        test_round_robin_out (ctx);

        // The request and reply messages SHALL have this format on the wire:
        // * A delimiter, consisting of an empty frame, added by the REQ socket.
        // * One or more data frames, comprising the message visible to the
        //   application.
        test_req_message_format (ctx);

        // SHALL block on sending, or return a suitable error, when it has no 
        // connected peers.
        test_block_on_send_no_peers (ctx);

        // SHALL accept an incoming message only from the last peer that it sent a
        // request to.
        // SHALL discard silently any messages received from other peers.
        // PH: this test is still failing; disabled for now to allow build to
        // complete.
        // test_req_only_listens_to_current_peer (ctx);
    }

    int rc = zmq_ctx_term (ctx);
    assert (rc == 0);

    return 0 ;
}
开发者ID:cxreg,项目名称:zeromq4-x,代码行数:40,代码来源:test_spec_req.cpp


示例17: main

int main (void)
{
    setup_test_environment ();
    void *ctx = zmq_ctx_new ();
    assert (ctx);

    void *sock = zmq_socket (ctx, ZMQ_PUB);
    assert (sock);

    int rc = zmq_connect (sock, "tcp://localhost:1234");
    assert (rc == 0);

    rc = zmq_connect (sock, "tcp://[::1]:1234");
    assert (rc == 0);

    rc = zmq_connect (sock, "tcp://localhost:invalid");
    assert (rc == -1);

    rc = zmq_connect (sock, "tcp://in val id:1234");
    assert (rc == -1);

    rc = zmq_connect (sock, "tcp://");
    assert (rc == -1);

    rc = zmq_connect (sock, "tcp://192.168.0.200:*");
    assert (rc == -1);

    rc = zmq_connect (sock, "invalid://localhost:1234");
    assert (rc == -1);
    assert (errno == EPROTONOSUPPORT);

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

    rc = zmq_ctx_term (ctx);
    assert (rc == 0);

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


示例18: main

int main(void)
{
    setup_test_environment ();
    test_basic ();
    test_unsubscribe_manual ();

    const char *frontend;
    const char *backend;

#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
    frontend = "ipc://frontend";
    backend = "ipc://backend";
    test_xpub_proxy_unsubscribe_on_disconnect (frontend, backend);
    test_missing_subscriptions (frontend, backend);
#endif
    frontend = "tcp://127.0.0.1:5560";
    backend = "tcp://127.0.0.1:5561";
    test_xpub_proxy_unsubscribe_on_disconnect (frontend, backend);
    test_missing_subscriptions (frontend, backend);

    return 0;
}
开发者ID:5igm4,项目名称:libzmq,代码行数:22,代码来源:test_xpub_manual.cpp


示例19: main

int main (void)
{
    setup_test_environment();
    void *ctx = zmq_ctx_new ();
    assert (ctx);

    void *sb = zmq_socket (ctx, ZMQ_REP);
    assert (sb);
    int rc = zmq_bind (sb, "inproc://a");
    assert (rc == 0);

    rc = zmq_unbind (sb, "inproc://a");
    assert (rc == 0);

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

    rc = zmq_ctx_term (ctx);
    assert (rc == 0);

    return 0;
}
开发者ID:5igm4,项目名称:libzmq,代码行数:22,代码来源:test_unbind_inproc.cpp


示例20: main

int main (void) {
    setup_test_environment ();
    void *ctx = zmq_ctx_new ();
    assert (ctx);
    
    void *stream = zmq_socket (ctx, ZMQ_STREAM);
    assert (stream);
    void *dealer = zmq_socket (ctx, ZMQ_DEALER);
    assert (dealer);
    
    int rc = zmq_bind (stream, "tcp://127.0.0.1:5555");
    assert (rc >= 0);
    rc = zmq_connect (dealer, "tcp://127.0.0.1:5555");
    assert (rc >= 0);
    zmq_send (dealer, "", 0, 0);
    
    zmq_msg_t ident, empty;
    zmq_msg_init (&ident);
    rc = zmq_msg_recv (&ident, stream, 0);
    assert (rc >= 0);
    rc = zmq_msg_init_data (&empty, (void *) "", 0, NULL, NULL);
    assert (rc >= 0);
    
    rc = zmq_msg_send (&ident, stream, ZMQ_SNDMORE);
    assert (rc >= 0);
    rc = zmq_msg_close (&ident);
    assert (rc >= 0);
    
    rc = zmq_msg_send (&empty, stream, 0);
    assert (rc >= 0);
    
    //  This close used to fail with Bad Address
    rc = zmq_msg_close (&empty);
    assert (rc >= 0);
    
    close_zero_linger (dealer);
    close_zero_linger (stream);
    zmq_ctx_term (ctx);
}
开发者ID:GameFilebyOpenSourse,项目名称:libzmq,代码行数:39,代码来源:test_stream_empty.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setup_work_tree函数代码示例发布时间:2022-05-30
下一篇:
C++ setup_test函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap