mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-10 01:37:31 +00:00
Merge pull request #17456 from opensourcerouting/fix/lua_unit_test
Lua casting
This commit is contained in:
commit
9b50371965
@ -457,8 +457,7 @@ route_match_script(void *rule, const struct prefix *prefix, void *object)
|
|||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long *action = frrscript_get_result(fs, routematch_function,
|
int *action = frrscript_get_result(fs, routematch_function, "action", lua_tointegerp);
|
||||||
"action", lua_tointegerp);
|
|
||||||
|
|
||||||
int status = RMAP_NOMATCH;
|
int status = RMAP_NOMATCH;
|
||||||
|
|
||||||
|
@ -49,15 +49,16 @@ int main(int argc, char **argv)
|
|||||||
long long *ansptr =
|
long long *ansptr =
|
||||||
frrscript_get_result(fs, "fact", "ans", lua_tolonglongp);
|
frrscript_get_result(fs, "fact", "ans", lua_tolonglongp);
|
||||||
assert(*ansptr == 120);
|
assert(*ansptr == 120);
|
||||||
|
XFREE(MTYPE_SCRIPT_RES, ansptr);
|
||||||
|
|
||||||
/* check consecutive call + get_result without re-loading */
|
/* check consecutive call + get_result without re-loading */
|
||||||
n = 4;
|
n = 4;
|
||||||
result = frrscript_call(fs, "fact", ("n", &n));
|
result = frrscript_call(fs, "fact", ("n", &n));
|
||||||
assert(result == 0);
|
assert(result == 0);
|
||||||
ansptr = frrscript_get_result(fs, "fact", "ans", lua_tointegerp);
|
int *ansptr_c = frrscript_get_result(fs, "fact", "ans", lua_tointegerp);
|
||||||
assert(*ansptr == 24);
|
|
||||||
|
|
||||||
XFREE(MTYPE_SCRIPT_RES, ansptr);
|
assert(*ansptr_c == 24);
|
||||||
|
XFREE(MTYPE_SCRIPT_RES, ansptr_c);
|
||||||
|
|
||||||
/* Negative testing */
|
/* Negative testing */
|
||||||
|
|
||||||
@ -70,9 +71,9 @@ int main(int argc, char **argv)
|
|||||||
assert(result == 1);
|
assert(result == 1);
|
||||||
|
|
||||||
/* Get result from a function that was not loaded */
|
/* Get result from a function that was not loaded */
|
||||||
long long *llptr =
|
int *intptr = frrscript_get_result(fs, "does_not_exist", "c", lua_tointegerp);
|
||||||
frrscript_get_result(fs, "does_not_exist", "c", lua_tointegerp);
|
|
||||||
assert(llptr == NULL);
|
assert(intptr == NULL);
|
||||||
|
|
||||||
/* Function returns void */
|
/* Function returns void */
|
||||||
result = frrscript_call(fs, "bad_return1");
|
result = frrscript_call(fs, "bad_return1");
|
||||||
@ -85,9 +86,9 @@ int main(int argc, char **argv)
|
|||||||
/* Get non-existent result from a function */
|
/* Get non-existent result from a function */
|
||||||
result = frrscript_call(fs, "bad_return3");
|
result = frrscript_call(fs, "bad_return3");
|
||||||
assert(result == 1);
|
assert(result == 1);
|
||||||
long long *cllptr =
|
intptr = frrscript_get_result(fs, "bad_return3", "c", lua_tointegerp);
|
||||||
frrscript_get_result(fs, "bad_return3", "c", lua_tointegerp);
|
assert(intptr == NULL);
|
||||||
assert(cllptr == NULL);
|
XFREE(MTYPE_SCRIPT_RES, intptr);
|
||||||
|
|
||||||
/* Function throws exception */
|
/* Function throws exception */
|
||||||
result = frrscript_call(fs, "bad_return4");
|
result = frrscript_call(fs, "bad_return4");
|
||||||
|
Loading…
Reference in New Issue
Block a user