Skip to content

Change test module makefile to cmake #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ ENDIF()
#----------------------------------------------------------------------------------------------

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests/module)
ADD_LIBRARY(redisai SHARED $<TARGET_OBJECTS:redisai_obj>)

TARGET_LINK_LIBRARIES(redisai ${CMAKE_DL_LIBS})
Expand Down
1 change: 1 addition & 0 deletions opt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ test: build
$(SHOW)\
DEVICE=$(DEVICE) \
MODULE=$(realpath $(INSTALLED_TARGET)) \
TESTMOD=$(realpath $(BINDIR)/tests/module/testmod.so) \
CLUSTER=$(CLUSTER) \
GEN=$(GEN) AOF=$(AOF) SLAVES=$(SLAVES) \
VALGRIND=$(VALGRIND) \
Expand Down
4 changes: 1 addition & 3 deletions tests/flow/includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import paella

ROOT = os.environ.get("ROOT", None)
if ROOT is None:
sys.stderr.write("ROOT was not defined in the environment.\n")
sys.exit(1)
TESTMOD_PATH = os.environ.get("TESTMOD", None)
MAX_ITERATIONS = 2 if os.environ.get("MAX_ITERATIONS") == None else os.environ.get("MAX_ITERATIONS")
TEST_TF = os.environ.get("TEST_TF") != "0" and os.environ.get("WITH_TF") != "0"
TEST_TFLITE = os.environ.get("TEST_TFLITE") != "0" and os.environ.get("WITH_TFLITE") != "0"
Expand Down
6 changes: 5 additions & 1 deletion tests/flow/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ help() {
Argument variables:
VERBOSE=1 Print commands
IGNERR=1 Do not abort on error

MODULE=path Path to redisai.so
TESTMOD=path Path to LLAPI module

DEVICE=cpu|gpu Device for testing
GEN=0|1 General tests
Expand Down Expand Up @@ -92,7 +95,6 @@ valgrind_summary() {
#----------------------------------------------------------------------------------------------

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

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

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

Expand Down
17 changes: 7 additions & 10 deletions tests/flow/tests_llapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
python -m RLTest --test tests_llapi.py --module path/to/redisai.so
'''


def ensure_test_module_loaded(f):
def with_test_module(f):
@wraps(f)
def wrapper(env, *args, **kwargs):
goal_dir = os.path.join(os.path.dirname(__file__), "../module/LLAPI.so")
TEST_MODULE_PATH = os.path.abspath(goal_dir)
con = env.getConnection()
modules = con.execute_command("MODULE", "LIST")
if b'RAI_llapi' in [module[1] for module in modules]:
return f(env, *args, **kwargs)
try:
ret = con.execute_command('MODULE', 'LOAD', TEST_MODULE_PATH)
ret = con.execute_command('MODULE', 'LOAD', TESTMOD_PATH)
env.assertEqual(ret, b'OK')
except Exception as e:
env.assertFalse(True)
Expand All @@ -29,15 +26,15 @@ def wrapper(env, *args, **kwargs):
return wrapper


@ensure_test_module_loaded
@with_test_module
def test_basic_check(env):

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


@ensure_test_module_loaded
@with_test_module
def test_model_run_async(env):

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


@ensure_test_module_loaded
@with_test_module
def test_script_run_async(env):

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


@ensure_test_module_loaded
@with_test_module
def test_dag_build_and_run(env):
con = env.getConnection()

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


@ensure_test_module_loaded
@with_test_module
def test_dagrun_multidevice_resnet(env):
con = env.getConnection()

Expand Down
5 changes: 5 additions & 0 deletions tests/module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ADD_LIBRARY(testmod SHARED LLAPI.c DAG_utils.c)

INCLUDE_DIRECTORIES(../../src)
SET_TARGET_PROPERTIES(testmod PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(testmod PROPERTIES SUFFIX ".so")
39 changes: 0 additions & 39 deletions tests/module/Makefile

This file was deleted.