diff options
author | Marat Dukhan <marat@fb.com> | 2017-10-26 00:35:46 +0000 |
---|---|---|
committer | Marat Dukhan <marat@fb.com> | 2017-10-26 00:35:46 +0000 |
commit | e029fd46d118f4e7d5d5c5f7e012df04f19983c8 (patch) | |
tree | 803a4c32033b7bcb69035ea845fbae59c78bfc54 /scripts | |
parent | f1c4a5c1f4f77b72b35bd67795f35d1e264c6d5e (diff) | |
download | cpuinfo-e029fd46d118f4e7d5d5c5f7e012df04f19983c8.tar.gz |
Fix problems with CMake build on ARM/Linux
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/android-armv7-build.sh | 13 | ||||
-rwxr-xr-x | scripts/android-armv7-cache-info.sh | 6 | ||||
-rwxr-xr-x | scripts/android-armv7-cpu-info.sh | 6 | ||||
-rwxr-xr-x | scripts/android-armv7-isa-info.sh | 6 | ||||
-rwxr-xr-x | scripts/android-armv7-mock.sh | 41 | ||||
-rwxr-xr-x | scripts/android-armv7-test.sh | 6 | ||||
-rwxr-xr-x | scripts/android-filesystem-dump.py | 122 | ||||
-rw-r--r-- | scripts/arm-linux-filesystem-dump.py | 107 |
8 files changed, 307 insertions, 0 deletions
diff --git a/scripts/android-armv7-build.sh b/scripts/android-armv7-build.sh new file mode 100755 index 0000000..094e9eb --- /dev/null +++ b/scripts/android-armv7-build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +SYSTEMNAME=`uname` +if [[ "$SYSTEMNAME" == 'Darwin' ]] +then + PROCESSORS=`sysctl -n hw.ncpu` +else + PROCESSORS=`nproc` +fi + +ndk-build APP_ABI=armeabi-v7a -j$PROCESSORS diff --git a/scripts/android-armv7-cache-info.sh b/scripts/android-armv7-cache-info.sh new file mode 100755 index 0000000..ab1313e --- /dev/null +++ b/scripts/android-armv7-cache-info.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +adb push libs/armeabi-v7a/cache-info /data/local/tmp/cache-info +adb shell /data/local/tmp/cache-info diff --git a/scripts/android-armv7-cpu-info.sh b/scripts/android-armv7-cpu-info.sh new file mode 100755 index 0000000..cd7d885 --- /dev/null +++ b/scripts/android-armv7-cpu-info.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +adb push libs/armeabi-v7a/cpu-info /data/local/tmp/cpu-info +adb shell /data/local/tmp/cpu-info diff --git a/scripts/android-armv7-isa-info.sh b/scripts/android-armv7-isa-info.sh new file mode 100755 index 0000000..7b0176a --- /dev/null +++ b/scripts/android-armv7-isa-info.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +adb push libs/armeabi-v7a/isa-info /data/local/tmp/isa-info +adb shell /data/local/tmp/isa-info diff --git a/scripts/android-armv7-mock.sh b/scripts/android-armv7-mock.sh new file mode 100755 index 0000000..9991b5b --- /dev/null +++ b/scripts/android-armv7-mock.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +adb push libs/armeabi-v7a/blu-r1-hd-test /data/local/tmp/blu-r1-hd-test +adb push libs/armeabi-v7a/moto-e-gen1-test /data/local/tmp/moto-e-gen1-test +adb push libs/armeabi-v7a/moto-g-gen2-test /data/local/tmp/moto-g-gen2-test +adb push libs/armeabi-v7a/moto-g-gen3-test /data/local/tmp/moto-g-gen3-test +adb push libs/armeabi-v7a/nexus4-test /data/local/tmp/nexus4-test +adb push libs/armeabi-v7a/nexus5x-test /data/local/tmp/nexus5x-test +adb push libs/armeabi-v7a/nexus6-test /data/local/tmp/nexus6-test +adb push libs/armeabi-v7a/nexus6p-test /data/local/tmp/nexus6p-test +adb push libs/armeabi-v7a/nexus9-test /data/local/tmp/nexus9-test +adb push libs/armeabi-v7a/meizu-pro-6s-test /data/local/tmp/meizu-pro-6s-test +adb push libs/armeabi-v7a/galaxy-grand-prime-value-edition-test /data/local/tmp/galaxy-grand-prime-value-edition-test +adb push libs/armeabi-v7a/galaxy-s3-us-test /data/local/tmp/galaxy-s3-us-test +adb push libs/armeabi-v7a/galaxy-s4-us-test /data/local/tmp/galaxy-s4-us-test +adb push libs/armeabi-v7a/galaxy-s6-test /data/local/tmp/galaxy-s6-test +adb push libs/armeabi-v7a/galaxy-s7-us-test /data/local/tmp/galaxy-s7-us-test +adb push libs/armeabi-v7a/galaxy-s7-global-test /data/local/tmp/galaxy-s7-global-test +adb push libs/armeabi-v7a/galaxy-s8-us-test /data/local/tmp/galaxy-s8-us-test +adb push libs/armeabi-v7a/galaxy-s8-global-test /data/local/tmp/galaxy-s8-global-test + +# adb shell "/data/local/tmp/blu-r1-hd-test --gtest_color=yes" +# adb shell "/data/local/tmp/moto-e-gen1-test --gtest_color=yes" +# adb shell "/data/local/tmp/moto-g-gen2-test --gtest_color=yes" +# adb shell "/data/local/tmp/moto-g-gen3-test --gtest_color=yes" +# adb shell "/data/local/tmp/nexus4-test --gtest_color=yes" +# adb shell "/data/local/tmp/nexus5x-test --gtest_color=yes" +# adb shell "/data/local/tmp/nexus6-test --gtest_color=yes" +# adb shell "/data/local/tmp/nexus6p-test --gtest_color=yes" +# adb shell "/data/local/tmp/nexus9-test --gtest_color=yes" +# adb shell "/data/local/tmp/meizu-pro-6s-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-grand-prime-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-s3-us-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-s4-us-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-s6-test --gtest_color=yes" +adb shell "/data/local/tmp/galaxy-s7-us-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-s7-global-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-s8-us-test --gtest_color=yes" +# adb shell "/data/local/tmp/galaxy-s8-global-test --gtest_color=yes" diff --git a/scripts/android-armv7-test.sh b/scripts/android-armv7-test.sh new file mode 100755 index 0000000..21d8f47 --- /dev/null +++ b/scripts/android-armv7-test.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +adb push libs/armeabi-v7a/init-test /data/local/tmp/init-test +adb shell /data/local/tmp/init-test --gtest_color=yes diff --git a/scripts/android-filesystem-dump.py b/scripts/android-filesystem-dump.py new file mode 100755 index 0000000..52d4fb9 --- /dev/null +++ b/scripts/android-filesystem-dump.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python + +import os +import sys +import argparse +import subprocess +import tempfile + + +parser = argparse.ArgumentParser(description='Android system files extractor') +parser.add_argument("-p", "--prefix", metavar="NAME", required=True, + help="Prefix for stored files, e.g. galaxy-s7-us") + + +SYSTEM_FILES = [ + "/proc/cpuinfo", + "/system/build.prop", + "/sys/devices/system/cpu/kernel_max", + "/sys/devices/system/cpu/possible", + "/sys/devices/system/cpu/present", +] + +CPU_FILES = [ + "cpufreq/cpuinfo_max_freq", + "cpufreq/cpuinfo_min_freq", + "topology/physical_package_id", + "topology/core_siblings_list", + "topology/core_id", + "topology/thread_siblings_list", +] + +CACHE_FILES = [ + "allocation_policy", + "coherency_line_size", + "level", + "number_of_sets", + "shared_cpu_list", + "size", + "type", + "ways_of_associativity", + "write_policy", +] + +def c_escape(string): + c_string = "" + for c in string: + if c == "\\": + c_string += "\\\\" + elif c == "\"": + c_string += "\\\"" + elif c == "\t": + c_string += "\\t" + elif c == "\n": + c_string += "\\n" + elif c == "\r": + c_string += "\\r" + elif ord(c) == 0: + c_string += "\\0" + elif 32 <= ord(c) < 127: + c_string += c + else: + c_string += "x%02X" % ord(c) + return c_string + +def adb_pull(device_path, local_path): + env = os.environ.copy() + env["LC_ALL"] = "C" + + adb = subprocess.Popen(["adb", "pull", device_path, local_path], env=env) + adb.communicate() + return adb.returncode == 0 + + +def dump_device_file(stream, path): + temp_fd, temp_path = tempfile.mkstemp() + os.close(temp_fd) + try: + if adb_pull(path, temp_path): + with open(temp_path, "rb") as temp_file: + content = temp_file.read() + stream.write("\t{\n") + stream.write("\t\t.path = \"%s\",\n" % path) + stream.write("\t\t.size = %d,\n" % len(content)) + if len(content.splitlines()) > 1: + stream.write("\t\t.content =") + for line in content.splitlines(True): + stream.write("\n\t\t\t\"%s\"" % c_escape(line)) + stream.write(",\n") + else: + stream.write("\t\t.content = \"%s\",\n" % c_escape(content)) + stream.write("\t},\n") + return True + finally: + os.remove(temp_path) + + +def main(args): + options = parser.parse_args(args) + + # with open(os.path.join("test", "dmesg", options.prefix + ".log"), "w") as dmesg_log: + # dmesg_log.write(device.Shell("dmesg")) + with open(os.path.join("test", options.prefix + ".h"), "w") as file_header: + file_header.write("struct cpuinfo_mock_file filesystem[] = {\n") + for path in SYSTEM_FILES: + dump_device_file(file_header, path) + for cpu in range(16): + for filename in CPU_FILES: + path = "/sys/devices/system/cpu/cpu%d/%s" % (cpu, filename) + dump_device_file(file_header, path) + for index in range(10): + for filename in CACHE_FILES: + path = "/sys/devices/system/cpu/cpu%d/cache/index%d/%s" % (cpu, index, filename) + dump_device_file(file_header, path) + file_header.write("\t{ NULL },\n") + file_header.write("};\n") + adb_pull("/proc/cpuinfo", + os.path.join("test", "cpuinfo", options.prefix + ".log")) + adb_pull("/system/build.prop", + os.path.join("test", "build.prop", options.prefix + ".log")) + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/scripts/arm-linux-filesystem-dump.py b/scripts/arm-linux-filesystem-dump.py new file mode 100644 index 0000000..feecf4b --- /dev/null +++ b/scripts/arm-linux-filesystem-dump.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python + +import os +import sys +import argparse +import shutil + + +parser = argparse.ArgumentParser(description='Android system files extractor') +parser.add_argument("-p", "--prefix", metavar="NAME", required=True, + help="Prefix for stored files, e.g. galaxy-s7-us") + + +SYSTEM_FILES = [ + "/proc/cpuinfo", + "/sys/devices/system/cpu/kernel_max", + "/sys/devices/system/cpu/possible", + "/sys/devices/system/cpu/present", +] + +CPU_FILES = [ + "cpufreq/cpuinfo_max_freq", + "cpufreq/cpuinfo_min_freq", + "topology/physical_package_id", + "topology/core_siblings_list", + "topology/core_id", + "topology/thread_siblings_list", +] + +CACHE_FILES = [ + "allocation_policy", + "coherency_line_size", + "level", + "number_of_sets", + "shared_cpu_list", + "size", + "type", + "ways_of_associativity", + "write_policy", +] + +def c_escape(string): + c_string = "" + for c in string: + if c == "\\": + c_string += "\\\\" + elif c == "\"": + c_string += "\\\"" + elif c == "\t": + c_string += "\\t" + elif c == "\n": + c_string += "\\n" + elif c == "\r": + c_string += "\\r" + elif ord(c) == 0: + c_string += "\\0" + elif 32 <= ord(c) < 127: + c_string += c + else: + c_string += "x%02X" % ord(c) + return c_string + + +def dump_system_file(stream, path): + try: + with open(path, "rb") as device_file: + content = device_file.read() + stream.write("\t{\n") + stream.write("\t\t.path = \"%s\",\n" % path) + stream.write("\t\t.size = %d,\n" % len(content)) + if len(content.splitlines()) > 1: + stream.write("\t\t.content =") + for line in content.splitlines(True): + stream.write("\n\t\t\t\"%s\"" % c_escape(line)) + stream.write(",\n") + else: + stream.write("\t\t.content = \"%s\",\n" % c_escape(content)) + stream.write("\t},\n") + return True + except IOError: + pass + + +def main(args): + options = parser.parse_args(args) + + # with open(os.path.join("test", "dmesg", options.prefix + ".log"), "w") as dmesg_log: + # dmesg_log.write(device.Shell("dmesg")) + with open(os.path.join("test", options.prefix + ".h"), "w") as file_header: + file_header.write("struct cpuinfo_mock_file filesystem[] = {\n") + for path in SYSTEM_FILES: + dump_system_file(file_header, path) + for cpu in range(16): + for filename in CPU_FILES: + path = "/sys/devices/system/cpu/cpu%d/%s" % (cpu, filename) + dump_system_file(file_header, path) + for index in range(10): + for filename in CACHE_FILES: + path = "/sys/devices/system/cpu/cpu%d/cache/index%d/%s" % (cpu, index, filename) + dump_system_file(file_header, path) + file_header.write("\t{ NULL },\n") + file_header.write("};\n") + shutil.copy("/proc/cpuinfo", + os.path.join("test", "cpuinfo", options.prefix + ".log")) + +if __name__ == "__main__": + main(sys.argv[1:]) |