• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2019 Huawei Technologies Co., Ltd
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ============================================================================
16
17# source the globals and functions for use with cache testing
18export SKIP_ADMIN_COUNTER=true
19declare session_id failed_tests
20. cachetest_lib.sh
21echo
22
23################################################################################
24# Cache testing: cache cpp test driver                                         #
25# Summary: A launcher for invoking cpp cache tests                             #
26################################################################################
27
28UT_TEST_DIR="${BUILD_PATH}/mindspore/tests/ut/cpp"
29DateStamp=$(date +%Y%m%d_%H%M%S);
30CPP_TEST_LOG_OUTPUT="/tmp/ut_tests_cache_${DateStamp}.log"
31
32## prepare data for dataset & mindrecord
33cp -fr ${PROJECT_PATH}/tests/ut/data ${UT_TEST_DIR}
34## prepare album dataset, uses absolute path so has to be generated
35python ${UT_TEST_DIR}/data/dataset/testAlbum/gen_json.py
36
37# start cache server with a spilling path to be used for all tests
38cmd="${CACHE_ADMIN} --start -s /tmp"
39CacheAdminCmd "${cmd}" 0
40sleep 1
41HandleRcExit $? 1 1
42
43# Set the environment variable to enable these pytests
44export RUN_CACHE_TEST=TRUE
45GTEST_FILTER_OLD=$GTEST_FILTER
46export GTEST_FILTER="MindDataTestCacheOp.*"
47export GTEST_ALSO_RUN_DISABLED_TESTS=1
48
49# All of the cpp tests run under the same session
50GetSession
51HandleRcExit $? 1 1
52export SESSION_ID=$session_id
53
54test_count=$(($test_count+1))
55cd ${UT_TEST_DIR} || exit
56cmd="${UT_TEST_DIR}/ut_tests"
57echo "Test ${test_count}: ${cmd}"
58MsgEnter "Run test ${test_count}"
59${cmd} > ${CPP_TEST_LOG_OUTPUT} 2>&1
60rc=$?
61if [ ${rc} -ne 0 ]; then
62   MsgFail "FAILED"
63   MsgError "Invoking cpp tests failed!" "${rc}" "See log: ${CPP_TEST_LOG_OUTPUT}"
64else
65   MsgOk "OK"
66fi
67echo
68HandleRcExit $rc 1 0
69
70cd ${CURRPATH} || exit
71
72StopServer
73HandleRcExit $? 1 0
74
75# restore old env var
76export GTEST_FILTER=$GTEST_FILTER_OLD
77unset RUN_CACHE_TEST
78unset GTEST_ALSO_RUN_DISABLED_TESTS
79
80exit ${failed_tests}
81