From 6dc80aa0c02428b3bc0aca97f7379297009d62c2 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 10 Feb 2016 14:00:14 -0800 Subject: [PATCH] Add kernel config tests (cherry pick from commit 7129c7dcd20bf57cf3a64ec224e4ebac81c8cd88) A simple start to simple day. Check for evidence of following CONFIGs: CONFIG_MMC_BLOCK_MAX_SPEED=y CONFIG_IPV6=y CONFIG_IP_MULTICAST=y CONFIG_PSTORE=y CONFIG_PSTORE_CONSOLE=y CONFIG_PSTORE_PMSG=y CONFIG_SYSVIPC is not set ToDo: Evidence for all configs in android/configs/android-base.cfg and android/configs/android-recommended.cfg. Most are not possible to directly discover, this is performed on a best effort basis. Bug: 19173869 Bug: 26559308 Change-Id: I0447334fab7781579fab10610d2f7ac1d34e6044 --- tests/kernel.config/Android.mk | 29 +++++++++++++++++++++++++ tests/kernel.config/mmc_max_speed_test.cpp | 24 ++++++++++++++++++++ tests/kernel.config/multicast_test.cpp | 26 ++++++++++++++++++++++ tests/kernel.config/pstore_test.cpp | 32 +++++++++++++++++++++++++++ tests/kernel.config/sysvipc_test.cpp | 35 ++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+) create mode 100644 tests/kernel.config/Android.mk create mode 100644 tests/kernel.config/mmc_max_speed_test.cpp create mode 100644 tests/kernel.config/multicast_test.cpp create mode 100644 tests/kernel.config/pstore_test.cpp create mode 100644 tests/kernel.config/sysvipc_test.cpp diff --git a/tests/kernel.config/Android.mk b/tests/kernel.config/Android.mk new file mode 100644 index 00000000..b97ec939 --- /dev/null +++ b/tests/kernel.config/Android.mk @@ -0,0 +1,29 @@ +# Copyright 2016 The Android Open Source Project + +LOCAL_PATH:= $(call my-dir) + +# ----------------------------------------------------------------------------- +# Unit tests. +# ----------------------------------------------------------------------------- + +test_c_flags := \ + -fstack-protector-all \ + -g \ + -Wall -Wextra \ + -Werror \ + -fno-builtin \ + -std=gnu++11 + +test_src_files := \ + multicast_test.cpp \ + mmc_max_speed_test.cpp \ + pstore_test.cpp \ + sysvipc_test.cpp + +include $(CLEAR_VARS) +LOCAL_MODULE := kernel-config-unit-tests +LOCAL_MODULE_TAGS := tests +LOCAL_CFLAGS += $(test_c_flags) +LOCAL_SRC_FILES := $(test_src_files) +include $(BUILD_NATIVE_TEST) + diff --git a/tests/kernel.config/mmc_max_speed_test.cpp b/tests/kernel.config/mmc_max_speed_test.cpp new file mode 100644 index 00000000..40cf0d07 --- /dev/null +++ b/tests/kernel.config/mmc_max_speed_test.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2016 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 + +#include + +TEST(kernel_config, CONFIG_MMC_BLOCK_MAX_SPEED) { + EXPECT_EQ(0, access("/sys/block/mmcblk0/max_read_speed", F_OK)); + EXPECT_EQ(0, access("/sys/block/mmcblk0/max_write_speed", F_OK)); + EXPECT_EQ(0, access("/sys/block/mmcblk0/cache_size", F_OK)); +} diff --git a/tests/kernel.config/multicast_test.cpp b/tests/kernel.config/multicast_test.cpp new file mode 100644 index 00000000..28655e81 --- /dev/null +++ b/tests/kernel.config/multicast_test.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2016 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 + +#include + +TEST(kernel_config, CONFIG_IPV6) { + EXPECT_EQ(0, access("/proc/net/igmp6", F_OK)); +} + +TEST(kernel_config, CONFIG_IP_MULTICAST) { + EXPECT_EQ(0, access("/proc/net/igmp", F_OK)); +} diff --git a/tests/kernel.config/pstore_test.cpp b/tests/kernel.config/pstore_test.cpp new file mode 100644 index 00000000..1dd5e728 --- /dev/null +++ b/tests/kernel.config/pstore_test.cpp @@ -0,0 +1,32 @@ + +/* + * Copyright (C) 2016 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 + +#include + +TEST(kernel_config, CONFIG_PSTORE) { + EXPECT_EQ(0, access("/sys/fs/pstore", F_OK)); +} + +TEST(kernel_config, CONFIG_PSTORE_CONSOLE) { + EXPECT_EQ(0, access("/sys/fs/pstore/console-ramoops", F_OK)); +} + +TEST(kernel_config, CONFIG_PSTORE_PMSG) { + EXPECT_EQ(0, access("/dev/pmsg0", F_OK)); + EXPECT_EQ(0, access("/sys/fs/pstore/pmsg-ramoops-0", F_OK)); +} diff --git a/tests/kernel.config/sysvipc_test.cpp b/tests/kernel.config/sysvipc_test.cpp new file mode 100644 index 00000000..d62b91cc --- /dev/null +++ b/tests/kernel.config/sysvipc_test.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 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 +#include +#include +#include + +#include + +int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { + return syscall(SYS_kcmp, pid1, pid2, type, 0, idx1, idx2); +} + +TEST(kernel_config, NOT_CONFIG_SYSVIPC) { + pid_t pid = getpid(); + int ret = kcmp(pid, pid, KCMP_SYSVSEM, 0, 0); + int error = (ret == -1) ? (errno == ENOSYS) ? EOPNOTSUPP : errno : 0; + EXPECT_EQ(-1, kcmp(pid, pid, KCMP_SYSVSEM, 0, 0)); + EXPECT_EQ(EOPNOTSUPP, error); + EXPECT_EQ(-1, access("/proc/sysvipc", F_OK)); +} + -- 2.11.0