Skip to content

Commit 45f26db

Browse files
committed
tests/ports/psoc6/mp_custom/fs.py: Update to list files.
Signed-off-by: NikhitaR-IFX <nikhita.rajasekhar@infineon.com>
1 parent b69a3b5 commit 45f26db

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

  • tests/ports/psoc6/mp_custom

tests/ports/psoc6/mp_custom/fs.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ def rm_files_if_exist(files):
142142
print(f"Existing files removed.")
143143

144144

145+
def find_file(name, path="."):
146+
try:
147+
for entry in os.listdir(path):
148+
full = path + "/" + entry
149+
if entry == name:
150+
return full
151+
if os.stat(full)[0] & 0x4000:
152+
found = find_file(name, full)
153+
if found:
154+
return found
155+
except:
156+
pass
157+
return None
158+
159+
145160
def copy_files(input_cp_files):
146161
### This will create a command with concatenation of cp commands for each file in the list:
147162
# ../tools/mpremote/mpremote.py connect /dev/ttyACM0 fs cp ./ports/psoc6/test_inputs/test_fs_medium_file.txt :/ + fs cp ./ports/psoc6/test_inputs/test_fs_medium_file.txt :/
@@ -153,15 +168,22 @@ def copy_files(input_cp_files):
153168
append_cmd_operand = " + "
154169
cp_sub_cmd += f"cp {test_input_dir}/{file} :{remote_directory_path}{append_cmd_operand}"
155170

156-
cp_cmd = f"{mpr_connect} {mpr_run_script} {cp_sub_cmd}"
171+
# cp_cmd = f"{mpr_connect} {mpr_run_script} {cp_sub_cmd}"
157172
ls_cmd = f"{mpr_connect} fs ls"
158173

159174
print("List files in local: ", os.listdir(test_input_dir))
160175

161-
logger.debug(f"cp_files command: {cp_cmd}")
176+
# logger.debug(f"cp_files command: {cp_cmd}")
162177

163178
print("List files in device: ", subprocess.run(ls_cmd, shell=True, capture_output=True))
164179

180+
result = find_file("test_fs_small_file.txt")
181+
print("Found at:" if result else "Not found:", result)
182+
183+
cp_sub_modified = f"cp {result} :/"
184+
185+
cp_cmd = f"{mpr_connect} {mpr_run_script} {cp_sub_modified}"
186+
165187
print("Copying files...", subprocess.run(cp_cmd, shell=True, capture_output=True))
166188

167189

0 commit comments

Comments
 (0)