Skip to content

Commit 0883200

Browse files
committed
Merge pull request #623 from RedisAI/Change_test_module_makefile_to_cmake
Change test module makefile to cmake
1 parent bbde22f commit 0883200

File tree

7 files changed

+20
-53
lines changed

7 files changed

+20
-53
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ ENDIF()
200200
#----------------------------------------------------------------------------------------------
201201

202202
ADD_SUBDIRECTORY(src)
203+
ADD_SUBDIRECTORY(tests/module)
203204
ADD_LIBRARY(redisai SHARED $<TARGET_OBJECTS:redisai_obj>)
204205

205206
TARGET_LINK_LIBRARIES(redisai ${CMAKE_DL_LIBS})

opt/Makefile

+1
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

+1-3
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

+5-1
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
@@ -92,7 +95,6 @@ valgrind_summary() {
9295
#----------------------------------------------------------------------------------------------
9396

9497
run_tests() {
95-
make -C ../module
9698
local title="$1"
9799
[[ ! -z $title ]] && { $ROOT/opt/readies/bin/sep -0; printf "Tests with $title:\n\n"; }
98100
cd $ROOT/tests/flow
@@ -116,6 +118,8 @@ OP=""
116118

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

120124
[[ $VALGRIND == 1 || $VGD == 1 ]] && valgrind_config
121125

tests/flow/tests_llapi.py

+7-10
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/LLAPI.so")
16-
TEST_MODULE_PATH = os.path.abspath(goal_dir)
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

tests/module/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ADD_LIBRARY(testmod SHARED LLAPI.c DAG_utils.c)
2+
3+
INCLUDE_DIRECTORIES(../../src)
4+
SET_TARGET_PROPERTIES(testmod PROPERTIES PREFIX "")
5+
SET_TARGET_PROPERTIES(testmod PROPERTIES SUFFIX ".so")

tests/module/Makefile

-39
This file was deleted.

0 commit comments

Comments
 (0)