diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-07 23:35:53 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-07 23:35:53 +0000 |
commit | 237da28ac8952f156b1b54b00b302872559cf1e9 (patch) | |
tree | 4aff3a7b23e7c5b7afe7abe4bbe842681fbc6dfa | |
parent | b81b3c5afd9256dd5c2d22418e8d96e15b10cf77 (diff) | |
parent | 6495903c08aea15dd61024302b648d59a8073957 (diff) | |
download | extras-237da28ac8952f156b1b54b00b302872559cf1e9.tar.gz |
Merge "Snap for 11812660 from 10ea6cc8b454565df086dad5f05c7ff29661880a to sdk-release" into sdk-release
-rw-r--r-- | profcollectd/libprofcollectd/config.rs | 8 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/report.rs | 3 | ||||
-rwxr-xr-x | tools/check_elf_alignment.sh | 18 |
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 |