]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/test_arch.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph distributed storage system
6 * Copyright (C) 2014 Red Hat <contact@redhat.com>
8 * Author: Loic Dachary <loic@dachary.org>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
19 #include "arch/probe.h"
20 #include "arch/intel.h"
22 #include "global/global_context.h"
23 #include "gtest/gtest.h"
26 #define FLAGS_SIZE 4096
31 EXPECT_TRUE(ceph_arch_probed
);
33 #if (__arm__ || __aarch64__ || __x86_64__) && __linux__
34 char flags
[FLAGS_SIZE
];
35 FILE *f
= popen("grep '^\\(flags\\|Features\\)[ ]*:' "
36 "/proc/cpuinfo | head -1", "r");
37 if(f
== NULL
|| fgets(flags
, FLAGS_SIZE
- 1, f
) == NULL
) {
38 // silently do nothing if /proc/cpuinfo does exist, is not
39 // readable or does not contain the expected information
45 flags
[strlen(flags
) - 1] = ' ';
49 #if (__arm__ || __aarch64__)
51 expected
= (strstr(flags
, " neon ") || strstr(flags
, " asimd ")) ? 1 : 0;
52 EXPECT_EQ(expected
, ceph_arch_neon
);
57 expected
= strstr(flags
, " crc32 ") ? 1 : 0;
58 EXPECT_EQ(expected
, ceph_arch_aarch64_crc32
);
63 expected
= strstr(flags
, " pclmulqdq ") ? 1 : 0;
64 EXPECT_EQ(expected
, ceph_arch_intel_pclmul
);
66 expected
= strstr(flags
, " sse4_2 ") ? 1 : 0;
67 EXPECT_EQ(expected
, ceph_arch_intel_sse42
);
69 expected
= strstr(flags
, " sse4_1 ") ? 1 : 0;
70 EXPECT_EQ(expected
, ceph_arch_intel_sse41
);
72 expected
= (strstr(flags
, " sse3 ") || strstr(flags
, " ssse3 ") || strstr(flags
, " pni ")) ? 1 : 0;
73 EXPECT_EQ(expected
, ceph_arch_intel_sse3
);
75 expected
= strstr(flags
, " ssse3 ") ? 1 : 0;
76 EXPECT_EQ(expected
, ceph_arch_intel_ssse3
);
78 expected
= strstr(flags
, " sse2 ") ? 1 : 0;
79 EXPECT_EQ(expected
, ceph_arch_intel_sse2
);
89 * compile-command: "cd .. ; make -j4 &&
90 * make unittest_arch &&
91 * valgrind --tool=memcheck ./unittest_arch --gtest_filter=*.*"