@@ -51,18 +51,20 @@ class ParseError(Exception):
51
51
52
52
53
53
def check_temp_dir ():
54
- # test if /dev/shm is available by writing a file
55
- temp_dir_filesystem = "/dev/shm"
56
- delete_at_exit = False
57
- try :
58
- with open (os .path .join (temp_dir_filesystem , "test" ), "w" ) as f :
59
- f .write ("test" )
60
- os .remove (os .path .join (temp_dir_filesystem , "test" ))
61
- except :
62
- temp_dir_filesystem = tempfile .gettempdir ()
63
- delete_at_exit = True
64
- print ("WARNING: /dev/shm not available, using non-RAM " + temp_dir_filesystem )
65
- return temp_dir_filesystem , delete_at_exit
54
+ PATHS = ["/docker/memfs" , "/dev/shm" ]
55
+
56
+ for path in PATHS :
57
+ try :
58
+ testfile = os .path .join (path , "test" )
59
+ with open (testfile , "w" ) as f :
60
+ f .write ("test" )
61
+ os .remove (testfile )
62
+
63
+ return path , True
64
+ except FileNotFoundError :
65
+ pass
66
+
67
+ return tempfile .gettempdir (), True
66
68
67
69
68
70
temp_dir_filesystem , delete_at_exit = check_temp_dir ()
@@ -562,7 +564,7 @@ def test_parse_instruction(self):
562
564
563
565
def assemble (instruction : Instruction | str ) -> list [str ]:
564
566
# create temporary directory
565
- with tempfile .TemporaryDirectory (prefix = "ax_assemble" , dir = "/dev/shm" ) as tmpdir :
567
+ with tempfile .TemporaryDirectory (prefix = "ax_assemble" , dir = temp_dir_filesystem ) as tmpdir :
566
568
# write assembly code to file
567
569
assembly_path = os .path .join (tmpdir , "a.asm" )
568
570
with open (assembly_path , "w" , encoding = 'utf8' ) as f :
@@ -994,7 +996,7 @@ def is_new(flags_set, flags_not_set, input_flags):
994
996
return False
995
997
return True
996
998
997
- with tempfile .TemporaryDirectory (prefix = "ax_flag_learner" , dir = "/dev/shm" ) as tmpdir :
999
+ with tempfile .TemporaryDirectory (prefix = "ax_flag_learner" , dir = temp_dir_filesystem ) as tmpdir :
998
1000
def imap_func (input : tuple [int , Input ]):
999
1001
return TestCase .learn_single_flags (input [0 ], assembled , instruction , input [1 ], tmpdir )
1000
1002
@@ -1223,10 +1225,10 @@ def main():
1223
1225
1224
1226
1225
1227
if __name__ == "__main__" :
1226
- try :
1228
+ # try:
1227
1229
main ()
1228
- except Exception as e :
1229
- raise e
1230
- finally :
1231
- if delete_at_exit :
1232
- shutil .rmtree (temp_dir_filesystem )
1230
+ # except Exception as e:
1231
+ # raise e
1232
+ # finally:
1233
+ # if delete_at_exit:
1234
+ # shutil.rmtree(temp_dir_filesystem)
0 commit comments