/*
|
* =====================================================================================
|
*
|
* Filename: api_test.cpp
|
*
|
* Description:
|
*
|
* Version: 1.0
|
* Created: 2021年04月13日 14时31分46秒
|
* Revision: none
|
* Compiler: gcc
|
*
|
* Author: Li Chao (), lichao@aiotlink.com
|
* Organization:
|
*
|
* =====================================================================================
|
*/
|
#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");
|
}
|