aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStefan Hoffmann <stefan991@gmail.com>2014-04-04 19:53:43 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-05 20:19:38 -0300
commita8013f2bb1b7e62c273f7a7da58653aa82e9c5ca (patch)
tree11807ea29c41ed7b6ed2769185e5283969e7fe8b /test
parentf545afaed0304838881930c6a5944f2c6523322e (diff)
downloadrneovim-a8013f2bb1b7e62c273f7a7da58653aa82e9c5ca.tar.gz
rneovim-a8013f2bb1b7e62c273f7a7da58653aa82e9c5ca.tar.bz2
rneovim-a8013f2bb1b7e62c273f7a7da58653aa82e9c5ca.zip
Moved mch_get_pid and renamed it to os_get_pid
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)
+