README.md
1<!--- Licensed to the Apache Software Foundation (ASF) under one -->
2<!--- or more contributor license agreements. See the NOTICE file -->
3<!--- distributed with this work for additional information -->
4<!--- regarding copyright ownership. The ASF licenses this file -->
5<!--- to you under the Apache License, Version 2.0 (the -->
6<!--- "License"); you may not use this file except in compliance -->
7<!--- with the License. You may obtain a copy of the License at -->
8
9<!--- http://www.apache.org/licenses/LICENSE-2.0 -->
10
11<!--- Unless required by applicable law or agreed to in writing, -->
12<!--- software distributed under the License is distributed on an -->
13<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
14<!--- KIND, either express or implied. See the License for the -->
15<!--- specific language governing permissions and limitations -->
16<!--- under the License. -->
17
18# Testing MXNET
19
20## Running CPP Tests
21
221. Install [cmake](https://cmake.org/install/)
231. Create a build directory in the root of the mxnet project
24 ```
25 mkdir build
26 cd build
27 ```
281. Generate your Makefile and build along with the tests with cmake (specify appropraite flags)
29 ```
30 cmake -DUSE_CUDNN=ON -DUSE_CUDA=ON -DUSE_MKLDNN=ON -DBLAS=Open -DCMAKE_BUILD_TYPE=Debug .. && make
31 ```
321. Run tests
33 ```
34 ctest --verbose
35 ```
36
371. The following will run all the tests the in `cpp` directory. To run just your test file replace the following in your `tests/CMakeLists.txt`
38 ```
39 file(GLOB_RECURSE UNIT_TEST_SOURCE "cpp/*.cc" "cpp/*.h")
40 ```
41 with
42 ```
43 file(GLOB_RECURSE UNIT_TEST_SOURCE "cpp/test_main.cc" "cpp/{RELATIVE_PATH_TO_TEST_FILE}")
44 ```
45
46### Building with Ninja
47
48Ninja is a build tool (like make) that prioritizes building speed. If you will be building frequently, we recommend you use ninja
49
501. Download Ninja via package manager or directly from [source](https://github.com/ninja-build/ninja)
51 ```
52 apt-get install ninja-build
53 ```
541. When running cmake, add the `-GNinja` flag to specify cmake to generate a Ninja build file
55 ```
56 cmake -DUSE_CUDNN=ON -DUSE_CUDA=ON -DUSE_MKLDNN=ON -DBLAS=Open -GNinja -DCMAKE_BUILD_TYPE=Debug ..
57 ```
581. Run the ninja build file with
59 ```
60 ninja
61 ```
62
63## Runing Python Tests Within Docker
64
65To run tests inside docker, you first need to install `docker` and `docker-compose` on your machine.
66
67On Ubuntu you may install them via `sudo apt-get install docker.io docker-compose`
68and set them up via `sudo usermod $(whoami) -G docker -a`.
69
70Then, to run tests inside docker run the following command
71
72```
73ci/build.py --platform {PLATFORM} /work/runtime_functions.sh {RUNTIME_FUNCTION}
74```
75
76An example for running python tests would be
77```
78ci/build.py --platform build_ubuntu_cpu_mkldnn /work/runtime_functions.sh unittest_ubuntu_python3_cpu
79```
80
81
82
83