From 7f307880a58012077833061b5ff18ba63c1a2269 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 13 四月 2021 19:04:37 +0800 Subject: [PATCH] change timestamp to steady seconds. --- utest/api_test.cpp | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/utest/api_test.cpp b/utest/api_test.cpp index 40ed2a1..113bb99 100644 --- a/utest/api_test.cpp +++ b/utest/api_test.cpp @@ -15,8 +15,40 @@ * * ===================================================================================== */ +#include "bh_api.h" #include "util.h" + +class DemoClient +{ +public: +}; BOOST_AUTO_TEST_CASE(ApiTest) { + auto max_time = std::chrono::steady_clock::time_point::max(); + auto dur = max_time.time_since_epoch(); + auto nsec = std::chrono::duration_cast<std::chrono::seconds>(dur).count(); + auto nmin = nsec / 60; + auto nhour = nmin / 60; + auto nday = nhour / 24; + auto years = nday / 365; + printf("seconds: %ld, hours: %ld , days:%ld, years: %ld\n", + nsec, nhour, nday, years); + std::chrono::steady_clock::duration a(123456); + printf("nowsec: %ld\n", NowSec()); + // for (int i = 0; i < 5; ++i) { + // std::this_thread::sleep_for(1s); + // printf("nowsec: %ld\n", NowSec()); + // } + + printf("maxsec: %ld\n", CountSeconds(max_time)); + + ProcInfo proc; + proc.set_proc_id("demo_client"); + proc.set_public_info("public info of demo_client. etc..."); + std::string proc_buf(proc.SerializeAsString()); + void *reply = 0; + int reply_len = 0; + bool r = BHRegister(proc_buf.data(), proc_buf.size(), &reply, &reply_len, 1000); + printf("register %s\n", r ? "ok" : "failed"); } \ No newline at end of file -- Gitblit v1.8.0