From e76249c813192aa082060d024b66f11d95d09b51 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Sat, 5 Apr 2014 13:51:48 +0200 Subject: Moved mch_get_host_name and renamed it to os_get_hostanme --- test/unit/os/env.moon | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/unit/os/env.moon b/test/unit/os/env.moon index b8405947d9..ad945f2206 100644 --- a/test/unit/os/env.moon +++ b/test/unit/os/env.moon @@ -9,6 +9,7 @@ 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); +void os_get_hostname(char *hostname, size_t len); ]] NULL = ffi.cast 'void*', 0 @@ -104,3 +105,13 @@ describe 'env function', -> -- /proc is not avaliable on all systems, test if pid is nonzero. eq true, (env.os_get_pid! > 0) + describe 'os_get_hostname', -> + + it 'returns the hostname', -> + handle = io.popen 'hostname' + hostname = handle\read '*l' + handle\close! + hostname_buf = cstr 255, '' + env.os_get_hostname hostname_buf, 255 + eq hostname, (ffi.string hostname_buf) + -- cgit