summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls
diff options
context:
space:
mode:
authorBin Lu <bin.lu@arm.com>2020-01-10 16:45:45 +0800
committerBin Lu <bin.lu@arm.com>2020-01-10 16:45:48 +0800
commitebd25099bfb9ac6af9739dd9a7795aff13f8e34a (patch)
tree50e6714558458c659c081c83fb1d9a0cc8222d02 /test/syscalls
parent27500d529f7fb87eef8812278fd1bbca67bcba72 (diff)
enable //test/syscalls:proc_test support on Arm64
Problems with different platform architectures have been solved. Signed-off-by: Bin Lu <bin.lu@arm.com>
Diffstat (limited to 'test/syscalls')
-rw-r--r--test/syscalls/linux/proc.cc70
1 files changed, 48 insertions, 22 deletions
diff --git a/test/syscalls/linux/proc.cc b/test/syscalls/linux/proc.cc
index 8cf08991b..66f89ef64 100644
--- a/test/syscalls/linux/proc.cc
+++ b/test/syscalls/linux/proc.cc
@@ -102,7 +102,55 @@ namespace {
// O_LARGEFILE as defined by Linux. glibc tries to be clever by setting it to 0
// because "it isn't needed", even though Linux can return it via F_GETFL.
+#if defined(__x86_64__) || defined(__i386__)
constexpr int kOLargeFile = 00100000;
+#elif __aarch64__
+// The value originate from the Linux
+// kernel's arch/arm64/include/uapi/asm/fcntl.h.
+constexpr int kOLargeFile = 00400000;
+#else
+#error "Unknown architecture"
+#endif
+
+#if defined(__x86_64__) || defined(__i386__)
+ // This list of "required" fields is taken from reading the file
+ // arch/x86/kernel/cpu/proc.c and seeing which fields will be unconditionally
+ // printed by the kernel.
+ static const char* required_fields[] = {
+ "processor",
+ "vendor_id",
+ "cpu family",
+ "model\t\t:",
+ "model name",
+ "stepping",
+ "cpu MHz",
+ "fpu\t\t:",
+ "fpu_exception",
+ "cpuid level",
+ "wp",
+ "bogomips",
+ "clflush size",
+ "cache_alignment",
+ "address sizes",
+ "power management",
+ };
+#elif __aarch64__
+ // This list of "required" fields is taken from reading the file
+ // arch/arm64/kernel/cpuinfo.c and seeing which fields will be unconditionally
+ // printed by the kernel.
+ static const char* required_fields[] = {
+ "processor",
+ "BogoMIPS",
+ "Features",
+ "CPU implementer",
+ "CPU architecture",
+ "CPU variant",
+ "CPU part",
+ "CPU revision",
+ };
+#else
+#error "Unknown architecture"
+#endif
// Takes the subprocess command line and pid.
// If it returns !OK, WithSubprocess returns immediately.
@@ -717,28 +765,6 @@ TEST(ProcCpuinfo, RequiredFieldsArePresent) {
ASSERT_FALSE(proc_cpuinfo.empty());
std::vector<std::string> cpuinfo_fields = absl::StrSplit(proc_cpuinfo, '\n');
- // This list of "required" fields is taken from reading the file
- // arch/x86/kernel/cpu/proc.c and seeing which fields will be unconditionally
- // printed by the kernel.
- static const char* required_fields[] = {
- "processor",
- "vendor_id",
- "cpu family",
- "model\t\t:",
- "model name",
- "stepping",
- "cpu MHz",
- "fpu\t\t:",
- "fpu_exception",
- "cpuid level",
- "wp",
- "bogomips",
- "clflush size",
- "cache_alignment",
- "address sizes",
- "power management",
- };
-
// Check that the usual fields are there. We don't really care about the
// contents.
for (const std::string& field : required_fields) {