void bfelf_loader_ut::test_bfelf_file_num_segments_success() { bfelf_file_t ef; auto test = get_test(); bfelf_file_init((char *)&test, sizeof(test), &ef); auto ret = bfelf_file_num_segments(&ef); EXPECT_TRUE(ret > 0); }
void bfelf_loader_ut::test_bfelf_file_get_segment_invalid_phdr() { auto ret = 0LL; bfelf_file_t ef; auto test = get_test(); ret = bfelf_file_init(reinterpret_cast<char *>(&test), sizeof(test), &ef); this->expect_true(ret == BFELF_SUCCESS); ret = bfelf_file_get_segment(&ef, 0, nullptr); this->expect_true(ret == BFELF_ERROR_INVALID_ARG); }
int main(int argc , char ** argv) { create_test(); get_test(); set_test(); load_empty_test(); test_equal(); test_copy(); test_io(); test_update_undefined( ); test_select_matching(); test_count_matching(); exit(0); }
void bfelf_loader_ut::test_bfelf_file_get_segment_success() { auto ret = 0LL; bfelf_file_t ef; bfelf_phdr *phdr = nullptr; auto test = get_test(); ret = bfelf_file_init(reinterpret_cast<char *>(&test), sizeof(test), &ef); this->expect_true(ret == BFELF_SUCCESS); ret = bfelf_file_get_segment(&ef, 0, &phdr); this->expect_true(ret == BFELF_SUCCESS); }
void cos_init(void) { static int first = 0; union sched_param sp; int i; if(first == 0){ first = 1; for (i=0; i<PAGE_NUM; i++) s_addr[i] = 0; for (i=0; i<PAGE_NUM; i++) d_addr[i] = 0; sp.c.type = SCHEDP_PRIO; sp.c.value = THREAD1; sched_create_thd(cos_spd_id(), sp.v, 0, 0); } else { timed_event_block(cos_spd_id(), 50); periodic_wake_create(cos_spd_id(), 1); i = 0; while(i++ < 80) { /* 80 x 10 x 4k < 4M */ printc("<<< MM RECOVERY TEST START (thd %d) >>>\n", cos_get_thd_id()); get_test(); #ifdef BEST_TEST alias_test(); revoke_test(); #endif /* all_in_one(); */ printc("<<< MM RECOVERY TEST DONE!! >>> {%d}\n\n\n", i); periodic_wake_wait(cos_spd_id()); } } return; }
int main(int argc, char *argv[]) { if (argc < 4) { return 1; } long processNum = atoi(argv[4]); long threadNum = atoi(argv[3]); long dtime = atol(argv[2]) * 1000; char* testName = argv[1]; long cycles = 0; Task task = get_test(testName, doneTask); int pipefd[2]; // open pipe if (pipe(pipefd) == -1) { perror("pipe"); exit(EXIT_FAILURE); } for (long i = 0; i < processNum; ++i) { if (fork() != 0) { continue; } // close unused read end close(pipefd[0]); pthread_mutexattr_t test4_mutexattr; pthread_mutex_init(&test4_mutex, &test4_mutexattr); pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN * 8); pthread_mutexattr_t mutexattr; pthread_mutex_init(&mutex, &mutexattr); pthread_condattr_t condattr; pthread_cond_init(&cond, &condattr); int rc = 0; pthread_t pid; if ((rc = pthread_mutex_lock(&mutex)) != 0) { std::cout << "pthread_mutex_lock " << rc << " " << strerror(rc) << std::endl; return 3; } time_start(); bool working = true; while ((working = (time_stop() < dtime)) || workingNum) { for (long i = workingNum; i < threadNum; ++i) { if ((rc = pthread_create(&pid, &attr, task, NULL)) != 0) { std::cout << "pthread_create " << rc << " " << strerror(rc) << std::endl; return 2; } ++workingNum; } if (workingNum == threadNum) { if ((rc = pthread_cond_wait(&cond, &mutex)) != 0) { std::cout << "pthread_cond_wait " << rc << " " << strerror(rc) << std::endl; return 3; } } //pthread_join(pids.front(), NULL); //pids.pop_front(); cycles += threadNum - workingNum; if (!working) { threadNum = workingNum; } while (!terminated_pids.empty()) { pthread_detach(terminated_pids.front()); terminated_pids.pop_front(); } } //cycles += workingNum; if ((rc = pthread_mutex_unlock(&mutex)) != 0) { std::cout << "pthread_mutex_unlock " << rc << " " << strerror(rc) << std::endl; return 3; } write(pipefd[1], &cycles, sizeof(cycles)); close(pipefd[1]); return 0; } // close unused write end close(pipefd[1]); long double result = 0; while (read(pipefd[0], &cycles, sizeof(cycles)) > 0) { result += cycles; } close(pipefd[0]); std::cout << ((long double) result * 1000) / dtime << std::endl; return 0; }
int main() { int repeat = 500; int size = (1 << 16) / 3; tellmeall(); printf("bitset container benchmarks\n"); bitset_container_t* B = bitset_container_create(); BEST_TIME(set_test(B), 0, repeat, size); int answer = get_test(B); size = 1 << 16; BEST_TIME(get_test(B), answer, repeat, size); BEST_TIME(bitset_container_cardinality(B), answer, repeat, 1); BEST_TIME(bitset_container_compute_cardinality(B), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); size = (1 << 16) / 3; BEST_TIME(unset_test(B), 0, repeat, size); bitset_container_free(B); for (int howmany = 4096; howmany <= (1 << 16); howmany *= 2) { bitset_container_t* Bt = bitset_container_create(); while (bitset_container_cardinality(Bt) < howmany) { bitset_container_set(Bt, (uint16_t)pcg32_random()); } size_t nbrtestvalues = 1024; uint16_t* testvalues = malloc(nbrtestvalues * sizeof(uint16_t)); printf("\n number of values in container = %d\n", bitset_container_cardinality(Bt)); int card = bitset_container_cardinality(Bt); uint32_t* out = malloc(sizeof(uint32_t) * (unsigned)card + 32); BEST_TIME(bitset_container_to_uint32_array(out, Bt, 1234), card, repeat, card); free(out); BEST_TIME_PRE_ARRAY(Bt, bitset_container_get, bitset_cache_prefetch, testvalues, nbrtestvalues); BEST_TIME_PRE_ARRAY(Bt, bitset_container_get, bitset_cache_flush, testvalues, nbrtestvalues); free(testvalues); bitset_container_free(Bt); } printf("\n"); bitset_container_t* B1 = bitset_container_create(); for (int x = 0; x < 1 << 16; x += 3) { bitset_container_set(B1, (uint16_t)x); } bitset_container_t* B2 = bitset_container_create(); for (int x = 0; x < 1 << 16; x += 5) { bitset_container_set(B2, (uint16_t)x); } bitset_container_t* BO = bitset_container_create(); BEST_TIME(bitset_container_or_nocard(B1, B2, BO), -1, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); answer = bitset_container_compute_cardinality(BO); BEST_TIME(bitset_container_or(B1, B2, BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); BEST_TIME(bitset_container_cardinality(BO), answer, repeat, 1); BEST_TIME(bitset_container_compute_cardinality(BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); BEST_TIME(bitset_container_and_nocard(B1, B2, BO), -1, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); answer = bitset_container_compute_cardinality(BO); BEST_TIME(bitset_container_and(B1, B2, BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); BEST_TIME(bitset_container_cardinality(BO), answer, repeat, 1); BEST_TIME(bitset_container_compute_cardinality(BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); // next we are going to benchmark conversion from bitset to array (an // important step) bitset_container_clear(B1); for (int k = 0; k < 4096; ++k) { bitset_container_set(B1, (uint16_t)ranged_random(1 << 16)); } answer = get_cardinality_through_conversion_to_array(B1); BEST_TIME(get_cardinality_through_conversion_to_array(B1), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); bitset_container_free(BO); bitset_container_free(B1); bitset_container_free(B2); return 0; }
static enum test_result gatq_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) { union request { protocol_binary_request_gat gat; char buffer[512]; }; ENGINE_ERROR_CODE ret; item *item = NULL; void *key = "get_test_key"; size_t keylen = strlen(key); union request r; memset(r.buffer, 0, sizeof(r)); r.gat.message.header.request.magic = PROTOCOL_BINARY_REQ; r.gat.message.header.request.opcode = PROTOCOL_BINARY_CMD_GATQ; r.gat.message.header.request.keylen = htons((uint16_t)keylen); r.gat.message.header.request.extlen = 4; r.gat.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES; r.gat.message.header.request.vbucket = 0; r.gat.message.header.request.bodylen = htonl((uint32_t)keylen + 4); r.gat.message.header.request.opaque = 0xdeadbeef; r.gat.message.header.request.cas = 0; r.gat.message.body.expiration = htonl(10); memcpy(r.buffer + sizeof(r.gat.bytes), key, keylen); ret = h1->unknown_command(h, NULL, &r.gat.message.header, response_handler); cb_assert(ret == ENGINE_SUCCESS); /* GATQ is quiet and should not produce any result */ cb_assert(last_response == NULL); /* store and get a key */ cb_assert(get_test(h, h1) == SUCCESS); /* Set expiry time to 10 secs.. */ ret = h1->unknown_command(h, NULL, &r.gat.message.header, response_handler); cb_assert(ret == ENGINE_SUCCESS); cb_assert(last_response != NULL); cb_assert(ntohs(last_response->response.status) == PROTOCOL_BINARY_RESPONSE_SUCCESS); cb_assert(last_response->response.keylen == 0); cb_assert(last_response->response.extlen == 4); cb_assert(ntohl(last_response->response.bodylen) == 5); /* get_test sets 1 byte datalen */ release_last_response(); /* time-travel 11 secs.. */ test_harness.time_travel(11); /* The item should have expired now... */ cb_assert(h1->get(h, NULL, &item, key, (int)keylen, 0) == ENGINE_KEY_ENOENT); /* Verify that it doesn't accept bogus packets. extlen is mandatory */ r.gat.message.header.request.extlen = 0; r.gat.message.header.request.bodylen = htonl((uint32_t)keylen); ret = h1->unknown_command(h, NULL, &r.gat.message.header, response_handler); cb_assert(ret == ENGINE_SUCCESS); cb_assert(last_response != NULL); cb_assert(ntohs(last_response->response.status) == PROTOCOL_BINARY_RESPONSE_EINVAL); release_last_response(); /* key is mandatory! */ r.gat.message.header.request.extlen = 4; r.gat.message.header.request.keylen = 0; r.gat.message.header.request.bodylen = htonl(4); ret = h1->unknown_command(h, NULL, &r.gat.message.header, response_handler); cb_assert(ret == ENGINE_SUCCESS); cb_assert(last_response != NULL); cb_assert(ntohs(last_response->response.status) == PROTOCOL_BINARY_RESPONSE_EINVAL); release_last_response(); return SUCCESS; }
} }; memcpy(r.buffer + sizeof(r.touch.bytes), key, keylen); ENGINE_ERROR_CODE ret; ret = h1->unknown_command(h, NULL, &r.touch.message.header, response_handler); assert(ret == ENGINE_SUCCESS); assert(last_response != NULL); assert(ntohs(last_response->response.status) == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); assert(last_response->response.keylen == 0); assert(last_response->response.extlen == 0); assert(last_response->response.bodylen == 0); release_last_response(); // store and get a key assert(get_test(h, h1) == SUCCESS); // Set expiry time to 10 secs.. ret = h1->unknown_command(h, NULL, &r.touch.message.header, response_handler); assert(ret == ENGINE_SUCCESS); assert(last_response != NULL); assert(ntohs(last_response->response.status) == PROTOCOL_BINARY_RESPONSE_SUCCESS); assert(last_response->response.keylen == 0); assert(last_response->response.extlen == 0); assert(last_response->response.bodylen == 0); release_last_response(); // time-travel 11 secs.. test_harness.time_travel(11); // The item should have expired now...
void symex_parse_optionst::report_cover( const path_searcht::property_mapt &property_map) { // report unsigned goals_covered=0; for(const auto &prop_pair : property_map) if(prop_pair.second.is_failure()) goals_covered++; switch(get_ui()) { case ui_message_handlert::uit::PLAIN: { status() << "\n** coverage results:" << eom; for(const auto &prop_pair : property_map) { const auto &property=prop_pair.second; status() << "[" << prop_pair.first << "]"; if(property.source_location.is_not_nil()) status() << ' ' << property.source_location; if(!property.description.empty()) status() << ' ' << property.description; status() << ": " << (property.is_failure()?"SATISFIED":"FAILED") << eom; } status() << '\n'; break; } case ui_message_handlert::uit::XML_UI: { for(const auto &prop_pair : property_map) { const auto &property=prop_pair.second; xmlt xml_result("result"); xml_result.set_attribute("goal", id2string(prop_pair.first)); xml_result.set_attribute( "description", id2string(property.description)); xml_result.set_attribute( "status", property.is_failure()?"SATISFIED":"FAILED"); if(property.source_location.is_not_nil()) xml_result.new_element()=xml(property.source_location); if(property.is_failure()) { const namespacet ns(goto_model.symbol_table); if(cmdline.isset("trace")) { convert(ns, property.error_trace, xml_result.new_element()); } else { xmlt &xml_test=xml_result.new_element("test"); for(const auto &step : property.error_trace.steps) { if(step.is_input()) { xmlt &xml_input=xml_test.new_element("input"); xml_input.set_attribute("id", id2string(step.io_id)); if(step.io_args.size()==1) xml_input.new_element("value")= xml(step.io_args.front(), ns); } } } } std::cout << xml_result << "\n"; } break; } case ui_message_handlert::uit::JSON_UI: { json_objectt json_result; json_arrayt &result_array=json_result["results"].make_array(); for(const auto &prop_pair : property_map) { const auto &property=prop_pair.second; json_objectt &result=result_array.push_back().make_object(); result["status"]= json_stringt(property.is_failure()?"satisfied":"failed"); result["goal"]=json_stringt(id2string(prop_pair.first)); result["description"]=json_stringt(id2string(property.description)); if(property.source_location.is_not_nil()) result["sourceLocation"]=json(property.source_location); if(property.is_failure()) { const namespacet ns(goto_model.symbol_table); if(cmdline.isset("trace")) { jsont &json_trace=result["trace"]; convert(ns, property.error_trace, json_trace); } else { json_arrayt &json_test=result["test"].make_array(); for(const auto &step : property.error_trace.steps) { if(step.is_input()) { json_objectt json_input; json_input["id"]=json_stringt(id2string(step.io_id)); if(step.io_args.size()==1) json_input["value"]=json(step.io_args.front(), ns); json_test.push_back(json_input); } } } } } json_result["totalGoals"]= json_numbert(std::to_string(property_map.size())); json_result["goalsCovered"]=json_numbert(std::to_string(goals_covered)); std::cout << ",\n" << json_result; break; } } status() << "** " << goals_covered << " of " << property_map.size() << " covered (" << std::fixed << std::setw(1) << std::setprecision(1) << (property_map.empty()? 100.0:100.0*goals_covered/property_map.size()) << "%)" << eom; if(get_ui()==ui_message_handlert::uit::PLAIN) { std::set<std::string> tests; for(const auto &prop_pair : property_map) if(prop_pair.second.is_failure()) tests.insert(get_test(prop_pair.second.error_trace)); std::cout << "Test suite:" << '\n'; for(const auto &t : tests) std::cout << t << '\n'; } }
int main(int argc, char *argv[]) { if (argc < 4) { return 1; } long processNum = atoi(argv[4]); long threadNum = atoi(argv[3]); long dtime = atol(argv[2]) * 1000; char* testName = argv[1]; long cycles = 0; Task task = get_test(testName, doneTask); int pipefd[2]; // open pipe if (pipe(pipefd) == -1) { perror("pipe"); exit(EXIT_FAILURE); } for (long i = 0; i < processNum; ++i) { if (fork() != 0) { continue; } // close unused read end close(pipefd[0]); st_init(); int rc = 0; st_thread_t pid; time_start(); while (time_stop() < dtime) { for (long i = workingNum; i < threadNum; ++i) { if ((pid = st_thread_create(task, NULL, false, PTHREAD_STACK_MIN * 8)) == NULL) { std::cout << "st_thread_create " << rc << " " << strerror(rc) << std::endl; return 2; } ++workingNum; } if (workingNum == threadNum) { if ((rc = st_cond_wait(cond)) != 0) { std::cout << "st_cond_wait " << rc << " " << strerror(rc) << std::endl; return 3; } } //pthread_join(pids.front(), NULL); //pids.pop_front(); cycles += threadNum - workingNum; } //cycles += workingNum; write(pipefd[1], &cycles, sizeof(cycles)); close(pipefd[1]); return 0; } // close unused write end close(pipefd[1]); long double result = 0; while (read(pipefd[0], &cycles, sizeof(cycles)) > 0) { result += cycles; } close(pipefd[0]); std::cout << ((long double) result * 1000) / dtime << std::endl; return 0; }