Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/phpt/dl/482_ob.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
@ok k2_skip
@ok
<?php
ob_start();
echo "1:blah\n";
ob_start();
echo "2:blah";
echo "2:blah\n";
ob_start();
echo "3:blah\n";
ob_clean();
var_dump(ob_get_clean());
var_dump("0");
var_dump(ob_get_clean());
var_dump("0");
var_dump(ob_get_clean());
Expand Down
2 changes: 2 additions & 0 deletions tests/phpt/dl/495_sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function cmp ($a, $b) {
$to_sort[rand(0, 1000000000)] = rand(0, 1000000000);
}

shuffle ($to_sort);

asort ($to_sort);

krsort ($to_sort);
Expand Down
58 changes: 57 additions & 1 deletion tests/python/tests/diagnostic/php/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function forkable() {
return wait($f);
}

function main() {
function test_backtrace() {
foreach (json_decode(file_get_contents('php://input')) as $action) {
switch ($action["op"]) {
case "check_main_trace":
Expand Down Expand Up @@ -109,5 +109,61 @@ function main() {
}
}

function make_custom_exception() {
return err('TEST', 'London is the capital of Great Britain');
}

function check_exception(Exception $e) {
if ($e->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();

33 changes: 9 additions & 24 deletions tests/python/tests/diagnostic/test_backtrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
15 changes: 15 additions & 0 deletions tests/python/tests/diagnostic/test_err.py
Original file line number Diff line number Diff line change
@@ -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")
Loading