Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
test_os_cpu_arch.cpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24#include <cassert>
25#include <cinttypes>
26#include <cstring>
27#include <memory>
28#include <thread>
29#include <pthread.h>
30
32
33#include <jau/file_util.hpp>
34#include <jau/cpuid.hpp>
35#include <jau/os/os_support.hpp>
36#include <jau/os/user_info.hpp>
37
38TEST_CASE( "Test 00 Platform Info - os_and_arch", "[endian][abi][cpu][os]" ) {
39 std::cout << jau::os::get_platform_info() << std::endl;
40}
41
42TEST_CASE( "Test 01 OS CPU ABI ENDIAN - os_and_arch", "[endian][abi][cpu][os]" ) {
46 const jau::endian_t byte_order = jau::endian_t::native;
47
48 std::cout << "CpuInfo: " << cpu.toString() << std::endl;
49 std::string os_and_arch = jau::os::get_os_and_arch(os, cpu.family, abi, byte_order);
50 std::cout << "- os_type: " << jau::os::to_string(os) << std::endl;
51 std::cout << "- abi_type: " << jau::os::to_string(abi) << std::endl;
52 std::cout << "- os_and_arch " << os_and_arch << std::endl << std::endl;
53
54 REQUIRE( true == jau::os::is_defined_os_type(os) );
55 REQUIRE( std::string::npos == os_and_arch.find("undef") );
56
58 REQUIRE( true == jau::is_little_or_big_endian() );
59}
60
61TEST_CASE( "Test 10 User Info", "[user][os]" ) {
62 {
64 std::cout << "User-Current: " << uinfo.toString() << std::endl;
65 REQUIRE( true == uinfo.isValid() );
66 }
67 {
68 jau::os::UserInfo uinfo("root");
69 std::cout << "User 'root': " << uinfo.toString() << std::endl;
70 // REQUIRE( true == uinfo.isValid() );
71 }
72
73}
Singleton CpuInfo caching all jau::cpu information.
Definition: cpuid.hpp:316
static const CpuInfo & get() noexcept
Returns reference to const singleton instance.
Definition: cpuid.hpp:356
cpu_family_t family
cpu_family_t derived from Architectures predefined compiler macros.
Definition: cpuid.hpp:335
std::string toString(std::string &sb, bool details_only=false) const noexcept
Definition: cpuid.cpp:393
User account information of the underlying OS.
Definition: user_info.hpp:42
bool isValid() const noexcept
Definition: user_info.hpp:77
std::string toString() const noexcept
Definition: user_info.hpp:85
constexpr bool is_defined_endian(const endian_t &v) noexcept
Evaluates true if the given endian is defined, i.e.
Definition: byte_util.hpp:275
constexpr bool is_little_or_big_endian() noexcept
Evaluates true if platform is running in little or big endian mode, i.e.
Definition: byte_util.hpp:324
endian_t
Endian identifier, indicating endianess of all scalar types.
Definition: byte_util.hpp:203
@ native
Identifier for native platform type, one of the above.
constexpr bool is_defined_os_type(const os_type_t v) noexcept
Evaluates true if the given os_type is defined, i.e.
Definition: os_support.hpp:168
os_type_t
OS type bits and unique IDs.
Definition: os_support.hpp:99
constexpr abi_type_t get_abi_type(const jau::cpu::cpu_family_t cpu) noexcept
Definition: os_support.hpp:261
std::string get_os_and_arch(const os_type_t os, const jau::cpu::cpu_family_t cpu, const abi_type_t abi, const endian_t e) noexcept
Returns the common name for the given os_type, jau::cpu::cpu_family, abi_type and endian.
Definition: os_support.cpp:105
std::string to_string(const os_type_t mask) noexcept
Return the string representation of os_type.
Definition: os_support.cpp:60
std::string get_platform_info(std::string &sb) noexcept
Definition: os_support.cpp:207
@ native
Identifier for native OS type, one of the above.
TEST_CASE("Test 00 Platform Info - os_and_arch", "[endian][abi][cpu][os]")