22import sys
33import os
44import logging
5- import time
65
76logger = logging .getLogger ("fs" )
87logging .basicConfig (format = "%(levelname)s: %(message)s" , encoding = "utf-8" , level = logging .WARNING )
1110test_type = sys .argv [2 ]
1211mem_type = sys .argv [3 ]
1312
14- '''device = "/dev/ttyACM1"
15- test_type = "basic"
16- mem_type = "flash"'''
17-
18-
13+ # tests inputs and script paths
1914test_input_dir = "./ports/psoc6/inputs"
2015test_script_dir = "./ports/psoc6/mp_custom"
21- curr_dir = os .getcwd ()
22- print (f"Current directory: { curr_dir } " )
23-
24- mpremote = "~/MPY/micropython/tools/mpremote/mpremote.py"
25-
2616
2717# List of mpremote commands
28- # mpr_connect = f"{ mpremote} connect {device}"
18+ mpr_connect = f"../tools/ mpremote/mpremote.py connect { device } "
2919mpr_run_script = ""
3020
3121# Remote directory path
@@ -167,7 +157,7 @@ def copy_files(input_cp_files):
167157
168158 logger .debug (f"cp_files command: { cp_cmd } " )
169159
170- print ( "Copying files..." , subprocess .run (cp_cmd , shell = True , capture_output = True ) )
160+ subprocess .run (cp_cmd , shell = True , capture_output = True )
171161
172162
173163def validate_test (files , file_sizes ):
@@ -194,7 +184,7 @@ def validate_test(files, file_sizes):
194184def cp_files_test (input_files , input_files_size ):
195185 rm_files_if_exist (input_files )
196186 copy_files (input_files )
197- # validate_test(input_files, input_files_size)
187+ validate_test (input_files , input_files_size )
198188
199189
200190def large_file_tests (device , test_type , mem_type ):
@@ -206,54 +196,4 @@ def large_file_tests(device, test_type, mem_type):
206196 cp_files_test (input_files , input_files_size )
207197
208198
209- def copy_files_to_dev (cmd , file ):
210- mpr_cp = f"{ mpr_connect } fs cp { file } :/"
211- print ("Copying files..." , subprocess .run (mpr_cp , shell = True , capture_output = True ))
212-
213-
214- # Function to find the micropython project root directory
215- def find_micropython_root (start_path = "/" ):
216- for root , dirs , files in os .walk (start_path ):
217- if os .path .basename (root ) == "micropython" :
218- return root
219- return None
220-
221-
222- # Function to search for a file within the micropython project directory
223- def find_file_in_micropython (root_dir , filename ):
224- for root , dirs , files in os .walk (root_dir ):
225- if filename in files :
226- return os .path .join (root , filename )
227- return None
228-
229-
230- # Main script logic
231- if __name__ == "__main__" :
232- # Find the micropython project root starting from the root of the filesystem
233- root_dir = find_micropython_root (start_path = "/" )
234-
235- if root_dir is None :
236- print ("micropython directory not found" )
237- else :
238- print (f"Found micropython project root at: { root_dir } " )
239-
240- filename = "mpremote.py"
241- mpremote = find_file_in_micropython (root_dir , filename )
242-
243- if mpremote :
244- print (f"File found at: { mpremote } " )
245- else :
246- print (f"File { filename } not found in the micropython project." )
247-
248- mpr_connect = f"{ mpremote } connect { device } "
249-
250- ip_file = "test_fs_small_file.txt"
251- test_ip = find_file_in_micropython (root_dir , ip_file )
252-
253- mpr_cp = f"{ mpr_connect } fs cp { test_ip } :/"
254- print ("Copying files..." , subprocess .run (mpr_cp , shell = True , capture_output = True ))
255-
256- # connect_to_dev_test()
257- # large_file_tests(device, test_type, mem_type)
258-
259- # copy_files_to_dev()
199+ large_file_tests (device , test_type , mem_type )
0 commit comments