summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-06-25 23:32:26 +0800
committerruki <[email protected]>2025-06-25 23:32:26 +0800
commit5120c8184c55cf80d6a90cbad51f59b30de34969 (patch)
tree1269ebfccb55896b5ec75ce3ddb0e08265e8e90e
parentcbbe73cf003569ffef57578e2cdfc2edb99b0ab1 (diff)
fix ping
-rw-r--r--tests/actions/install/test.lua2
-rw-r--r--xmake/modules/net/ping.lua14
2 files changed, 13 insertions, 3 deletions
diff --git a/tests/actions/install/test.lua b/tests/actions/install/test.lua
index 1c84b9f4c..4edc90275 100644
--- a/tests/actions/install/test.lua
+++ b/tests/actions/install/test.lua
@@ -1,6 +1,6 @@
function main(t)
if is_host("windows", "linux", "macosx") and os.arch():startswith("x") then
- os.vrun("xmake -y -vD")
+ os.vrun("xmake -y")
os.vrun("xmake run app")
os.vrun("xmake install -o build/usr")
if not is_host("linux") then -- TODO, change rpath has been not supported yet on linux.
diff --git a/xmake/modules/net/ping.lua b/xmake/modules/net/ping.lua
index db66a42b0..2f019cb66 100644
--- a/xmake/modules/net/ping.lua
+++ b/xmake/modules/net/ping.lua
@@ -49,10 +49,20 @@ end
-- using curl to ping host
function _ping_via_curl(curl, host)
- local data = try { function () return os.iorunv(curl.program, {"-o", os.nuldev(), "-s", "-w", "%{time_total}", "--max-time", "1", host}) end }
+ local data, dt = try { function ()
+ local t = os.mclock()
+ local outdata = os.iorunv(curl.program, {"-o", os.nuldev(), "-s", "-w", "%{time_total}", "--max-time", "1", host})
+ t = os.mclock() - t
+ return outdata, t
+ end }
local timeval = 65535
if data then
- timeval = tonumber(data:trim()) * 1000
+ local t = tonumber(data:trim())
+ if t then
+ timeval = t * 1000
+ else
+ timeval = dt
+ end
end
return timeval
end