diff --git a/python/paddle/fluid/tests/unittests/CMakeLists.txt b/python/paddle/fluid/tests/unittests/CMakeLists.txt index c03a7738a673f5fee06189b2b740114eca7d90f6..2bb3b45bc4120f4e8aca67145c7f725f934c70f3 100644 --- a/python/paddle/fluid/tests/unittests/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/CMakeLists.txt @@ -348,7 +348,6 @@ list(REMOVE_ITEM TEST_OPS test_imperative_static_runner_while) # disable this unittest temporarily list(REMOVE_ITEM TEST_OPS test_imperative_data_loader_exception) list(REMOVE_ITEM TEST_OPS test_sampling_id_op) -list(REMOVE_ITEM TEST_OPS test_static_save_load) if (APPLE OR WIN32) list(REMOVE_ITEM TEST_OPS test_dataset) @@ -669,7 +668,7 @@ set_tests_properties(test_nearest_interp_v2_op PROPERTIES TIMEOUT 120) set_tests_properties(test_trilinear_interp_op PROPERTIES TIMEOUT 120) set_tests_properties(test_bicubic_interp_v2_op PROPERTIES TIMEOUT 120) set_tests_properties(test_gather_op PROPERTIES TIMEOUT 120) -#set_tests_properties(test_static_save_load PROPERTIES TIMEOUT 120) +set_tests_properties(test_static_save_load PROPERTIES TIMEOUT 120) set_tests_properties(test_imperative_selected_rows_to_lod_tensor PROPERTIES TIMEOUT 120) set_tests_properties(test_index_select_op PROPERTIES TIMEOUT 120) set_tests_properties(test_parallel_ssa_graph_inference_feed_partial_data PROPERTIES TIMEOUT 120) diff --git a/python/paddle/fluid/tests/unittests/test_static_save_load.py b/python/paddle/fluid/tests/unittests/test_static_save_load.py index baab747c57e586e1b92e6486f3fee123842b98f8..d7618add293f67206a61c564db6406fa091ca980 100644 --- a/python/paddle/fluid/tests/unittests/test_static_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_static_save_load.py @@ -28,6 +28,7 @@ import numpy as np import six import pickle import os +import errno class SimpleLSTMRNN(fluid.Layer): @@ -1159,11 +1160,20 @@ class TestProgramStateOldSave(unittest.TestCase): self.check_in_static(main_program, base_map) # case 2: load with no need file + def symlink_force(target, link_name): + try: + os.symlink(target, link_name) + except OSError as e: + if e.errno == errno.EEXIST: + os.remove(link_name) + os.symlink(target, link_name) + else: + raise e + orig_filepath = './test_program_1/fc_0.w_0' symlink_filepath = './test_program_1/link_fc_0.w_0' - if os.path.exists(symlink_filepath): - os.remove(symlink_filepath) - os.symlink(orig_filepath, symlink_filepath) + # create a needless link file for coverage + symlink_force(orig_filepath, symlink_filepath) program_state = fluid.load_program_state("test_program_1") fluid.set_program_state(main_program, program_state) self.check_in_static(main_program, base_map)