Skip to content

Commit

Permalink
rename builtins in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Sadokhov committed Oct 25, 2024
1 parent 1ed5fa2 commit 821e182
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion builtin-functions/kphp-light/job-workers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function job_worker_send_noreply_request(string $request, float $timeout): bool;
/** @kphp-extern-func-info interruptible */
function job_worker_send_multi_request(string[] $request, float $timeout): (future<string> | false)[];
/** @kphp-extern-func-info interruptible */
function job_worker_fetch_response(): string;
function job_worker_fetch_request(): string;
/** @kphp-extern-func-info interruptible */
function job_worker_store_response(string $response): int;

Expand Down
6 changes: 3 additions & 3 deletions tests/k2-components/test_job_worker.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

if (isset($_SERVER["JOB_ID"])) {
$request = kphp_job_worker_fetch_request();
$request = job_worker_fetch_request();
sched_yield_sleep(0.1);
kphp_job_worker_store_response($request . ": done!");
job_worker_store_response($request . ": done!");
} else {
$job = kphp_job_worker_start("Job Request", 0.3);
$job = job_worker_send_request("Job Request", 0.3);
if (wait($job) != "Job Request: done!") {
critical_error("response not matched");
}
Expand Down
6 changes: 3 additions & 3 deletions tests/k2-components/test_job_worker_multi.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

if (isset($_SERVER["JOB_ID"])) {
$request = kphp_job_worker_fetch_request();
$request = job_worker_fetch_request();
sched_yield_sleep(0.1);
kphp_job_worker_store_response($request . ": done!");
job_worker_store_response($request . ": done!");
} else {
$job_arr = [];
for ($i = 0; $i < 20; $i++) {
$job_arr[] = "Job Request";
}
$job_ids = kphp_job_worker_start_multi($job_arr, 0.3);
$job_ids = job_worker_send_multi_request($job_arr, 0.3);
foreach ($job_ids as $id) {
if (wait($id) != "Job Request: done!") {
critical_error("response not matched");
Expand Down
6 changes: 3 additions & 3 deletions tests/k2-components/test_job_worker_noreply.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

if (isset($_SERVER["JOB_ID"])) {
$request = kphp_job_worker_fetch_request();
if (kphp_job_worker_store_response($request . ": done!") == 0) {
$request = job_worker_fetch_request();
if (job_worker_store_response($request . ": done!") == 0) {
critical_error("unexpected success on store response");
}
} else {
$job = kphp_job_worker_start_no_reply("Job Request", 0.3);
$job = job_worker_send_noreply_request("Job Request", 0.3);
sched_yield_sleep(0.1);
}
12 changes: 6 additions & 6 deletions tests/k2-components/test_rpc_memcached.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php

function do_untyped_rpc() {
$ids = rpc_tl_query("mc_main", [["_" => "memcache.get", "key" => "xxx"]]);
$response = rpc_tl_query_result($ids)[0];
$ids = rpc_send_request("mc_main", [["_" => "memcache.get", "key" => "xxx"]]);
$response = rpc_fetch_response($ids)[0];
$result = $response["result"];
if ($result["_"] !== "memcache.not_found") {
warning("memcache.not_found expected");
return false;
}

$ids = rpc_tl_query("mc_main", [["_" => "memcache.set", "key" => "foo", "flags" => 0, "delay" => 0, "value" => "bar"]]);
$response = rpc_tl_query_result($ids)[0];
$ids = rpc_send_request("mc_main", [["_" => "memcache.set", "key" => "foo", "flags" => 0, "delay" => 0, "value" => "bar"]]);
$response = rpc_fetch_response($ids)[0];
$result = $response["result"];
if ($result !== true) {
warning("true expected");
return false;
}

$ids = rpc_tl_query("mc_main", [["_" => "memcache.get", "key" => "foo"]]);
$response = rpc_tl_query_result($ids)[0];
$ids = rpc_send_request("mc_main", [["_" => "memcache.get", "key" => "foo"]]);
$response = rpc_fetch_response($ids)[0];
$result = $response["result"];
if ($result["_"] !== "memcache.strvalue" || $result["value"] !== "bar") {
warning("\"bar\" expected");
Expand Down

0 comments on commit 821e182

Please sign in to comment.