diff --git a/tests/phpt/dl/482_ob.php b/tests/phpt/dl/482_ob.php index c2efd9b99e..d44fb10271 100644 --- a/tests/phpt/dl/482_ob.php +++ b/tests/phpt/dl/482_ob.php @@ -1,9 +1,14 @@ -@ok k2_skip +@ok getFile() != 'index.php') + return 'expected "index.php" but "' . $e->getFile() . '" found'; + + if ($e->getLine() != 113) + return 'expected 113 but ' . $e->getLine() . ' found'; + + if ($e->getCode() != 0) + return 'expected 0 but ' . $e->getCode() . ' found'; + + if ($e->getMessage() != 'ERR_TEST: London is the capital of Great Britain') + return 'expected "ERR_TEST: London is the capital of Great Britain" but "' . $e->getMessage() . '" found'; + + return 'ok'; +} + +function test_err() { + foreach (json_decode(file_get_contents('php://input')) as $action) { + switch ($action["op"]) { + case "just_make": + $e = make_custom_exception(); + $res = check_exception($e); + echo $res; + break; + case "throw_catch": + try { + throw make_custom_exception(); + } catch (Exception $e) { + $res = check_exception($e); + } + echo $res; + break; + default: + echo "unknown operation"; + return; + } + } +} + +function main() { + switch ($_SERVER["PHP_SELF"]) { + case "/test_backtrace": + test_backtrace(); + break; + case "/test_err": + test_err(); + break; + default: + critical_error("unknown test"); + } +} + main(); diff --git a/tests/python/tests/diagnostic/test_backtrace.py b/tests/python/tests/diagnostic/test_backtrace.py index d4dda2ab49..ced6026c2c 100644 --- a/tests/python/tests/diagnostic/test_backtrace.py +++ b/tests/python/tests/diagnostic/test_backtrace.py @@ -6,35 +6,20 @@ class TestBacktrace(WebServerAutoTestCase): @classmethod def extra_kphp2cpp_options(cls): return {"KPHP_EXTRA_CXXFLAGS" : "-O0 -g"} - - def test_main_fork_trace(self): - resp = self.web_server.http_post( - json=[ - {"op": "check_main_trace"}, - ]) + + def query(self, op: str): + resp = self.web_server.http_post(uri="/test_backtrace", json=[{"op": op}]) self.assertEqual(resp.text, "ok") self.assertEqual(resp.status_code, 200) + def test_main_fork_trace(self): + self.query("check_main_trace") + def test_fork_trace(self): - resp = self.web_server.http_post( - json=[ - {"op": "check_fork_trace"}, - ]) - self.assertEqual(resp.text, "ok") - self.assertEqual(resp.status_code, 200) + self.query("check_fork_trace") def test_fork_switch_trace(self): - resp = self.web_server.http_post( - json=[ - {"op": "check_fork_switch_trace"}, - ]) - self.assertEqual(resp.text, "ok") - self.assertEqual(resp.status_code, 200) + self.query("check_fork_switch_trace") def test_nested_fork_trace(self): - resp = self.web_server.http_post( - json=[ - {"op": "check_nested_fork_trace"}, - ]) - self.assertEqual(resp.text, "ok") - self.assertEqual(resp.status_code, 200) + self.query("check_nested_fork_trace") diff --git a/tests/python/tests/diagnostic/test_err.py b/tests/python/tests/diagnostic/test_err.py new file mode 100644 index 0000000000..05a3c9ab69 --- /dev/null +++ b/tests/python/tests/diagnostic/test_err.py @@ -0,0 +1,15 @@ +import pytest +from python.lib.testcase import WebServerAutoTestCase + + +class TestErr(WebServerAutoTestCase): + def query(self, op: str): + resp = self.web_server.http_post(uri="/test_err", json=[{"op": op}]) + self.assertEqual(resp.text, "ok") + self.assertEqual(resp.status_code, 200) + + def test_just_make(self): + self.query("just_make") + + def test_throw_catch(self): + self.query("throw_catch")