-
Notifications
You must be signed in to change notification settings - Fork 704
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
35 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,30 @@ | ||
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"} overrides {{save ""}}} { | ||
r module load $testmodule | ||
|
||
r function load $HELLO_PROGRAM | ||
|
||
test {Call scripting engine function: calling foo works} { | ||
set result [r fcall foo 0 134] | ||
assert_equal $result 134 | ||
} | ||
|
||
test {Call scripting engine function: calling bar works} { | ||
set result [r fcall bar 0] | ||
assert_equal $result 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 | ||
} | ||
} |