Better handle symlinks in flattened APEXes in `art_apex_test.py`.
APEXes can contain symlinks which appear broken on host, as they may
reference files located under `/system` on device. For this reason,
avoid reading the size of a symlink's target present in a flattened
APEX in script `build/apex/art_apex_test.py`; instead, report the
length of the symlink's target's path as file size, like `ls`.
Test: art/build/apex/runtests.sh -l -t -s
Change-Id: I60dc53d94aa585e1ffa8633e775cb1a324ee5242
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 186a994..b86abf3 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -170,7 +170,11 @@
is_dir = os.path.isdir(filepath)
is_exec = os.access(filepath, os.X_OK)
is_symlink = os.path.islink(filepath)
- size = os.path.getsize(filepath)
+ if is_symlink:
+ # Report the length of the symlink's target's path as file size, like `ls`.
+ size = len(os.readlink(filepath))
+ else:
+ size = os.path.getsize(filepath)
apex_map[basename] = FSObject(basename, is_dir, is_exec, is_symlink, size)
self._folder_cache[apex_dir] = apex_map
return apex_map