// The goal of this is to test a real web request, rather than simply evaling // snippets of code like the other tests. A single web request is issued and // debugged by multiple other requests. bool TestDebugger::TestWebRequest() { bool ret = false; // If we can't get sandbox host format right, fail early string sandboxHost = getSandboxHostFormat(); if (sandboxHost.empty()) { return CountSkip(); } // A quick sanity check to ensure the server is still up and accepting // requests. string result; if (!getResponse("hello.php", result, -1, sandboxHost) || result != "Hello, World!") { printf("Sanity check didn't pass on sandbox host %s, skip test\n", sandboxHost.c_str()); return CountSkip(); } // We need to wait at various times during the test for a request to progress // to a certian point, at which time we can take further action. This is done // via this pipe. m_fname = "/tmp/hphpd_test_fifo." + boost::lexical_cast<string>(Process::GetProcessId()); if (mkfifo(m_fname.c_str(), 0666)) { printf("Can not make fifo %s, skip test\n", m_fname.c_str()); return CountSkip(); } m_tempResult = false; // Kick off a thread to make requests for the debugger portions of this test. AsyncFunc<TestDebugger> func(this, &TestDebugger::testWebRequestHelperPhase1); func.start(); char flag; // Wait for web_request_phase_1.php, the first debugger portion of the test, // to connect and get ready to debug. if (!recvFromTests(flag) || flag != '1') { printf("failed to receive from test\n"); } else { // Now get web_request_t.php running so that web_requests.php // can debug it. Wait here for the entire request to finish. if (!getResponse("web_request_t.php", result, -1, sandboxHost) || result != "request done") { printf("failed on web_request_t.php\n"); } else { ret = true; } } func.waitForEnd(); unlink(m_fname.c_str()); // testWebRequestHelperPhase1() should flag m_tempResult to true if succeed ret = ret && m_tempResult; return Count(ret); }
bool TestDebugger::TestWebRequest() { bool ret = false; // If we can't get sandbox host format right, fail early string sandboxHost = getSandboxHostFormat(); if (sandboxHost.empty()) { return CountSkip(); } string result; if (!getResponse("hello.php", result, -1, sandboxHost) || result != "Hello, World!") { printf("Sanity check didn't pass on sandbox host %s, skip test\n", sandboxHost.c_str()); return CountSkip(); } m_fname = "/tmp/hphpd_test_fifo." + boost::lexical_cast<string>(Process::GetProcessId()); if (mkfifo(m_fname.c_str(), 0666)) { printf("Can not make fifo %s, skip test\n", m_fname.c_str()); return CountSkip(); } m_tempResult = false; AsyncFunc<TestDebugger> func(this, &TestDebugger::testWebRequestHelper); func.start(); char flag; // wait for "web_request.php" to connect and wait if (!recvFromTests(flag) || flag != '1') { printf("failed to receive from test\n"); } else if (!getResponse("web_request_t.php", result, -1, sandboxHost) || result != "request done") { printf("failed on web_request_t.php\n"); } else { ret = true; } func.waitForEnd(); unlink(m_fname.c_str()); // testWebRequestHelper() should flag m_tempResult to true if succeed ret = ret && m_tempResult; return Count(ret); }
bool TestExtMysql::test_mysql_db_name() { Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD); Variant dbs = f_mysql_list_dbs(); if (f_mysql_db_name(dbs, 0).toString().empty()) { return CountSkip(); } return Count(true); }
bool TestExtMysql::test_mysql_list_dbs() { Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD); Variant res = f_mysql_list_dbs(); Variant db = f_mysql_fetch_assoc(res); if (db["Database"].toString().empty()) { return CountSkip(); } return Count(true); }
bool TestExtMysql::test_mysql_list_dbs() { static const StaticString s_Database("Database"); Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD); Variant res = f_mysql_list_dbs(); Variant db = f_mysql_fetch_assoc(res); if (db.toArray()[s_Database].toString().empty()) { return CountSkip(); } return Count(true); }
bool TestExtCurl::test_curl_copy_handle() { Variant c = f_curl_init(); f_curl_setopt(c.toResource(), k_CURLOPT_URL, String(get_request_uri())); f_curl_setopt(c.toResource(), k_CURLOPT_RETURNTRANSFER, true); Variant cpy = f_curl_copy_handle(c.toResource()); f_curl_close(c.toResource()); // to test cpy is still working fine Variant res = f_curl_exec(cpy.toResource()); if (res.toString() != s_OK) { // XXX: t1782098 return CountSkip(); } return Count(true); }