OSDN Git Service

Add kernel config tests
authorMark Salyzyn <salyzyn@google.com>
Wed, 10 Feb 2016 22:00:14 +0000 (14:00 -0800)
committerMark Salyzyn <salyzyn@google.com>
Wed, 10 Feb 2016 23:28:07 +0000 (15:28 -0800)
(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 [new file with mode: 0644]
tests/kernel.config/mmc_max_speed_test.cpp [new file with mode: 0644]
tests/kernel.config/multicast_test.cpp [new file with mode: 0644]
tests/kernel.config/pstore_test.cpp [new file with mode: 0644]
tests/kernel.config/sysvipc_test.cpp [new file with mode: 0644]

diff --git a/tests/kernel.config/Android.mk b/tests/kernel.config/Android.mk
new file mode 100644 (file)
index 0000000..b97ec93
--- /dev/null
@@ -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 (file)
index 0000000..40cf0d0
--- /dev/null
@@ -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 <unistd.h>
+
+#include <gtest/gtest.h>
+
+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 (file)
index 0000000..28655e8
--- /dev/null
@@ -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 <unistd.h>
+
+#include <gtest/gtest.h>
+
+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 (file)
index 0000000..1dd5e72
--- /dev/null
@@ -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 <unistd.h>
+
+#include <gtest/gtest.h>
+
+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 (file)
index 0000000..d62b91c
--- /dev/null
@@ -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 <errno.h>
+#include <linux/kcmp.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#include <gtest/gtest.h>
+
+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));
+}
+