#include "center.h"
|
#include "defs.h"
|
#include "log.h"
|
#include "util.h"
|
#include <atomic>
|
#include <condition_variable>
|
#include <stdio.h>
|
#include <string>
|
#include <thread>
|
#include <vector>
|
|
namespace
|
{
|
bool InitLog()
|
{
|
ns_log::AddLog("/tmp/bhshmq_test.log", true, true);
|
ns_log::ResetLogLevel(ns_log::LogLevel::debug);
|
return true;
|
}
|
static bool g_test_init_log = InitLog();
|
} // namespace
|
|
using namespace bhome_shm;
|
using namespace bhome_msg;
|
|
SharedMemory &TestShm()
|
{
|
static SharedMemory shm("utest_0", 1024 * 1024 * 512);
|
return shm;
|
}
|
|
template <class A, class B>
|
struct IsSameType {
|
static const bool value = false;
|
};
|
template <class A>
|
struct IsSameType<A, A> {
|
static const bool value = true;
|
};
|
|
BOOST_AUTO_TEST_CASE(Temp)
|
{
|
const std::string shm_name("ShmTemp");
|
ShmRemover auto_remove(shm_name); //remove twice? in case of killed?
|
SharedMemory shm(shm_name, 1024 * 1024 * 10);
|
|
typedef std::chrono::steady_clock clock;
|
int n = 1000 * 1000;
|
std::vector<clock::time_point> tps(n);
|
{
|
printf("thread switch %d times, ", n);
|
boost::timer::auto_cpu_timer timer;
|
for (auto &tp : tps) {
|
tp = clock::now();
|
std::this_thread::yield();
|
}
|
}
|
printf("time: %ld ns\n", (tps.back() - tps.front()).count());
|
}
|
|
int test_main(int argc, char *argv[])
|
{
|
printf("test main\n");
|
int a = 0;
|
int b = 0;
|
BOOST_CHECK_EQUAL(a, b);
|
|
return 0;
|
}
|