Skip to content

Commit 30c2d48

Browse files
committed
Send the path of test module .so to tests.sh and use it in tests_llapi.py to load the module.
1 parent b404063 commit 30c2d48

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

opt/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ test: build
276276
$(SHOW)\
277277
DEVICE=$(DEVICE) \
278278
MODULE=$(realpath $(INSTALLED_TARGET)) \
279+
TESTMOD=$(realpath $(BINDIR)/tests/module/testmod.so) \
279280
CLUSTER=$(CLUSTER) \
280281
GEN=$(GEN) AOF=$(AOF) SLAVES=$(SLAVES) \
281282
VALGRIND=$(VALGRIND) \

tests/flow/includes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import paella
1616

1717
ROOT = os.environ.get("ROOT", None)
18-
if ROOT is None:
19-
sys.stderr.write("ROOT was not defined in the environment.\n")
20-
sys.exit(1)
18+
TESTMOD_PATH = os.environ.get("TESTMOD", None)
2119
MAX_ITERATIONS = 2 if os.environ.get("MAX_ITERATIONS") == None else os.environ.get("MAX_ITERATIONS")
2220
TEST_TF = os.environ.get("TEST_TF") != "0" and os.environ.get("WITH_TF") != "0"
2321
TEST_TFLITE = os.environ.get("TEST_TFLITE") != "0" and os.environ.get("WITH_TFLITE") != "0"

tests/flow/tests.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ help() {
2828
Argument variables:
2929
VERBOSE=1 Print commands
3030
IGNERR=1 Do not abort on error
31+
32+
MODULE=path Path to redisai.so
33+
TESTMOD=path Path to LLAPI module
3134
3235
DEVICE=cpu|gpu Device for testing
3336
GEN=0|1 General tests
@@ -115,6 +118,8 @@ OP=""
115118

116119
MODULE=${MODULE:-$1}
117120
[[ -z $MODULE || ! -f $MODULE ]] && { echo "Module not found at ${MODULE}. Aborting."; exit 1; }
121+
TESTMOD=${TESTMOD}
122+
echo "Test module path is ${TESTMOD}"
118123

119124
[[ $VALGRIND == 1 || $VGD == 1 ]] && valgrind_config
120125

tests/flow/tests_llapi.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@
88
python -m RLTest --test tests_llapi.py --module path/to/redisai.so
99
'''
1010

11-
12-
def ensure_test_module_loaded(f):
11+
def with_test_module(f):
1312
@wraps(f)
1413
def wrapper(env, *args, **kwargs):
15-
#goal_dir = os.path.join(os.path.dirname(__file__), "../module/testmod.so")
16-
TEST_MODULE_PATH = "{ROOT}/bin/linux-x64-release/src/tests/module/testmod.so".format(ROOT=ROOT)
1714
con = env.getConnection()
1815
modules = con.execute_command("MODULE", "LIST")
1916
if b'RAI_llapi' in [module[1] for module in modules]:
2017
return f(env, *args, **kwargs)
2118
try:
22-
ret = con.execute_command('MODULE', 'LOAD', TEST_MODULE_PATH)
19+
ret = con.execute_command('MODULE', 'LOAD', TESTMOD_PATH)
2320
env.assertEqual(ret, b'OK')
2421
except Exception as e:
2522
env.assertFalse(True)
@@ -29,15 +26,15 @@ def wrapper(env, *args, **kwargs):
2926
return wrapper
3027

3128

32-
@ensure_test_module_loaded
29+
@with_test_module
3330
def test_basic_check(env):
3431

3532
con = env.getConnection()
3633
ret = con.execute_command("RAI_llapi.basic_check")
3734
env.assertEqual(ret, b'OK')
3835

3936

40-
@ensure_test_module_loaded
37+
@with_test_module
4138
def test_model_run_async(env):
4239

4340
con = env.getConnection()
@@ -56,7 +53,7 @@ def test_model_run_async(env):
5653
env.assertEqual(ret, b'Async run success')
5754

5855

59-
@ensure_test_module_loaded
56+
@with_test_module
6057
def test_script_run_async(env):
6158

6259
con = env.getConnection()
@@ -78,7 +75,7 @@ def test_script_run_async(env):
7875
env.assertEqual(ret, b'Async run success')
7976

8077

81-
@ensure_test_module_loaded
78+
@with_test_module
8279
def test_dag_build_and_run(env):
8380
con = env.getConnection()
8481

@@ -105,7 +102,7 @@ def test_dag_build_and_run(env):
105102
env.assertEqual(ret, b'DAG run success')
106103

107104

108-
@ensure_test_module_loaded
105+
@with_test_module
109106
def test_dagrun_multidevice_resnet(env):
110107
con = env.getConnection()
111108

0 commit comments

Comments
 (0)