Steps to add a unittest in this directory
step 1. Add Unittest files
Add a file like test_c_identity.py
step 2. Edit the testslist.csv file
Add an item like test_c_identity in testslist.csv
and specify the properties for the new unit test
the properties are the following:
name: the test's nameos: The supported operator system, ignoring case. If the test run in multiple operator systems, use ";" to split systems, for example,apple;linuxmeans the test runs on both Apple and Linux. The supported values arelinux,win32andapple. If the value is empty, this means the test runs on all operator systems.arch: the device's architecture. similar toos, multiple values are split by ";" and ignoring case. The supported architectures aregpu,xpuandrocm.timeout: timeout of a unittest, whose unit is second. Blank means default.run_type: run_type of a unittest. Supported values areNIGHTLY,EXCLUSIVE,CINN,DIST,GPUPS,INFER,EXCLUSIVE:NIGHTLY,DIST:NIGHTLY,which are case-insensitive.launcher: the test launcher.Supported values are test_runner.py, dist_test.sh and custom scripts' name. Blank means test_runner.py.num_port: the number of port used in a distributed unit test. Blank means automatically distributed port.run_serial: whether in serial mode. the value can be 1 or 0.Default (empty) is 0. Blank means default.ENVS: required environments. multiple environments are split by ";".conditions: extra required conditions for some tests. The value is a list of boolean expression in cmake programmer, split with ";". For example, the value can beWITH_DGC;NOT WITH_NCCLorWITH_NCCL;${NCCL_VERSION} VERSION_GREATER_EQUAL 2212,The relationship between these expressions is a conjunction.
step 3. Generate CMakeLists.txt
Run the cmd:
python3 ${PADDLE_ROOT}/tools/gen_ut_cmakelists.py -f ${PADDLE_ROOT}/python/paddle/fluid/tests/unittests/collective/testslist.csv
Then the cmd generates a file named CMakeLists.txt in the same directory with the testslist.csv.
-
usage: The command accepts --files/-f or --dirpaths/-d options, both of which accepts multiple values. Option -f accepts a list of testslist.csv. Option -d accepts a list of directory path including files named testslist.csv. Type
python3 ${PADDLE_ROOT}/tools/gen_ut_cmakelists.py --helpfor details. -
note: When committing the codes, you should commit both the testslist.csv and the generated CMakeLists.txt. Once you pulled the repo, you don't need to run this command until you modify the testslists.csv file.
step 4. Build and test
Build paddle and run ctest for the new unit test