summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-29 00:49:07 +0800
committerruki <[email protected]>2022-07-29 00:49:07 +0800
commit50af6707efc8f4831d790005cdddad4278f3a37d (patch)
treedf209654f13b65ef076a822dde7d6d5b8a009b9f
parent07ef7c8da6a58bd22a4cd8dc3c80f915771c02e2 (diff)
add cpuinfo/meminfo tests
-rw-r--r--tests/modules/os/cpuinfo.lua7
-rw-r--r--tests/modules/os/meminfo.lua6
-rw-r--r--xmake/core/base/cpu.lua6
-rw-r--r--xmake/core/base/memory.lua6
4 files changed, 23 insertions, 2 deletions
diff --git a/tests/modules/os/cpuinfo.lua b/tests/modules/os/cpuinfo.lua
new file mode 100644
index 000000000..1f0180739
--- /dev/null
+++ b/tests/modules/os/cpuinfo.lua
@@ -0,0 +1,7 @@
+function main()
+ print(os.cpuinfo())
+ while true do
+ print(os.time(), os.cpuinfo("usagerate"))
+ os.sleep(1000)
+ end
+end
diff --git a/tests/modules/os/meminfo.lua b/tests/modules/os/meminfo.lua
new file mode 100644
index 000000000..68a245cda
--- /dev/null
+++ b/tests/modules/os/meminfo.lua
@@ -0,0 +1,6 @@
+function main()
+ while true do
+ print(os.time(), os.meminfo())
+ os.sleep(1000)
+ end
+end
diff --git a/xmake/core/base/cpu.lua b/xmake/core/base/cpu.lua
index 0b452161b..35bb97332 100644
--- a/xmake/core/base/cpu.lua
+++ b/xmake/core/base/cpu.lua
@@ -335,7 +335,11 @@ function cpu.info(name)
cpuinfo.features = cpu.features()
cpuinfo.usagerate = cpu.usagerate()
cpuinfo.model_name = cpu.model_name()
- return name and cpuinfo[name] or cpuinfo
+ if name then
+ return cpuinfo[name]
+ else
+ return cpuinfo
+ end
end
-- return module
diff --git a/xmake/core/base/memory.lua b/xmake/core/base/memory.lua
index 3bd00813d..ca90646f4 100644
--- a/xmake/core/base/memory.lua
+++ b/xmake/core/base/memory.lua
@@ -36,7 +36,11 @@ function memory.info(name)
memory._MEMINFO = meminfo
memory._MEMTIME = os.time()
end
- return name and meminfo[name] or meminfo
+ if name then
+ return meminfo[name]
+ else
+ return meminfo
+ end
end
-- return module