-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new module API test to test the scripting engine module API
This commit adds a simple test to test the new module API that allows to implement new scripting engines as modules. Signed-off-by: Ricardo Dias <[email protected]>
- Loading branch information
Showing
5 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "../valkeymodule.h" | ||
#include "valkeymodule.h" | ||
|
||
#include <string.h> | ||
#include <ctype.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../src/modules/helloscripting.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
set testmodule [file normalize tests/modules/helloscripting.so] | ||
|
||
set HELLO_PROGRAM "#!hello name=mylib\nFUNCTION foo\nARGS 0\nRETURN\nFUNCTION bar\nCONSTI 432\nRETURN" | ||
|
||
start_server {tags {"modules"}} { | ||
r module load $testmodule | ||
|
||
r function load $HELLO_PROGRAM | ||
|
||
test {Call scripting engine function: calling foo works} { | ||
r fcall foo 0 134 | ||
} {134} | ||
|
||
test {Call scripting engine function: calling bar works} { | ||
r fcall bar 0 | ||
} {432} | ||
|
||
test {Replace function library and call functions} { | ||
set result [r function load replace "#!hello name=mylib\nFUNCTION foo\nARGS 0\nRETURN\nFUNCTION bar\nCONSTI 500\nRETURN"] | ||
assert_equal $result "mylib" | ||
|
||
set result [r fcall foo 0 132] | ||
assert_equal $result 132 | ||
|
||
set result [r fcall bar 0] | ||
assert_equal $result 500 | ||
} | ||
|
||
test {List scripting engine functions} { | ||
r function load replace "#!hello name=mylib\nFUNCTION foobar\nARGS 0\nRETURN" | ||
r function list | ||
} {{library_name mylib engine HELLO functions {{name foobar description {} flags {}}}}} | ||
|
||
test {Unload scripting engine module} { | ||
set result [r module unload helloengine] | ||
assert_equal $result "OK" | ||
} | ||
} |