// This function performs basic drop tests, testing a data object consisting of // two transferables. nsresult Do_Test2() { nsresult rv = NS_OK; nsresult workingrv; workingrv = Do_CheckTwoFiles(); if (NS_FAILED(workingrv)) { fail("Drag object tests failed on multiple files"); rv = NS_ERROR_UNEXPECTED; } else { passed("Successfully created a working multiple file drag object!"); } workingrv = Do_CheckTwoStrings(); if (NS_FAILED(workingrv)) { fail("Drag object tests failed on multiple strings"); rv = NS_ERROR_UNEXPECTED; } else { passed("Successfully created a working multiple string drag object!"); } workingrv = Do_CheckSetArbitraryData(true); if (NS_FAILED(workingrv)) { fail("Drag object tests failed on setting arbitrary data"); rv = NS_ERROR_UNEXPECTED; } else { passed("Successfully set arbitrary data on a drag object"); } return rv; }
// This function performs basic drop tests, testing a data object consisting // of one transferable nsresult Do_Test1() { nsresult rv = NS_OK; nsresult workingrv; workingrv = Do_CheckOneFile(); if (NS_FAILED(workingrv)) { fail("Drag object tests failed on a single file"); rv = NS_ERROR_UNEXPECTED; } else { passed("Successfully created a working file drag object!"); } workingrv = Do_CheckOneString(); if (NS_FAILED(workingrv)) { fail("Drag object tests failed on a single string"); rv = NS_ERROR_UNEXPECTED; } else { passed("Successfully created a working string drag object!"); } workingrv = Do_CheckSetArbitraryData(false); if (NS_FAILED(workingrv)) { fail("Drag object tests failed on setting arbitrary data"); rv = NS_ERROR_UNEXPECTED; } else { passed("Successfully set arbitrary data on a drag object"); } return rv; }
void TestAsyncReturnsParent::Main() { SendNoReturn()->Then(MessageLoop::current()->SerialEventTarget(), __func__, [](bool unused) { fail("resolve handler should not be called"); }, [](PromiseRejectReason aReason) { // MozPromise asserts in debug build if the // handler is not called if (aReason != PromiseRejectReason::ChannelClosed) { fail("reject with wrong reason"); } passed("reject handler called on channel close"); }); SendPing()->Then(MessageLoop::current()->SerialEventTarget(), __func__, [this](bool one) { if (one) { passed("take one argument"); } else { fail("get one argument but has wrong value"); } Close(); }, [](PromiseRejectReason aReason) { fail("sending Ping"); }); }
NS_IMETHODIMP UDPClientListener::OnPacketReceived(nsIUDPSocket* socket, nsIUDPMessage* message) { mResult = NS_OK; uint16_t port; nsCString ip; nsCOMPtr<nsINetAddr> fromAddr; message->GetFromAddr(getter_AddRefs(fromAddr)); fromAddr->GetPort(&port); fromAddr->GetAddress(ip); passed("Packet received on client from %s:%d", ip.get(), port); if (TEST_SEND_API == phase && CheckMessageContent(message, REQUEST)) { uint32_t count; const uint32_t data = RESPONSE; printf("*** Attempting to write response 0x%x to server by SendWithAddr...\n", RESPONSE); mResult = socket->SendWithAddr(fromAddr, (const uint8_t*)&data, sizeof(uint32_t), &count); if (mResult == NS_OK && count == sizeof(uint32_t)) { passed("Response written"); } else { fail("Response written"); } return NS_OK; } else if (TEST_OUTPUT_STREAM != phase || !CheckMessageContent(message, RESPONSE)) { mResult = NS_ERROR_FAILURE; } // Notify thread QuitPumpingEvents(); return NS_OK; }
NS_IMETHODIMP UDPListener::OnPacketReceived(nsIUDPServerSocket* socket, nsIUDPMessage* message) { mResult = NS_OK; uint16_t port; nsCString ip; nsCOMPtr<nsINetAddr> fromAddr; message->GetFromAddr(getter_AddRefs(fromAddr)); fromAddr->GetPort(&port); fromAddr->GetAddress(ip); passed("Packet received on server from %s:%d", ip.get(), port); nsCString data; message->GetData(data); const char* buffer = data.get(); uint32_t len = data.Length(); uint32_t input = 0; for (uint32_t i = 0; i < len; i++) { input += buffer[i] << (8 * i); } if (len != sizeof(uint32_t) || input != REQUEST) { mResult = NS_ERROR_FAILURE; fail("Request 0x%x received on server", input); } else { passed("Request 0x%x received on server", input); // Respond with same data nsCOMPtr<nsIOutputStream> outstream; message->GetOutputStream(getter_AddRefs(outstream)); uint32_t count; const uint32_t data = RESPONSE; printf("*** Attempting to write response 0x%x to client ...\n", RESPONSE); mResult = outstream->Write((const char*)&data, sizeof(uint32_t), &count); if (mResult == NS_OK && count == sizeof(uint32_t)) { passed("Response written"); } else { fail("Response written"); } } // Notify thread QuitPumpingEvents(); return NS_OK; }
/* * eventSort() * * This helps sort a list of events (a type implementation) based on how soon * each event is to occur. */ static int eventSort(EVENT *s1, EVENT *s2) { if (during(s1) && during(s2)) return s1->EvMinutes - s2->EvMinutes; if (during(s1)) return -1; if (during(s2)) return 1; if ((passed(s1) && passed(s2)) || (!passed(s1) && !passed(s2))) return s1->EvMinutes - s2->EvMinutes; return (s2->EvMinutes - s1->EvMinutes); }
static void hysteresis16(HysteresisContext *s, const uint8_t *bbsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t blinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h) { const uint16_t *bsrc = (const uint16_t *)bbsrc; const uint16_t *asrc = (const uint16_t *)aasrc; uint16_t *dst = (uint16_t *)ddst; const int t = s->threshold; int x, y; blinesize /= 2; alinesize /= 2; dlinesize /= 2; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { if ((bsrc[x + y * blinesize] > t) && (asrc[x + y * alinesize] > t) && !passed(s, x, y, w)) { int posx, posy; dst[x + y * dlinesize] = asrc[x + y * alinesize]; push(s, x, y, w); while (!is_empty(s)) { int x_min, x_max, y_min, y_max, yy, xx; pop(s, &posx, &posy); x_min = posx > 0 ? posx - 1 : 0; x_max = posx < w - 1 ? posx + 1 : posx; y_min = posy > 0 ? posy - 1 : 0; y_max = posy < h - 1 ? posy + 1 : posy; for (yy = y_min; yy <= y_max; yy++) { for (xx = x_min; xx <= x_max; xx++) { if ((asrc[xx + yy * alinesize] > t) && !passed(s, xx, yy, w)) { dst[xx + yy * dlinesize] = asrc[xx + yy * alinesize]; push(s, xx, yy, w); } } } } } } } }
void RejectedPromises::handlerAdded(v8::PromiseRejectMessage data) { // First look it up in the pending messages and fast return, it'll be covered // by processQueue(). for (auto it = m_queue.begin(); it != m_queue.end(); ++it) { if (!(*it)->isCollected() && (*it)->hasPromise(data.GetPromise())) { m_queue.remove(it); return; } } // Then look it up in the reported errors. for (size_t i = 0; i < m_reportedAsErrors.size(); ++i) { std::unique_ptr<Message>& message = m_reportedAsErrors.at(i); if (!message->isCollected() && message->hasPromise(data.GetPromise())) { message->makePromiseStrong(); Platform::current() ->currentThread() ->scheduler() ->timerTaskRunner() ->postTask(BLINK_FROM_HERE, WTF::bind(&RejectedPromises::revokeNow, RefPtr<RejectedPromises>(this), passed(std::move(message)))); m_reportedAsErrors.remove(i); return; } } }
static nsresult TestJemallocUsableSizeInAdvance() { #define K * 1024 #define M * 1024 * 1024 /* * Test every size up to a certain point, then (N-1, N, N+1) triplets for a * various sizes beyond that. */ for (size_t n = 0; n < 16 K; n++) if (!TestOne(n)) return NS_ERROR_UNEXPECTED; for (size_t n = 16 K; n < 1 M; n += 4 K) if (!TestThree(n)) return NS_ERROR_UNEXPECTED; for (size_t n = 1 M; n < 8 M; n += 128 K) if (!TestThree(n)) return NS_ERROR_UNEXPECTED; passed("malloc_good_size"); return NS_OK; }
void DataConsumerHandleTestUtil::HandleTwoPhaseReader::didGetReadable() { WebDataConsumerHandle::Result r = WebDataConsumerHandle::UnexpectedError; while (true) { const void* buffer = nullptr; size_t size; r = m_reader->beginRead(&buffer, WebDataConsumerHandle::FlagNone, &size); if (r == WebDataConsumerHandle::ShouldWait) return; if (r != WebDataConsumerHandle::Ok) break; // Read smaller than available in order to test |endRead|. size_t readSize = std::min(size, std::max(size * 2 / 3, static_cast<size_t>(1))); m_data.append(static_cast<const char*>(buffer), readSize); m_reader->endRead(readSize); } std::unique_ptr<HandleReadResult> result = wrapUnique(new HandleReadResult(r, m_data)); m_data.clear(); Platform::current()->currentThread()->getWebTaskRunner()->postTask( BLINK_FROM_HERE, WTF::bind(&HandleTwoPhaseReader::runOnFinishedReading, WTF::unretained(this), passed(std::move(result)))); m_reader = nullptr; }
int main() { float *Ad; hipMalloc((void**)&Ad, 1024); // Test the different hipLaunchParm options: hipLaunchKernel(vAdd, size_t(1024), 1, 0, 0, Ad); hipLaunchKernel(vAdd, 1024, dim3(1), 0, 0, Ad); hipLaunchKernel(vAdd, dim3(1024), 1, 0, 0, Ad); hipLaunchKernel(vAdd, dim3(1024), dim3(1), 0, 0, Ad); // Test case with hipLaunchKernel inside another macro: float e0; GPU_PRINT_TIME (hipLaunchKernel(vAdd, dim3(1024), dim3(1), 0, 0, Ad), e0, j); GPU_PRINT_TIME (WRAP(hipLaunchKernel(vAdd, dim3(1024), dim3(1), 0, 0, Ad)), e0, j); #ifdef EXTRA_PARENS_1 // Don't wrap hipLaunchKernel in extra set of parens: GPU_PRINT_TIME ((hipLaunchKernel(vAdd, dim3(1024), dim3(1), 0, 0, Ad)), e0, j); #endif MY_LAUNCH (hipLaunchKernel(vAdd, dim3(1024), dim3(1), 0, 0, Ad), true, "firstCall"); float *A; float e1; MY_LAUNCH_WITH_PAREN (hipMalloc(&A, 100), true, "launch2"); #ifdef EXTRA_PARENS_2 //MY_LAUNCH_WITH_PAREN wraps cmd in () which can cause issues. MY_LAUNCH_WITH_PAREN (hipLaunchKernel(vAdd, dim3(1024), dim3(1), 0, 0, Ad), true, "firstCall"); #endif passed(); }
int main(int argc, char *argv[]) { HipTest::parseStandardArguments(argc, argv, true); // Serial version, just call once: if (p_tests & 0x1) { printf ("\ntest 0x1 : serial createThenDestroyStreams(10) \n"); createThenDestroyStreams(10, 10); }; /*disable, this takess a while and if the next one works then no need to run serial*/ if (1 && (p_tests & 0x2)) { printf ("\ntest 0x2 : serialized multiThread_pyramid(1) \n"); multiThread_pyramid(true, 3); } if (p_tests & 0x4) { printf ("\ntest 0x4 : parallel multiThread_pyramid(1) \n"); multiThread_pyramid(false, 3); } //if (p_tests & 0x8) { // printf ("test 0x8 : multiThread_pyramid(100) \n"); // multiThread_pyramid(false, 100); // } if (p_tests & 0x10) { printf ("\ntest 0x10 : parallel multiThread_nearzero(1000) \n"); multiThread_nearzero(false, 1000); } passed(); }
void MSCalibrator::writeXMLOutput() { if (myOutput != nullptr) { updateMeanData(); const int p = passed(); // meandata will be off if vehicles are removed on the next edge instead of this one const int discrepancy = myEdgeMeanData.nVehEntered + myEdgeMeanData.nVehDeparted - myEdgeMeanData.nVehVaporized - passed(); assert(discrepancy >= 0); const std::string ds = (discrepancy > 0 ? "\" vaporizedOnNextEdge=\"" + toString(discrepancy) : ""); const double durationSeconds = STEPS2TIME(myCurrentStateInterval->end - myCurrentStateInterval->begin); (*myOutput) << " <interval begin=\"" << time2string(myCurrentStateInterval->begin) << "\" end=\"" << time2string(myCurrentStateInterval->end) << "\" id=\"" << myID << "\" nVehContrib=\"" << p << "\" removed=\"" << myRemoved << "\" inserted=\"" << myInserted << "\" cleared=\"" << myClearedInJam << "\" flow=\"" << p * 3600.0 / durationSeconds << "\" aspiredFlow=\"" << myCurrentStateInterval->q << "\" speed=\"" << myEdgeMeanData.getTravelledDistance() / myEdgeMeanData.getSamples() << "\" aspiredSpeed=\"" << myCurrentStateInterval->v << ds << //optional "\"/>\n"; } myDidSpeedAdaption = false; myInserted = 0; myRemoved = 0; myClearedInJam = 0; myHaveWarnedAboutClearingJam = false; reset(); }
// Test for CJK with DisallowLineBreaking nsresult TestCJKWithDisallowLineBreaking() { nsString test; nsString result; test.AssignLiteral("<html><body>"); for (uint32_t i = 0; i < 400; i++) { // Insert Kanji (U+5341) test.Append(0x5341); } test.AppendLiteral("</body></html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted | nsIDocumentEncoder::OutputCRLineBreak | nsIDocumentEncoder::OutputLFLineBreak | nsIDocumentEncoder::OutputFormatFlowed | nsIDocumentEncoder::OutputDisallowLineBreaking); // create result case for (uint32_t i = 0; i < 400; i++) { result.Append(0x5341); } result.AppendLiteral("\r\n"); if (!test.Equals(result)) { fail("Wrong HTML to CJK text serialization with OutputDisallowLineBreaking"); return NS_ERROR_FAILURE; } passed("HTML to CJK text serialization with OutputDisallowLineBreaking"); return NS_OK; }
// Test for ASCII with format=flowed; delsp=yes nsresult TestASCIIWithFlowedDelSp() { nsString test; nsString result; test.AssignLiteral("<html><body>" "Firefox Firefox Firefox Firefox " "Firefox Firefox Firefox Firefox " "Firefox Firefox Firefox Firefox" "</body></html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted | nsIDocumentEncoder::OutputCRLineBreak | nsIDocumentEncoder::OutputLFLineBreak | nsIDocumentEncoder::OutputFormatFlowed | nsIDocumentEncoder::OutputFormatDelSp); // create result case result.AssignLiteral("Firefox Firefox Firefox Firefox " "Firefox Firefox Firefox Firefox " "Firefox \r\nFirefox Firefox Firefox\r\n"); if (!test.Equals(result)) { fail("Wrong HTML to ASCII text serialization with format=flowed; delsp=yes"); return NS_ERROR_FAILURE; } passed("HTML to ASCII text serialization with format=flowed; delsp=yes"); return NS_OK; }
int TestMain(void) { fail_count += imc_shm_mmap(65536, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 0, 0); fail_count += imc_shm_mmap(4096, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 1, 0); fail_count += imc_shm_mmap(1, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 1, 0); fail_count += imc_shm_mmap(0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 0, 0); fail_count += imc_shm_mmap(0x30000, PROT_READ, MAP_SHARED, 0, 0, 0); fail_count += imc_shm_mmap(65536, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 0, 1); fail_count += imc_shm_mmap(0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 0, 1); fail_count += imc_shm_mmap(0x30000, PROT_READ, MAP_SHARED, 0, 0, 1); fail_count += imc_shm_mmap(0x100000, PROT_READ|PROT_WRITE, MAP_SHARED, 0, 0, 1); /* * TODO(mseaborn): This triggers a LOG_FATAL error. Enable this * when it returns a normal error from the syscall. See * http://code.google.com/p/nativeclient/issues/detail?id=724 */ /* test_map_private_is_not_supported(); */ printf("imc_shm_mmap: %d failures\n", fail_count); if (0 == fail_count) passed("imc_shm_mmap: all sizes\n"); else failed("imc_shm_mmap: some test(s) failed\n"); return fail_count; }
nsresult TestPreWrapElementForThunderbird() { // This test examines the magic pre-wrap setup that Thunderbird relies on. nsString test; test.AppendLiteral( "<html>" NS_LINEBREAK "<body style=\"white-space: pre-wrap; width: 10ch;\">" NS_LINEBREAK "<pre>" NS_LINEBREAK " first line is too long" NS_LINEBREAK " second line is even loooonger " NS_LINEBREAK "</pre>" NS_LINEBREAK "</body>" NS_LINEBREAK "</html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputWrap); // "\n\n first\nline is\ntoo long\n second\nline is\neven\nloooonger\n\n\n" if (!test.EqualsLiteral(NS_LINEBREAK NS_LINEBREAK " first" NS_LINEBREAK "line is" NS_LINEBREAK "too long" NS_LINEBREAK " second" NS_LINEBREAK "line is" NS_LINEBREAK "even" NS_LINEBREAK "loooonger" NS_LINEBREAK NS_LINEBREAK NS_LINEBREAK)) { fail("Wrong prettyprinted html to text serialization"); return NS_ERROR_FAILURE; } passed("prettyprinted HTML to text serialization test"); return NS_OK; }
nsresult TestPlainTextSerializer() { nsString test; test.AppendLiteral("<html><base>base</base><head><span>span</span></head>" "<body>body</body></html>"); ConvertBufToPlainText(test, 0); if (!test.EqualsLiteral("basespanbody")) { fail("Wrong html to text serialization"); return NS_ERROR_FAILURE; } passed("HTML to text serialization test"); nsresult rv = TestASCIIWithFlowedDelSp(); NS_ENSURE_SUCCESS(rv, rv); rv = TestCJKWithFlowedDelSp(); NS_ENSURE_SUCCESS(rv, rv); rv = TestPrettyPrintedHtml(); NS_ENSURE_SUCCESS(rv, rv); rv = TestPreElement(); NS_ENSURE_SUCCESS(rv, rv); rv = TestBlockElement(); NS_ENSURE_SUCCESS(rv, rv); rv = TestPreWrapElementForThunderbird(); NS_ENSURE_SUCCESS(rv, rv); // Add new tests here... return NS_OK; }
int main() { unsigned flag = 0; HIPCHECK(hipDeviceReset()); int deviceCount = 0; HIPCHECK(hipGetDeviceCount(&deviceCount)); for(int j=0;j<deviceCount;j++){ HIPCHECK(hipSetDevice(j)); for(int i=0;i<4;i++){ flag = 1 << i; printf ("Flag=%x\n", flag); HIPCHECK(hipSetDeviceFlags(flag)); //HIPCHECK_API(hipSetDeviceFlags(flag), hipErrorInvalidValue); } flag = 0; } passed(); }
std::vector<int> compute_subtree_size( const AdjacencyList<EdgeType> &conn, int root) const { const int n = conn.size(); std::vector<int> subtree_size(n); std::vector<bool> passed(n), gathered(n); std::stack<pii> count_stack; count_stack.push(pii(root, 0)); while(!count_stack.empty()){ const pii p = count_stack.top(); count_stack.pop(); const int u = p.first, i = p.second; if(i == 0){ passed[u] = true; count_stack.push(pii(u, 1)); for(size_t j = 0; j < conn[u].size(); ++j){ const int v = conn[u][j].to; if(passed[v]){ continue; } count_stack.push(pii(v, 0)); } }else{ int sum = 1; gathered[u] = true; for(size_t j = 0; j < conn[u].size(); ++j){ const int v = conn[u][j].to; if(!gathered[v]){ continue; } sum += subtree_size[v]; } subtree_size[u] = sum; } } return subtree_size; }
int main(int argc, char **argv) { ScopedXPCOM xpcom("TestMimeCrash"); if (xpcom.failed()) return 1; // We cannot use malloc() since this crashes depends on memory allocation. // By using mmap()/PR_MemMap(), end of buffer that is last in the page // sets LF. PRUint32 bufsize = PR_GetPageSize(); PRFileMap *fm = PR_OpenAnonFileMap(".", bufsize, PR_PROT_READWRITE); if (!fm) return 1; char *addr = (char *) PR_MemMap(fm, 0, bufsize); if (!addr) return 1; memset(addr, '\r', bufsize); nsresult rv = do_test(addr, bufsize); PR_MemUnmap(addr, bufsize); PR_CloseFileMap(fm); if (NS_FAILED(rv)) { fail("cannot use nsIMimeConverter error=%08x\n", rv); return -1; } passed("no crash"); return 0; }
bool TestSuccess(const char* hdr, bool extraTokens, uint64_t expectedMaxAge, bool expectedIncludeSubdomains, nsISiteSecurityService* sss) { nsCOMPtr<nsIURI> dummyUri; nsresult rv = NS_NewURI(getter_AddRefs(dummyUri), "https://foo.com/bar.html"); EXPECT_SUCCESS(rv, "Failed to create URI"); uint64_t maxAge = 0; bool includeSubdomains = false; rv = sss->UnsafeProcessHeader(nsISiteSecurityService::HEADER_HSTS, dummyUri, hdr, 0, &maxAge, &includeSubdomains, nullptr); EXPECT_SUCCESS(rv, "Failed to process valid header: %s", hdr); REQUIRE_EQUAL(maxAge, expectedMaxAge, "Did not correctly parse maxAge"); REQUIRE_EQUAL(includeSubdomains, expectedIncludeSubdomains, "Did not correctly parse presence/absence of includeSubdomains"); if (extraTokens) { REQUIRE_EQUAL(rv, NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA, "Extra tokens were expected when parsing, but were not encountered."); } else { REQUIRE_EQUAL(rv, NS_OK, "Unexpected tokens found during parsing."); } passed(hdr); return true; }
int main() { if (run_sincos() && run_sincospi() && run_llrint() && run_norm3d() && run_norm4d() && run_rnorm3d() && run_rnorm4d() && run_rnorm() && run_lround() && run_llround() && run_rint() && run_rhypot() && run_erfinv()) { passed(); } }
bool processing_system::check_timeout_and_reset(augs::deterministic_timeout& t) { if (passed(t)) { reset(t); return true; } return false; }
void TestBridgeMainParent::ActorDestroy(ActorDestroyReason why) { if (NormalShutdown != why) fail("unexpected destruction!"); passed("ok"); QuitParent(); }
EXPORT_C int test_results::result_code() const { return passed() ? exit_success : ( (p_assertions_failed > p_expected_failures || p_skipped ) ? exit_test_failure : exit_exception_failure ); }
Assertions::operator bool() const noexcept { if (!_inverted) { return failed() == 0; } else { return failed() > 0 || passed() == 0; } }
int main(){ float *Ad, *A; hipHostMalloc((void**)&A, size); hipMalloc((void**)&Ad, size); assert(hipSuccess == hipMemcpy(Ad, A, size, hipMemcpyHostToDevice)); assert(hipSuccess == hipMemcpy(A, Ad, size, hipMemcpyDeviceToHost)); passed(); }
/*! \brief Validates test. \param[in] Message String containing description of the test. \param[in] Result Boolean result of the test. \return Returns the \a Result of the test. */ dmz::Boolean dmz::Test::validate (const String &Message, const Boolean Result) { out.flush () << Message; if (Result) { passed (); } else { failed (); } return Result; }
int main(int argc, char *argv[]) { HipTest::parseStandardArguments(argc, argv, true); test_gl2(N); passed(); }