diff options
author | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2014-03-17 13:20:42 -0700 |
---|---|---|
committer | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2014-03-17 13:20:42 -0700 |
commit | 1818f81a6f4f6a3cc47b28cc7ce93f808cbafe7e (patch) | |
tree | c2234aca48bca4e367b574b19bde073fe0ddee77 /src | |
parent | 13d156d282a28371761d93d02f15290138166ddf (diff) | |
parent | f6780f982a912ddc118697197da5c7425960c293 (diff) | |
download | caffeonacl-1818f81a6f4f6a3cc47b28cc7ce93f808cbafe7e.tar.gz caffeonacl-1818f81a6f4f6a3cc47b28cc7ce93f808cbafe7e.tar.bz2 caffeonacl-1818f81a6f4f6a3cc47b28cc7ce93f808cbafe7e.zip |
Merge pull request #179 from erictzeng/test_all
Run all tests jointly in a single binary and summarize failures at the end.
Diffstat (limited to 'src')
-rw-r--r-- | src/caffe/test/test_caffe_main.cpp | 32 | ||||
-rw-r--r-- | src/caffe/test/test_caffe_main.hpp | 28 | ||||
-rw-r--r-- | src/caffe/test/test_common.cpp | 1 |
3 files changed, 34 insertions, 27 deletions
diff --git a/src/caffe/test/test_caffe_main.cpp b/src/caffe/test/test_caffe_main.cpp new file mode 100644 index 00000000..4674bb4e --- /dev/null +++ b/src/caffe/test/test_caffe_main.cpp @@ -0,0 +1,32 @@ +// Copyright 2013 Yangqing Jia + +// The main caffe test code. Your test cpp code should include this hpp +// to allow a main function to be compiled into the binary. + +#include "test_caffe_main.hpp" + +namespace caffe { + cudaDeviceProp CAFFE_TEST_CUDA_PROP; +} + +using caffe::CAFFE_TEST_CUDA_PROP; + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::google::InitGoogleLogging(argv[0]); + // Before starting testing, let's first print out a few cuda defice info. + int device; + cudaGetDeviceCount(&device); + cout << "Cuda number of devices: " << device << endl; + if (argc > 1) { + // Use the given device + device = atoi(argv[1]); + cudaSetDevice(device); + cout << "Setting to use device " << device << endl; + } + cudaGetDevice(&device); + cout << "Current device id: " << device << endl; + cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device); + // invoke the test. + return RUN_ALL_TESTS(); +} diff --git a/src/caffe/test/test_caffe_main.hpp b/src/caffe/test/test_caffe_main.hpp index 01cb0c81..68374ae6 100644 --- a/src/caffe/test/test_caffe_main.hpp +++ b/src/caffe/test/test_caffe_main.hpp @@ -15,32 +15,6 @@ using std::cout; using std::endl; -namespace caffe { - -cudaDeviceProp CAFFE_TEST_CUDA_PROP; - -} // namespace caffe - -using caffe::CAFFE_TEST_CUDA_PROP; - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::google::InitGoogleLogging(argv[0]); - // Before starting testing, let's first print out a few cuda defice info. - int device; - cudaGetDeviceCount(&device); - cout << "Cuda number of devices: " << device << endl; - if (argc > 1) { - // Use the given device - device = atoi(argv[1]); - cudaSetDevice(device); - cout << "Setting to use device " << device << endl; - } - cudaGetDevice(&device); - cout << "Current device id: " << device << endl; - cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device); - // invoke the test. - return RUN_ALL_TESTS(); -} +int main(int argc, char** argv); #endif // CAFFE_TEST_TEST_CAFFE_MAIN_HPP_ diff --git a/src/caffe/test/test_common.cpp b/src/caffe/test/test_common.cpp index 8b521cc7..275c6e1b 100644 --- a/src/caffe/test/test_common.cpp +++ b/src/caffe/test/test_common.cpp @@ -24,6 +24,7 @@ TEST_F(CommonTest, TestVslStream) { } TEST_F(CommonTest, TestBrewMode) { + Caffe::set_mode(Caffe::CPU); EXPECT_EQ(Caffe::mode(), Caffe::CPU); Caffe::set_mode(Caffe::GPU); EXPECT_EQ(Caffe::mode(), Caffe::GPU); |