未验证 提交 c39da29d 编写于 作者: C Chen Weihang 提交者: GitHub

Add symlink force for unittest test_static_save_load (#29137)

* add symlink force for unittest

* open unittest
上级 9cc0e726
...@@ -348,7 +348,6 @@ list(REMOVE_ITEM TEST_OPS test_imperative_static_runner_while) ...@@ -348,7 +348,6 @@ list(REMOVE_ITEM TEST_OPS test_imperative_static_runner_while)
# disable this unittest temporarily # disable this unittest temporarily
list(REMOVE_ITEM TEST_OPS test_imperative_data_loader_exception) 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_sampling_id_op)
list(REMOVE_ITEM TEST_OPS test_static_save_load)
if (APPLE OR WIN32) if (APPLE OR WIN32)
list(REMOVE_ITEM TEST_OPS test_dataset) list(REMOVE_ITEM TEST_OPS test_dataset)
...@@ -669,7 +668,7 @@ set_tests_properties(test_nearest_interp_v2_op PROPERTIES TIMEOUT 120) ...@@ -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_trilinear_interp_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_bicubic_interp_v2_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_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_imperative_selected_rows_to_lod_tensor PROPERTIES TIMEOUT 120)
set_tests_properties(test_index_select_op 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) set_tests_properties(test_parallel_ssa_graph_inference_feed_partial_data PROPERTIES TIMEOUT 120)
......
...@@ -28,6 +28,7 @@ import numpy as np ...@@ -28,6 +28,7 @@ import numpy as np
import six import six
import pickle import pickle
import os import os
import errno
class SimpleLSTMRNN(fluid.Layer): class SimpleLSTMRNN(fluid.Layer):
...@@ -1159,11 +1160,20 @@ class TestProgramStateOldSave(unittest.TestCase): ...@@ -1159,11 +1160,20 @@ class TestProgramStateOldSave(unittest.TestCase):
self.check_in_static(main_program, base_map) self.check_in_static(main_program, base_map)
# case 2: load with no need file # 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' orig_filepath = './test_program_1/fc_0.w_0'
symlink_filepath = './test_program_1/link_fc_0.w_0' symlink_filepath = './test_program_1/link_fc_0.w_0'
if os.path.exists(symlink_filepath): # create a needless link file for coverage
os.remove(symlink_filepath) symlink_force(orig_filepath, symlink_filepath)
os.symlink(orig_filepath, symlink_filepath)
program_state = fluid.load_program_state("test_program_1") program_state = fluid.load_program_state("test_program_1")
fluid.set_program_state(main_program, program_state) fluid.set_program_state(main_program, program_state)
self.check_in_static(main_program, base_map) self.check_in_static(main_program, base_map)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册