int heap_visitor_check_sorted(int index, void *elm, size_t elmsize, void *context) { VISITCTX * ctx = (VISITCTX *) context; HEntry *pentry = (HEntry *) elm; M_UNUSED( index ); M_UNUSED( elmsize ); if (ctx->entry) { VASSERT_RET( HEntry_compare( ctx->entry, elm, 0 ) < 0 , -1); } ctx->entry = pentry; return 0; }
pilo::i32_t functional_test_lock_and_unlock(void* param) { M_UNUSED(param); const pilo::u32_t AddTimes = 20000; const pilo::u32_t NumThreads = 4; pilo::uint_r value_to_add = 0; recursive_timed_mutex mutex; c_test_mutex_lock_and_unlock<recursive_timed_mutex> thr_test_lock[NumThreads]; for (int i = 0; i < (int) MF_COUNT_OF(thr_test_lock); i++) { thr_test_lock[i].m_value = &value_to_add; thr_test_lock[i].m_mutex = &mutex; thr_test_lock[i].m_loops = AddTimes; thr_test_lock[i].execute(MC_INVALID_SIZE); } for (int i = 0; i < (int) MF_COUNT_OF(thr_test_lock); i++) { thr_test_lock[i].wait(); } if (value_to_add != (AddTimes * NumThreads)) { return -1; } return 0; }
pilo::i32_t functional_memory_pool_mt(void* param) { M_UNUSED(param); return 0; }
pilo::i32_t functional_test_copy_operator_4(void* param) { M_UNUSED(param); pilo::core::string::fixed_astring<MC_STR0_SIZE> str0; pilo::i32_t vi32 = -12345678; str0 = vi32; pilo::i64_t vi64 = -1234567890; str0 = vi64; pilo::u32_t vu32 = 82345678; str0 = vu32; pilo::u64_t vu64 = 11234567890; str0 = vu64; float fv = -235.238f; str0 = fv; float fv2 = (float) ::atof(str0.c_str()); if (fv != fv2) { return -5; } double dv = 123.683909; str0 = dv; double dv2 = ::atof(str0.c_str()); if (dv != dv2) { return -6; } return 0; }
pilo::i32_t functional_test_constructor_3_char(void* param) { M_UNUSED(param); const char* str = "1234567890"; size_t len = pilo::core::string::string_util::length(str); pilo::core::string::fixed_astring<32> str0(str, len); pilo::core::string::fixed_astring<64> str1(str0); if (str0.size() != str1.length()) { return -1; } if (::memcmp(str0.c_str(), str1.c_str(), (len + 1)*sizeof(char)) != 0) { return -2; } const char* cstr2 = "012345678901234567890123456789"; len = pilo::core::string::string_util::length(cstr2); pilo::core::string::fixed_astring<112> str2(cstr2); pilo::core::string::fixed_astring<32> str3(str2); if (str3.size() != len) { return -3; } if (::memcmp(str3.c_str(), str2.c_str(), (len + 1) * sizeof(char)) != 0) { return -4; } return 0; }
pilo::i32_t functional_test_constructor_4_char(void* param) { M_UNUSED(param); std::string stdstr0 = "012345678901234567890123456789"; pilo::core::string::fixed_astring<31> str0(stdstr0); if (stdstr0.length() != stdstr0.length()) { return -1; } if (::memcmp(stdstr0.c_str(), str0.c_str(), str0.size()) != 0) { return -2; } std::string stdstr1 = "0123456789"; pilo::core::string::fixed_astring<11> str3 = stdstr1; if (::memcmp(str3.c_str(), "0123456789", 11) != 0) { return -9; } if (str3.length() != 10) { return -10; } return 0; }
static void webby_connection_thread( EVTHREAD *thread, struct tagEVSOCKET *socket, void *user_ctx) { WEBBY_CONNECTION_IMPL *wimpl = (WEBBY_CONNECTION_IMPL *) user_ctx; BF *bf; int rt; M_UNUSED( thread ); wimpl->socket = socket; bf = &wimpl->connection->in_buf; while( 1 ) { rt = EVSOCKET_recv( wimpl->socket, bf->get_pos, BF_put_size( bf ), 0, wimpl->io_timeout ); if (rt < 0) { goto ret; } if (rt == 0) { goto ret; } bf->put_pos = bf->get_pos + rt; if ( WEBBY_connection_data_received( wimpl->connection ) ) { goto ret; } } ret: if (wimpl->socket) { EVSOCKET_close( wimpl->socket ); } WEBBY_connection_close(wimpl->connection); free(wimpl); }
pilo::i32_t functional_test_constructor_2_char(void* param) { M_UNUSED(param); char str_buffer[MC_STR0_SIZE + 1]; pilo::core::string::string_util::set(str_buffer, '1', MC_STR0_SIZE); pilo::core::string::fixed_astring<MC_STR0_SIZE + 1> str0(str_buffer, MC_STR0_SIZE); if (str0.size() != MC_STR0_SIZE) { return -1; } if (::memcmp(str_buffer, str0.c_str(), sizeof(str_buffer) != 0)) { return -2; } pilo::core::string::fixed_astring<10> str2("1234567890", 10); if (::memcmp(str2.c_str(), "1234567890", 11) != 0) { return -9; } if (str2.length() != 10) { return -10; } return 0; }
void check_heap(void *data, size_t elsize, void *context) { HEntry *pentry = (HEntry *) data; int *num = (int *) context; M_UNUSED(elsize); VASSERT( *num < pentry->Key); *num = pentry->Key; }
pilo::i32_t functional_test_constructor_1_char(void* param) { M_UNUSED(param); char str_buffer[MC_STR0_SIZE]; pilo::core::string::string_util::m_set(str_buffer, 0, MF_COUNT_OF(str_buffer)); pilo::core::string::string_util::m_set(str_buffer, 1, MF_COUNT_OF(str_buffer) - 1); str_buffer[0] = '$'; str_buffer[MC_STR0_SIZE - 2] = '#'; pilo::core::string::fixed_astring<MC_STR0_SIZE> str0(str_buffer); if (str0.length() != 8191) { return -1; } if (str0.size() != 8191) { return -2; } if (str0.empty()) { return -4; } if (str0.front() != '$') { return -5; } if (str0.back() != '#') { return -6; } if (::memcmp(str0.c_str(), str_buffer, MC_STR0_SIZE) != 0) { return -7; } pilo::core::string::fixed_astring<MC_STR0_SIZE> str1(""); if (str1.length() != 0) { return -8; } pilo::core::string::fixed_astring<10> str2 = "1234567890"; if (::memcmp(str2.c_str(), "1234567890", 11) != 0) { return -9; } return 0; }
pilo::i32_t functional_test_copy_construct(void* param) { M_UNUSED(param); testing_pod_info info[103]; for (int i = 0; i < 103; i++) { info[i].m_id = i; } fixed_array<testing_pod_info, 133> array(info,101); if (array.size() != 101) { return -1; } fixed_array<testing_pod_info, 133> array2(array); if (array2.size() != 101) { return -20; } for (int i = 0; i < (int) array2.size(); i++) { if (array2[i].m_id != i) { return -2000 + i; } } fixed_array<testing_pod_info, 133> array3; array3 = array2; if (array3.size() != 101) { return -20; } for (int i = 0; i < (int) array3.size(); i++) { if (array3.at(i).m_id != i) { return -4000 + i; } } testing_pod_info tofindinfo(100,""); if (array3.find(tofindinfo) != 100) { return -1000; } return 0; }
pilo::i32_t functional_test_copy_operator_2(void* param) { M_UNUSED(param); pilo::core::string::fixed_astring<32> fastr; fastr = "0123456789"; if (fastr.length() != 10) { return -1; } return 0; }
int HEntry_compare(void *lh, void *rh, size_t entry) { HEntry *le = (HEntry *) lh; HEntry *re = (HEntry *) rh; M_UNUSED(entry); if (le->Key < re->Key) { return -1; } if (le->Key > re->Key) { return 1; } return 0; }
pilo::i32_t functional_test_copy_operator_1(void* param) { M_UNUSED(param); std::string stdstr0 = "0123456789"; pilo::core::string::fixed_astring<32> fastr; fastr = stdstr0; if (fastr.length() != stdstr0.length()) { return -1; } return 0; }
pilo::i32_t functional_test_assign_0(void* param) { M_UNUSED(param); pilo::core::string::fixed_astring<12> str0; pilo::core::string::fixed_astring<12> str1 = str0.assign(12, 'x'); if (str1.size() != 12) { return -1; } if (::memcmp(str1.c_str(), "xxxxxxxxxxxx", 13) != 0) { return -2; } return 0; }
pilo::i32_t functional_test_time_lock(void* param) { M_UNUSED(param); recursive_timed_mutex mutex; pilo::test::c_test_mutex_lock_only<recursive_timed_mutex>* thr_lock_only = new pilo::test::c_test_mutex_lock_only<recursive_timed_mutex>; thr_lock_only->m_mutex = &mutex; thr_lock_only->execute(); basic_thread::sleep(5); for (int i = 0; i < 100; i++) { pilo::tick64_t start = PiloGetTickCount64(); if (mutex.try_lock_for(150) != false) { mutex.unlock(); return -1; } pilo::tick64_t end = PiloGetTickCount64(); pilo::tick64_t diff = end - start; if (diff > 200 || diff < 100) { mutex.unlock(); return -2; } } time_t now = time(0); mutex.try_lock_until(now + 3); time_t cur = time(0); time_t diff = cur - now; MP_CHECK_RANGE_OC_RETURN(diff, 0, 3 + 1, -3); thr_lock_only->m_stop = 1; thr_lock_only->wait(); delete thr_lock_only; return 0; }
pilo::i32_t functional_test_assign_1(void* param) { M_UNUSED(param); std::string stdstr = "xxxxxxxxxxxx"; pilo::core::string::fixed_astring<12> str0; pilo::core::string::fixed_astring<12> str1 = str0.assign(stdstr); if (str1.size() != 12) { return -1; } if (::memcmp(str1.c_str(), stdstr.c_str(), 13) != 0) { return -2; } return 0; }
pilo::i32_t functional_test_copy_operator_3(void* param) { M_UNUSED(param); pilo::core::string::fixed_astring<32> fastr; fastr = 'x'; if (fastr.length() != 1) { return -1; } if (fastr[0] != 'x' || fastr[1] != 0) { return -2; } return 0; }
pilo::i32_t functional_test_trylock(void* param) { M_UNUSED(param); recursive_timed_mutex mutex; c_test_mutex_trylock_for_false<recursive_timed_mutex> try_thr; try_thr.m_mutex = &mutex; try_thr.m_loops = 2000; mutex.lock(); try_thr.execute(); for (int i = 0; i < 1000; i++) { basic_thread::msleep(10); if (mutex.try_lock() != true) { return -1; } } for (int i = 0; i < 1000; i++) { mutex.unlock(); } try_thr.wait(); pilo::i32_t result; if (try_thr.get_result(result) != pilo::EC_OK) { return -10; } if (result != 0) { return -20; } mutex.unlock(); return 0; }
pilo::i32_t functional_test_pod_ptr_ascend(void* param) { M_UNUSED(param); const size_t ELEM_SZ = 1024; fixed_bin_heap<pilo::test::testing_pod_info*, ELEM_SZ, ptr_gel_compare_greater<pilo::test::testing_pod_info>, ptr_gel_compare_greater<pilo::test::testing_pod_info> > bh0; if (bh0.size() != 0) { return -1; } std::vector<pilo::test::testing_pod_info> sample; for (int i = 0; i < (int) ELEM_SZ; i++) { pilo::test::testing_pod_info info(i, ""); sample.push_back(info); } std::random_shuffle(sample.begin(), sample.end()); for (int i = 0; i < (int) ELEM_SZ; i++) { pilo::test::testing_pod_info* info = new pilo::test::testing_pod_info(i, ""); bh0.push(info); } for (int i = 0; i < (int) ELEM_SZ; i++) { pilo::i32_t nbr = (*bh0.top())->m_id; if (nbr != i) { return -100000 - i; } bh0.pop(); } return 0; }
pilo::i32_t functional_test_construct(void* param) { M_UNUSED(param); fixed_array<testing_pod_info,13> array; if (array.size() != 0) { return -1; } testing_pod_info info[13]; for (int i = 0; i < 13; i++) { info[i].m_id = i; } fixed_array<testing_pod_info, 13> array1(info, 13, false); if (array1.size() != 13) { return -20; } for (int i = 0; i < (int) array1.size(); i++) { if (array1[i].m_id != i) { return -1000 + i; } } fixed_array<testing_pod_info, 12> array2(info, 13, true); if (array2.size() != 12) { return -30; } for (int i = 0; i < (int) array2.size(); i++) { if (array2[i].m_id != i) { return -2000 + i; } } return 0; }
static int webby_thread_factory (int fd, EVTHREAD_PROC *proc, void **ctx, void *factory_ctx ) { WEBBY_IMPL *wimpl = (WEBBY_IMPL *) factory_ctx; WEBBY_CONNECTION_IMPL *conn; M_UNUSED(fd); conn = ( WEBBY_CONNECTION_IMPL * ) malloc( sizeof( WEBBY_CONNECTION_IMPL ) ); if (!conn) { return -1; } conn->socket = 0; conn->connection = WEBBY_new_connection( wimpl->server, conn ); conn->io_timeout.tv_sec = wimpl->config->io_timeout; conn->io_timeout.tv_usec = 0; *ctx = (void *) conn; *proc = webby_connection_thread; return 0; }
pilo::i32_t functional_test_descend(void* param) { M_UNUSED(param); const size_t ELEM_SZ = 1024; fixed_bin_heap<pilo::i32_t, ELEM_SZ, ref_gel_compare_less<pilo::i32_t>, ref_gel_compare_less<pilo::i32_t> > bh0; if (bh0.size() != 0) { return -1; } std::vector<pilo::i32_t> sample; for (int i = 0; i < (int) ELEM_SZ; i++) { sample.push_back(i); } std::random_shuffle(sample.begin(), sample.end()); for (int i = 0; i < (int) ELEM_SZ; i++) { bh0.push(sample[i]); } for (int i = ELEM_SZ-1; i >= 0; i--) { pilo::i32_t *nbr = bh0.top(); if (*nbr != i) { return -100000 - i; } bh0.pop(); } return 0; }
pilo::i32_t functional_test_copy_operator_0(void* param) { M_UNUSED(param); const char* cstr0 = "012345678901234567890123456789"; pilo::core::string::fixed_astring<64> tstr0 = cstr0; pilo::core::string::fixed_astring<32> tstr1; tstr1 = tstr0; if (tstr1.size() != 30) { return -1; } if (::memcmp(tstr1.c_str(), cstr0, ::strlen(cstr0) + 1) != 0) { return -2; } return 0; }
pilo::i32_t functional_test_lock_and_unlock_recur(void* param) { M_UNUSED(param); const pilo::uint_r nloops = 2000; pilo::uint_r value = 0; recursive_timed_mutex mutex; c_test_mutex_lock_and_unlock_recur<recursive_timed_mutex> test_thr; test_thr.m_loops = nloops; test_thr.m_value = &value; test_thr.m_mutex = &mutex; test_thr.execute(); for (int i = 0; i < (int) nloops; i++) { for (int j = 0; j < 100; j++) { mutex.lock(); } value ++; for (int j = 0; j < 100; j++) { mutex.unlock(); } } test_thr.wait(); if (value != nloops * 2) { return -1; } return 0; }
pilo::i32_t functional_test_trylock(void* param) { M_UNUSED(param); nonrecursive_timed_mutex mutex; mutex.lock(); for (int i = 0; i < 1000; i++) { basic_thread::msleep(10); if (mutex.try_lock() != false) { mutex.unlock(); return -1; } } mutex.try_lock(); mutex.unlock(); return 0; }
pilo::i32_t functional_test_constructor_6_char(void* param) { M_UNUSED(param); float fv1 = -789.123f; pilo::core::string::fixed_astring<32> str0(fv1); float fv2 = (float) ::atof(str0.c_str()); if (fv1 != fv2) { return -1; } double dv1 = -789.123456f; pilo::core::string::fixed_astring<32> str1(dv1); double dv2 = (float) ::atof(str1.c_str()); if (dv1 != dv2) { return -1; } return 0; }
pilo::i32_t functional_test_push_pop(void* param) { M_UNUSED(param); fixed_array<testing_pod_info, 700> array; if (array.capacity() != 700) { return -1; } for (int i = 0; i < (int) (array.capacity()) + ((int) 1); i++) { testing_pod_info info(i, ""); array.push_back(info); if (array.full()) { break; } } for (pilo::i32_t i = (pilo::i32_t) array.size() - 1; i >= 0; i--) { if (array.pop_back().m_id != i) { return -1000; } } if (array.size() != 0) { return -2000; } return 0; }
pilo::i32_t functional_test_constructor_0_char(void* param) { M_UNUSED(param); pilo::core::string::fixed_astring<MC_STR0_SIZE> str0; if (str0.length() != 0) { return -1; } if (str0[0] != 0) { return -2; } if (str0.capacity() != MC_STR0_SIZE) { return -3; } if (!str0.empty()) { return -4; } return 0; }
pilo::i32_t functional_test_constructor_5_char(void* param) { M_UNUSED(param); pilo::core::string::fixed_astring<10> str0(1234567); if (str0.size() != 7) { return -1; } pilo::core::string::fixed_astring<10> str1 = 987654321; if (str1.size() != 9) { return -3; } str1 = str0; if (str1.size() != 7) { return -1; } pilo::core::string::fixed_astring<11> stri64(9876543210LL); if (stri64.size() != 10) { return -1; } pilo::u64_t u64vv= 19876543210U; pilo::core::string::fixed_astring<12> stru64(u64vv); if (stru64.size() != 11) { return -1; } return 0; }