aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/os/env.moon14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/os/env.moon b/test/unit/os/env.moon
index 1f1692859b..b8405947d9 100644
--- a/test/unit/os/env.moon
+++ b/test/unit/os/env.moon
@@ -8,6 +8,7 @@ ffi.cdef [[
const char *os_getenv(const char *name);
int os_setenv(const char *name, const char *value, int override);
char *os_getenvname_at_index(size_t index);
+long os_get_pid(void);
]]
NULL = ffi.cast 'void*', 0
@@ -90,3 +91,16 @@ describe 'env function', ->
maxuint64 = ffi.new 'size_t', 18446744073709000000
eq NULL, env.os_getenvname_at_index maxuint64
+ describe 'os_get_pid', ->
+
+ it 'returns the process ID', ->
+ stat_file = io.open '/proc/self/stat'
+ if stat_file
+ stat_str = stat_file\read '*l'
+ stat_file\close!
+ pid = tonumber (stat_str\match '%d+')
+ eq pid, tonumber env.os_get_pid!
+ else
+ -- /proc is not avaliable on all systems, test if pid is nonzero.
+ eq true, (env.os_get_pid! > 0)
+