Skip to content

Commit ca99c10

Browse files
committed
Add travis test scripts (#35)
1 parent 200973a commit ca99c10

File tree

8 files changed

+91
-5
lines changed

8 files changed

+91
-5
lines changed

nnvm/include/nnvm/graph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Graph {
4646
* \tparam T the type of the attribute.
4747
*/
4848
template<typename T>
49-
inline const T& GetAttr(const std::string& attr_name);
49+
inline const T& GetAttr(const std::string& attr_name) const;
5050
/*!
5151
* \brief Get a move copy of the attribute, implement copy on write semantics.
5252
* The content is moved if the reference counter of shared_ptr is 1.
@@ -209,7 +209,7 @@ inline void DFSVisit(const std::vector<NodeEntry>& heads, FVisit fvisit);
209209

210210
// inline function implementations
211211
template<typename T>
212-
inline const T& Graph::GetAttr(const std::string& attr_name) {
212+
inline const T& Graph::GetAttr(const std::string& attr_name) const {
213213
auto it = attrs.find(attr_name);
214214
CHECK(it != attrs.end())
215215
<< "Cannot find attribute " << attr_name << " in the graph";

nnvm/tests/cpp/op_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ TEST(Op, GetAttr) {
1919

2020
CHECK_EQ(nick[add], "plus");
2121
}
22+
23+
int main(int argc, char ** argv) {
24+
testing::InitGoogleTest(&argc, argv);
25+
testing::FLAGS_gtest_death_test_style = "threadsafe";
26+
return RUN_ALL_TESTS();
27+
}

nnvm/tests/cpp/tuple_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ TEST(Tuple, Basic) {
2222
s = std::move(ss);
2323
CHECK((s == TShape{1, 2, 3}));
2424
}
25+
26+
int main(int argc, char ** argv) {
27+
testing::InitGoogleTest(&argc, argv);
28+
testing::FLAGS_gtest_death_test_style = "threadsafe";
29+
return RUN_ALL_TESTS();
30+
}

nnvm/tests/cpp/unittest.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ GTEST_INC=$(GTEST_PATH)/include/
44
TEST_SRC = $(wildcard tests/cpp/*_test.cc)
55
TEST = $(patsubst tests/cpp/%_test.cc, tests/cpp/%_test, $(TEST_SRC))
66

7-
tests/cpp/%_test: tests/cpp/%_test.cc lib/libnngraph.a
7+
tests/cpp/%_test: tests/cpp/%_test.cc lib/libnnvm.a
88
$(CXX) -std=c++11 $(CFLAGS) -MM -MT tests/cpp/$* $< >tests/cpp/$*.d
99
$(CXX) -std=c++11 $(CFLAGS) -I$(GTEST_INC) -o $@ $(filter %.cc %.a, $^) \
10-
-L$(GTEST_LIB) $(LDFLAGS) -lgtest -lgtest_main
10+
-L$(GTEST_LIB) $(LDFLAGS) -lgtest
1111

1212
-include tests/cpp/*.d

nnvm/tests/python/test_gradient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_graph_gradient():
1818
print("Original graph")
1919
print(y.debug_str())
2020
print("Gradient graph")
21-
print grad_graph.symbol.debug_str()
21+
print(grad_graph.symbol.debug_str())
2222

2323
if __name__ == "__main__":
2424
test_graph_gradient()

nnvm/tests/travis/run_test.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
4+
if [ ${TASK} == "lint" ]; then
5+
make lint || exit -1
6+
echo "Check documentations of c++ code..."
7+
make doc 2>log.txt
8+
(cat log.txt| grep -v ENABLE_PREPROCESSING |grep -v "unsupported tag") > logclean.txt
9+
echo "---------Error Log----------"
10+
cat logclean.txt
11+
echo "----------------------------"
12+
(cat logclean.txt|grep warning) && exit -1
13+
(cat logclean.txt|grep error) && exit -1
14+
exit 0
15+
fi
16+
17+
18+
if [ ! ${TRAVIS_OS_NAME} == "osx" ]; then
19+
# use g++-4.8 for linux
20+
if [ ${CXX} == "g++" ]; then
21+
export CXX=g++-4.8
22+
fi
23+
fi
24+
25+
if [ ${TASK} == "cpp_test" ]; then
26+
make -f dmlc-core/scripts/packages.mk gtest
27+
echo "GTEST_PATH="${CACHE_PREFIX} >> config.mk
28+
make test || exit -1
29+
for test in tests/cpp/*_test; do
30+
./$test || exit -1
31+
done
32+
exit 0
33+
fi
34+
35+
# run two test one for cython, one for ctypes
36+
if [ ${TASK} == "python_test" ]; then
37+
make clean
38+
make -j all || exit -1
39+
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
40+
python -m nose tests/python/ || exit -1
41+
python3 -m nose tests/python/ || exit -1
42+
else
43+
nosetests tests/python/ || exit -1
44+
nosetests3 tests/python/ || exit -1
45+
fi
46+
47+
python -m nose tests/python/ || exit -1
48+
python3 -m nose tests/python/ || exit -1
49+
make cython || exit -1
50+
make cython3 || exit -1
51+
python -m nose tests/python/ || exit -1
52+
python3 -m nose tests/python/ || exit -1
53+
exit 0
54+
fi

nnvm/tests/travis/setup.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
4+
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
5+
brew update
6+
brew install python3
7+
if [ ${TASK} == "python_test" ]; then
8+
python -m pip install nose numpy cython --user `whoami`
9+
python3 -m pip install nose numpy cython --user `whoami`
10+
fi
11+
fi
12+
13+
if [ ${TASK} == "lint" ]; then
14+
pip install cpplint 'pylint==1.4.4' 'astroid==1.3.6' --user `whoami`
15+
fi
16+
17+
if [ ! -d dmlc-core ]; then
18+
git clone https://github.com/dmlc/dmlc-core
19+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/bash

0 commit comments

Comments
 (0)