summaryrefslogtreecommitdiff
path: root/tests/lib/test_frrlua.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/test_frrlua.c')
-rw-r--r--tests/lib/test_frrlua.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/lib/test_frrlua.c b/tests/lib/test_frrlua.c
index 2760a273bd..4aa8c8a8c3 100644
--- a/tests/lib/test_frrlua.c
+++ b/tests/lib/test_frrlua.c
@@ -13,6 +13,8 @@ static void test_encode_decode(void)
{
lua_State *L = luaL_newstate();
+ luaL_openlibs(L);
+
int a = 123;
int b = a;
@@ -99,6 +101,20 @@ static void test_encode_decode(void)
lua_decode_sockunion(L, -1, &su_a);
assert(sockunion_cmp(&su_a, &su_b) == 0);
assert(lua_gettop(L) == 0);
+
+ /* Test if built-in functions (string() in this case) are working */
+ const char *result;
+
+ lua_getglobal(L, "string");
+ lua_getfield(L, -1, "upper");
+ lua_pushstring(L, "testas");
+ lua_pcall(L, 1, 1, 0);
+
+ result = lua_tostring(L, -1);
+ assert(strmatch(result, "TESTAS"));
+ lua_pop(L, 1);
+ lua_close(L);
+ /* End of built-in functions test */
}
int main(int argc, char **argv)