@@ -271,7 +271,7 @@ test_inductor() {
271
271
# docker build uses bdist_wheel which does not work with test_aot_inductor
272
272
# TODO: need a faster way to build
273
273
BUILD_AOT_INDUCTOR_TEST=1 python setup.py develop
274
- LD_LIBRARY_PATH =" $TORCH_LIB_DIR $TORCH_BIN_DIR " /test_aot_inductor
274
+ CPP_TESTS_DIR =" ${BUILD_BIN_DIR} " LD_LIBRARY_PATH= " ${TORCH_LIB_DIR} " python test/run_test.py --cpp --verbose -i cpp /test_aot_inductor
275
275
}
276
276
277
277
# "Global" flags for inductor benchmarking controlled by TEST_CONFIG
@@ -547,43 +547,60 @@ test_libtorch() {
547
547
ln -sf " $TORCH_LIB_DIR " /libtbb* " $TORCH_BIN_DIR "
548
548
ln -sf " $TORCH_LIB_DIR " /libnvfuser* " $TORCH_BIN_DIR "
549
549
550
+ export CPP_TESTS_DIR=" ${TORCH_BIN_DIR} "
551
+
550
552
# Start background download
551
- python tools/download_mnist.py --quiet -d test/cpp/api/mnist &
553
+ MNIST_DIR=" ${PWD} /test/cpp/api/mnist"
554
+ python tools/download_mnist.py --quiet -d " ${MNIST_DIR} " &
552
555
553
- # Make test_reports directory
554
- # NB: the ending test_libtorch must match the current function name for the current
555
- # test reporting process to function as expected.
556
- TEST_REPORTS_DIR=test/test-reports/ cpp-unittest/test_libtorch
557
- mkdir -p $TEST_REPORTS_DIR
556
+ # Prepare the model used by test_jit, the model needs to be in the test directory
557
+ # to get picked up by run_test
558
+ pushd test
559
+ python cpp/jit/tests_setup.py setup
560
+ popd
558
561
559
562
# Run JIT cpp tests
560
- python test/cpp/jit/tests_setup.py setup
561
-
562
563
if [[ " $BUILD_ENVIRONMENT " == * cuda* ]]; then
563
- " $TORCH_BIN_DIR " /test_jit --gtest_output=xml:$TEST_REPORTS_DIR /test_jit.xml
564
- " $TORCH_BIN_DIR " /nvfuser_tests --gtest_output=xml:$TEST_REPORTS_DIR /nvfuser_tests.xml
564
+ python test/run_test.py --cpp --verbose -i cpp/test_jit cpp/nvfuser_tests
565
565
else
566
- " $TORCH_BIN_DIR " /test_jit --gtest_filter=' -*CUDA' --gtest_output=xml:$TEST_REPORTS_DIR /test_jit.xml
566
+ # CUDA tests have already been skipped when CUDA is not available
567
+ python test/run_test.py --cpp --verbose -i cpp/test_jit -k " not CUDA"
567
568
fi
568
569
569
570
# Run Lazy Tensor cpp tests
570
571
if [[ " $BUILD_ENVIRONMENT " == * cuda* && " $TEST_CONFIG " != * nogpu* ]]; then
571
- LTC_TS_CUDA=1 " $TORCH_BIN_DIR " /test_lazy --gtest_output=xml: $TEST_REPORTS_DIR /test_lazy.xml
572
+ LTC_TS_CUDA=1 python test/run_test.py --cpp --verbose -i cpp /test_lazy
572
573
else
573
- " $TORCH_BIN_DIR " /test_lazy --gtest_output=xml: $TEST_REPORTS_DIR /test_lazy.xml
574
+ python test/run_test.py --cpp --verbose -i cpp /test_lazy
574
575
fi
575
576
576
- python test/cpp/jit/tests_setup.py shutdown
577
+ # Cleaning up test artifacts in the test folder
578
+ pushd test
579
+ python cpp/jit/tests_setup.py shutdown
580
+ popd
577
581
578
582
# Wait for background download to finish
579
583
wait
580
- # Exclude IMethodTest that relies on torch::deploy, which will instead be ran in test_deploy.
581
- OMP_NUM_THREADS=2 TORCH_CPP_TEST_MNIST_PATH=" test/cpp/api/mnist" " $TORCH_BIN_DIR " /test_api --gtest_filter=' -IMethodTest.*' --gtest_output=xml:$TEST_REPORTS_DIR /test_api.xml
582
- " $TORCH_BIN_DIR " /test_tensorexpr --gtest_output=xml:$TEST_REPORTS_DIR /test_tensorexpr.xml
584
+
585
+ if [[ " $BUILD_ENVIRONMENT " == * asan* ]]; then
586
+ TEST_REPORTS_DIR=test/test-reports/cpp-unittest/test_libtorch
587
+ mkdir -p $TEST_REPORTS_DIR
588
+
589
+ # TODO: Not quite sure why these tests time out only on ASAN, probably
590
+ # this is due to the fact that a python executable is used and ASAN
591
+ # treats that differently
592
+ OMP_NUM_THREADS=2 TORCH_CPP_TEST_MNIST_PATH=" ${MNIST_DIR} " " $TORCH_BIN_DIR " /test_api --gtest_filter=' -IMethodTest.*' --gtest_output=xml:$TEST_REPORTS_DIR /test_api.xml
593
+ " $TORCH_BIN_DIR " /test_tensorexpr --gtest_output=xml:$TEST_REPORTS_DIR /test_tensorexpr.xml
594
+ else
595
+ # Exclude IMethodTest that relies on torch::deploy, which will instead be ran in test_deploy
596
+ OMP_NUM_THREADS=2 TORCH_CPP_TEST_MNIST_PATH=" ${MNIST_DIR} " python test/run_test.py --cpp --verbose -i cpp/test_api -k " not IMethodTest"
597
+ python test/run_test.py --cpp --verbose -i cpp/test_tensorexpr
598
+ fi
583
599
584
600
if [[ " ${BUILD_ENVIRONMENT} " != * android* && " ${BUILD_ENVIRONMENT} " != * cuda* && " ${BUILD_ENVIRONMENT} " != * asan* ]]; then
585
- # TODO: Consider to run static_runtime_test from $TORCH_BIN_DIR (may need modify build script)
586
- " $BUILD_BIN_DIR " /static_runtime_test --gtest_output=xml:$TEST_REPORTS_DIR /static_runtime_test.xml
601
+ # NB: This test is not under TORCH_BIN_DIR but under BUILD_BIN_DIR
602
+ export CPP_TESTS_DIR=" ${BUILD_BIN_DIR} "
603
+ python test/run_test.py --cpp --verbose -i cpp/static_runtime_test
587
604
fi
588
605
589
606
assert_git_not_dirty
@@ -595,26 +612,21 @@ test_aot_compilation() {
595
612
ln -sf " $TORCH_LIB_DIR " /libc10* " $TORCH_BIN_DIR "
596
613
ln -sf " $TORCH_LIB_DIR " /libtorch* " $TORCH_BIN_DIR "
597
614
598
- # Make test_reports directory
599
- # NB: the ending test_libtorch must match the current function name for the current
600
- # test reporting process to function as expected.
601
- TEST_REPORTS_DIR=test/test-reports/cpp-unittest/test_aot_compilation
602
- mkdir -p $TEST_REPORTS_DIR
603
- if [ -f " $TORCH_BIN_DIR " /test_mobile_nnc ]; then " $TORCH_BIN_DIR " /test_mobile_nnc --gtest_output=xml:$TEST_REPORTS_DIR /test_mobile_nnc.xml; fi
604
- # shellcheck source=test/mobile/nnc/test_aot_compile.sh
605
- if [ -f " $TORCH_BIN_DIR " /aot_model_compiler_test ]; then source test/mobile/nnc/test_aot_compile.sh; fi
615
+ if [ -f " $TORCH_BIN_DIR " /test_mobile_nnc ]; then
616
+ CPP_TESTS_DIR=" ${TORCH_BIN_DIR} " python test/run_test.py --cpp --verbose -i cpp/test_mobile_nnc
617
+ fi
618
+
619
+ if [ -f " $TORCH_BIN_DIR " /aot_model_compiler_test ]; then
620
+ source test/mobile/nnc/test_aot_compile.sh
621
+ fi
606
622
}
607
623
608
624
test_vulkan () {
609
625
if [[ " $BUILD_ENVIRONMENT " == * vulkan* ]]; then
610
626
ln -sf " $TORCH_LIB_DIR " /libtorch* " $TORCH_TEST_DIR "
611
627
ln -sf " $TORCH_LIB_DIR " /libc10* " $TORCH_TEST_DIR "
612
628
export VK_ICD_FILENAMES=/var/lib/jenkins/swiftshader/swiftshader/build/Linux/vk_swiftshader_icd.json
613
- # NB: the ending test_vulkan must match the current function name for the current
614
- # test reporting process to function as expected.
615
- TEST_REPORTS_DIR=test/test-reports/cpp-vulkan/test_vulkan
616
- mkdir -p $TEST_REPORTS_DIR
617
- LD_LIBRARY_PATH=/var/lib/jenkins/swiftshader/swiftshader/build/Linux/ " $TORCH_TEST_DIR " /vulkan_api_test --gtest_output=xml:$TEST_REPORTS_DIR /vulkan_test.xml
629
+ CPP_TESTS_DIR=" ${TORCH_TEST_DIR} " LD_LIBRARY_PATH=/var/lib/jenkins/swiftshader/swiftshader/build/Linux/ python test/run_test.py --cpp --verbose -i cpp/vulkan_api_test
618
630
fi
619
631
}
620
632
@@ -631,22 +643,24 @@ test_distributed() {
631
643
echo " Testing distributed C++ tests"
632
644
ln -sf " $TORCH_LIB_DIR " /libtorch* " $TORCH_BIN_DIR "
633
645
ln -sf " $TORCH_LIB_DIR " /libc10* " $TORCH_BIN_DIR "
634
- # NB: the ending test_distributed must match the current function name for the current
635
- # test reporting process to function as expected.
636
- TEST_REPORTS_DIR=test/test-reports/cpp- distributed/test_distributed
637
- mkdir -p $TEST_REPORTS_DIR
638
- " $TORCH_BIN_DIR " /FileStoreTest --gtest_output=xml: $TEST_REPORTS_DIR /FileStoreTest.xml
639
- " $TORCH_BIN_DIR " /HashStoreTest --gtest_output=xml: $TEST_REPORTS_DIR /HashStoreTest.xml
640
- " $TORCH_BIN_DIR " /TCPStoreTest --gtest_output=xml: $TEST_REPORTS_DIR /TCPStoreTest.xml
646
+
647
+ export CPP_TESTS_DIR= " ${TORCH_BIN_DIR} "
648
+ # These are distributed tests, so let's continue running them sequentially here to avoid
649
+ # any surprise
650
+ python test/run_test.py --cpp --verbose -i cpp /FileStoreTest
651
+ python test/run_test.py --cpp --verbose -i cpp /HashStoreTest
652
+ python test/run_test.py --cpp --verbose -i cpp /TCPStoreTest
641
653
642
654
MPIEXEC=$( command -v mpiexec)
643
655
if [[ -n " $MPIEXEC " ]]; then
656
+ # NB: mpiexec only works directly with the C++ test binary here
644
657
MPICMD=" ${MPIEXEC} -np 2 $TORCH_BIN_DIR /ProcessGroupMPITest"
645
658
eval " $MPICMD "
646
659
fi
647
- " $TORCH_BIN_DIR " /ProcessGroupGlooTest --gtest_output=xml:$TEST_REPORTS_DIR /ProcessGroupGlooTest.xml
648
- " $TORCH_BIN_DIR " /ProcessGroupNCCLTest --gtest_output=xml:$TEST_REPORTS_DIR /ProcessGroupNCCLTest.xml
649
- " $TORCH_BIN_DIR " /ProcessGroupNCCLErrorsTest --gtest_output=xml:$TEST_REPORTS_DIR /ProcessGroupNCCLErrorsTest.xml
660
+
661
+ python test/run_test.py --cpp --verbose -i cpp/ProcessGroupGlooTest
662
+ python test/run_test.py --cpp --verbose -i cpp/ProcessGroupNCCLTest
663
+ python test/run_test.py --cpp --verbose -i cpp/ProcessGroupNCCLErrorsTest
650
664
fi
651
665
}
652
666
@@ -658,9 +672,8 @@ test_rpc() {
658
672
ln -sf " $TORCH_LIB_DIR " /libtorch* " $TORCH_BIN_DIR "
659
673
ln -sf " $TORCH_LIB_DIR " /libc10* " $TORCH_BIN_DIR "
660
674
ln -sf " $TORCH_LIB_DIR " /libtbb* " $TORCH_BIN_DIR "
661
- TEST_REPORTS_DIR=test/test-reports/cpp-rpc/test_rpc
662
- mkdir -p $TEST_REPORTS_DIR
663
- " $TORCH_BIN_DIR " /test_cpp_rpc --gtest_output=xml:$TEST_REPORTS_DIR /test_cpp_rpc.xml
675
+
676
+ CPP_TESTS_DIR=" ${TORCH_BIN_DIR} " python test/run_test.py --cpp --verbose -i cpp/test_cpp_rpc
664
677
fi
665
678
}
666
679
0 commit comments