Skip to content
Snippets Groups Projects
Commit bd8d0a2d authored by Bojian Du's avatar Bojian Du Committed by Automerger Merge Worker
Browse files

Add initial version of files to the liburingutils am: c272d862

Original change: https://android-review.googlesource.com/c/platform/system/liburingutils/+/3460992



Change-Id: I394ba9a9775095aa76477aaaa68ae25cd84d1396
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d48830b7 c272d862
No related branches found
No related tags found
No related merge requests found
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
cc_library {
name: "liburingutils",
srcs: [
"src/LibUringUtils.cpp",
],
cflags: ["-Werror"],
export_include_dirs: ["include"],
shared_libs: [
"libbase",
],
tidy: true,
tidy_checks: [
"-*",
"cert-*",
"clang-analyzer-security*",
"android-*",
],
tidy_checks_as_errors: [
"cert-*",
"clang-analyzer-security*",
"android-*",
],
}
cc_test {
name: "liburingutils_tests",
test_suites: ["device-tests"],
srcs: [
"src/LibUringUtils_test.cpp",
],
shared_libs: [
"liburingutils",
],
}
OWNERS 0 → 100644
bojiandu@google.com
sawlani@google.com
akailash@google.com
\ No newline at end of file
/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __LIBURING_UTILS_H
#define __LIBURING_UTILS_H
class LibUringUtils {
public:
static bool isIouringEnabled();
private:
static bool isIouringSupportedByKernel();
};
#endif
/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "LibUringUtils"
#include <android-base/strings.h>
#include <liburingutils/LibUringUtils.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <unistd.h>
bool LibUringUtils::isIouringEnabled() {
// TODO: b/385143770 - Change this behavior to also check the Liburing version.
return isIouringSupportedByKernel();
}
bool LibUringUtils::isIouringSupportedByKernel() {
struct utsname uts {};
unsigned int major, minor;
uname(&uts);
if (sscanf(uts.release, "%u.%u", &major, &minor) != 2) {
return false;
}
// We will only support kernels from 6.1 and higher.
return major > 6 || (major == 6 && minor >= 1);
}
/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <liburingutils/LibUringUtils.h>
#include <gtest/gtest.h>
class LibUringUtilsTest : public testing::Test {
public:
void testIsIouringEnabled(bool expectedResult) {
EXPECT_EQ(LibUringUtils::isIouringEnabled(), expectedResult);
}
};
TEST_F(LibUringUtilsTest, ReturnsIouringNotEnabled) {
// TODO: b/385143770 - Change this test to base on the real OS version,
// this default expected value is true for the binary built from the
// latest version of source code.
testIsIouringEnabled(true);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment