summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-07 23:22:07 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-07 23:22:07 +0000
commit6495903c08aea15dd61024302b648d59a8073957 (patch)
tree4aff3a7b23e7c5b7afe7abe4bbe842681fbc6dfa
parentb81b3c5afd9256dd5c2d22418e8d96e15b10cf77 (diff)
parent10ea6cc8b454565df086dad5f05c7ff29661880a (diff)
downloadextras-6495903c08aea15dd61024302b648d59a8073957.tar.gz
Snap for 11812660 from 10ea6cc8b454565df086dad5f05c7ff29661880a to sdk-release
Change-Id: I34e05d9c1460212900cf4a2c30f77f34d3003cd5
-rw-r--r--profcollectd/libprofcollectd/config.rs8
-rw-r--r--profcollectd/libprofcollectd/report.rs3
-rwxr-xr-xtools/check_elf_alignment.sh18
3 files changed, 19 insertions, 10 deletions
diff --git a/profcollectd/libprofcollectd/config.rs b/profcollectd/libprofcollectd/config.rs
index af714242..8a6c9e4f 100644
--- a/profcollectd/libprofcollectd/config.rs
+++ b/profcollectd/libprofcollectd/config.rs
@@ -166,3 +166,11 @@ pub fn clear_data() -> Result<()> {
remove_files(&REPORT_OUTPUT_DIR)?;
Ok(())
}
+pub fn clear_processed_files() -> Result<()> {
+ read_dir(&PROFILE_OUTPUT_DIR as &Path)?
+ .filter_map(|e| e.ok())
+ .map(|e| e.path())
+ .filter(|e| e.is_file() && e != (&CONFIG_FILE as &Path))
+ .try_for_each(remove_file)?;
+ Ok(())
+}
diff --git a/profcollectd/libprofcollectd/report.rs b/profcollectd/libprofcollectd/report.rs
index e0f2ec84..60410c1a 100644
--- a/profcollectd/libprofcollectd/report.rs
+++ b/profcollectd/libprofcollectd/report.rs
@@ -29,7 +29,7 @@ use zip::write::FileOptions;
use zip::CompressionMethod::Deflated;
use zip::ZipWriter;
-use crate::config::Config;
+use crate::config::{clear_processed_files, Config};
pub const NO_USAGE_SETTING: i32 = -1;
@@ -80,6 +80,7 @@ pub fn pack_report(
zip.write_all(usage_setting.to_string().as_bytes())?;
}
zip.finish()?;
+ clear_processed_files()?;
Ok(report_filename)
}
diff --git a/tools/check_elf_alignment.sh b/tools/check_elf_alignment.sh
index ba82eb7a..b74f34ae 100755
--- a/tools/check_elf_alignment.sh
+++ b/tools/check_elf_alignment.sh
@@ -40,12 +40,12 @@ if ! [ -f "${dir}" -o -d "${dir}" ]; then
exit 1
fi
-if [[ ${dir} == *.apk ]]; then
+if [[ "${dir}" == *.apk ]]; then
trap 'cleanup_trap' EXIT
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
echo "=== APK zip-alignment ==="
- zipalign -v -c -P 16 4 ${dir} | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
+ zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
echo "========================="
else
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
@@ -55,10 +55,10 @@ if [[ ${dir} == *.apk ]]; then
echo " sdkmanager \"build-tools;35.0.0-rc3\""
fi
- dir_filename=$(basename ${dir})
- tmp=$(mktemp -d -t ${dir_filename%.apk}_out_XXXXX)
- unzip ${dir} lib/arm64-v8a/* lib/x86_64/* -d ${tmp} >/dev/null 2>&1
- dir=${tmp}
+ dir_filename=$(basename "${dir}")
+ tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
+ unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
+ dir="${tmp}"
fi
RED="\e[31m"
@@ -70,7 +70,7 @@ unaligned_libs=()
echo
echo "=== ELF alignment ==="
-matches="$(find ${dir} -name "*.so" -type f)"
+matches="$(find "${dir}" -name "*.so" -type f)"
IFS=$'\n'
for match in $matches; do
res="$(objdump -p ${match} | grep LOAD | awk '{ print $NF }' | head -1)"
@@ -78,12 +78,12 @@ for match in $matches; do
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
else
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
- unaligned_libs+=(${match})
+ unaligned_libs+=("${match}")
fi
done
if [ ${#unaligned_libs[@]} -gt 0 ]; then
- echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs${ENDCOLOR}"
+ echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
elif [ -n "${dir_filename}" ]; then
echo -e "ELF Verification Successful"
fi