From 4da4f7a534451fce42ab1cd75f2bbb7346bea538 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 16 Apr 2015 16:06:48 +0100 Subject: [PATCH] elua lib: test elua_util_file_run --- src/tests/elua/elua_lib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tests/elua/elua_lib.c b/src/tests/elua/elua_lib.c index ffa99f52e6..6c8952c731 100644 --- a/src/tests/elua/elua_lib.c +++ b/src/tests/elua/elua_lib.c @@ -13,6 +13,9 @@ START_TEST(elua_api) { Elua_State *st; lua_State *lst; + char buf[] = "tmpXXXXXX"; + FILE *f; + int fd; fail_if(!elua_init()); @@ -75,6 +78,17 @@ START_TEST(elua_api) fail_if(lua_type(lst, -1) != LUA_TSTRING); lua_pop(lst, 1); + fd = mkstemp(buf); + fail_if(fd < 0); + f = fdopen(fd, "w"); + fail_if(!f); + fprintf(f, "return 5\n"); + fclose(f); + fail_if(elua_util_file_run(st, buf)); + fail_if(lua_tointeger(lst, -1) != 5); + lua_pop(lst, 1); + fail_if(remove(buf)); + /* halfassed testing here, but not possible otherwise */ fail_if(elua_util_error_report(st, "foo", 0)); lua_pushliteral(lst, "msg"); -- 2.34.1