parent
28593e23c8
commit
a5b2b08035
@ -1,8 +1,8 @@
|
||||
#add flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
|
||||
|
||||
if (ENABLE_ACL)
|
||||
add_subdirectory(cxx_st)
|
||||
else ()
|
||||
if (ENABLE_TESTCASES)
|
||||
add_subdirectory(ut)
|
||||
elseif (ENABLE_CPP_ST)
|
||||
add_subdirectory(st/cpp)
|
||||
endif ()
|
||||
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "common/common_test.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ST {
|
||||
|
||||
void Common::SetUpTestCase() {}
|
||||
|
||||
void Common::TearDownTestCase() {}
|
||||
|
||||
void Common::SetUp() {}
|
||||
|
||||
void Common::TearDown() {}
|
||||
|
||||
} // namespace ST
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
BASEPATH=$(cd "$(dirname $0)"; pwd)
|
||||
PROJECT_PATH=${BASEPATH}/../..
|
||||
if [ $BUILD_PATH ];then
|
||||
echo "BUILD_PATH = $BUILD_PATH"
|
||||
else
|
||||
BUILD_PATH=${PROJECT_PATH}/build
|
||||
echo "BUILD_PATH = $BUILD_PATH"
|
||||
fi
|
||||
|
||||
cd ${BUILD_PATH}/mindspore/tests/cxx_st
|
||||
|
||||
export LD_LIBRARY_PATH=${BUILD_PATH}/mindspore/googletest/googlemock/gtest:${PROJECT_PATH}/mindspore:${PROJECT_PATH}/mindspore/lib:$LD_LIBRARY_PATH
|
||||
export PYTHONPATH=${PROJECT_PATH}/tests/ut/cpp/python_input:$PYTHONPATH:${PROJECT_PATH}
|
||||
export GLOG_v=2
|
||||
export GC_COLLECT_IN_CELL=1
|
||||
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
./st_tests --gtest_filter=$1
|
||||
else
|
||||
./st_tests
|
||||
fi
|
||||
RET=$?
|
||||
cd -
|
||||
|
||||
exit ${RET}
|
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "common/common_test.h"
|
||||
#include "include/api/context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ST {
|
||||
static std::string GetEnv(const std::string &envvar) {
|
||||
const char *value = std::getenv(envvar.c_str());
|
||||
if (value == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return std::string(value);
|
||||
}
|
||||
|
||||
void Common::SetUpTestCase() {}
|
||||
|
||||
void Common::TearDownTestCase() {}
|
||||
|
||||
void Common::SetUp() {}
|
||||
|
||||
void Common::TearDown() {}
|
||||
|
||||
void Common::ReadFile(const char *file, size_t *size, char **buf) {
|
||||
ASSERT_NE(nullptr, file);
|
||||
ASSERT_NE(nullptr, size);
|
||||
ASSERT_NE(nullptr, buf);
|
||||
std::string path = std::string(file);
|
||||
std::ifstream ifs(path);
|
||||
ASSERT_EQ(true, ifs.good());
|
||||
ASSERT_EQ(true, ifs.is_open());
|
||||
|
||||
ifs.seekg(0, std::ios::end);
|
||||
*size = ifs.tellg();
|
||||
*buf = new char[*size];
|
||||
|
||||
ifs.seekg(0, std::ios::beg);
|
||||
ifs.read(*buf, *size);
|
||||
ifs.close();
|
||||
}
|
||||
|
||||
void Common::ContextAutoSet() {
|
||||
auto device_target = GetEnv("DEVICE_TARGET");
|
||||
if (device_target.empty()) {
|
||||
device_target = mindspore::api::kDeviceTypeAscend310; // default is 310
|
||||
}
|
||||
|
||||
auto device_id_str = GetEnv("DEVICE_ID");
|
||||
if (device_id_str.empty()) {
|
||||
device_id_str = "0"; // default is 0
|
||||
}
|
||||
uint32_t device_id = std::strtoul(device_id_str.c_str(), nullptr, 10);
|
||||
|
||||
mindspore::api::Context::Instance().SetDeviceTarget(device_target).SetDeviceID(device_id);
|
||||
}
|
||||
} // namespace ST
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
BASEPATH=$(cd "$(dirname $0)"; pwd)
|
||||
PROJECT_PATH=${BASEPATH}/../../..
|
||||
|
||||
# print usage message
|
||||
usage()
|
||||
{
|
||||
echo "Usage:"
|
||||
echo "sh runtests.sh [-e ascend310|ascend910] [-n testcase_name] [-d n]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h Print usage"
|
||||
echo " -e Device target, default is ascend310"
|
||||
echo " -d Device ID, default is 0"
|
||||
echo " -n Run single tesecase, default off"
|
||||
echo "to be continued ..."
|
||||
}
|
||||
|
||||
checkopts()
|
||||
{
|
||||
DEVICE_TARGET_OPT="ascend310"
|
||||
DEVICE_ID_OPT=0
|
||||
TASECASE_NAME_OPT=""
|
||||
|
||||
# Process the options
|
||||
while getopts 'he:d:n:' opt
|
||||
do
|
||||
case "${opt}" in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
e)
|
||||
DEVICE_TARGET_OPT=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
|
||||
;;
|
||||
d)
|
||||
DEVICE_ID_OPT=$OPTARG
|
||||
;;
|
||||
n)
|
||||
TASECASE_NAME_OPT=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Undefined option: ${opt}"
|
||||
usage
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
}
|
||||
checkopts "$@"
|
||||
|
||||
cd ${PROJECT_PATH}/tests/st/cpp
|
||||
|
||||
MINDSPORE_PKG_PATH=`python -m pip show mindspore-ascend | grep Location | awk '{print $2"/mindspore"}' | xargs realpath`
|
||||
if [[ "X${MINDSPORE_PKG_PATH}" == "X" ]]; then
|
||||
MINDSPORE_PKG_PATH=${PROJECT_PATH}/build/package/mindspore:
|
||||
fi
|
||||
|
||||
export LD_LIBRARY_PATH=${MINDSPORE_PKG_PATH}:${MINDSPORE_PKG_PATH}/lib:${PROJECT_PATH}/tests/st/cpp:$LD_LIBRARY_PATH
|
||||
export GLOG_v=2
|
||||
export GC_COLLECT_IN_CELL=1
|
||||
export DEVICE_ID=$DEVICE_ID_OPT
|
||||
if [[ "X$DEVICE_TARGET_OPT" == "Xascend310" ]]; then
|
||||
export DEVICE_TARGET=Ascend310
|
||||
elif [[ "X$DEVICE_TARGET_OPT" == "Xascend910" ]]; then
|
||||
export DEVICE_TARGET=Ascend910
|
||||
else
|
||||
export DEVICE_TARGET=$DEVICE_TARGET_OPT
|
||||
fi
|
||||
|
||||
if [[ "X$TASECASE_NAME_OPT" != "X" ]]; then
|
||||
./st_tests --gtest_filter=$TASECASE_NAME_OPT
|
||||
else
|
||||
./st_tests
|
||||
fi
|
||||
RET=$?
|
||||
cd -
|
||||
|
||||
exit ${RET}
|
Loading…
Reference in new issue