OSDN Git Service

cts: android.kernel.config
authorMark Salyzyn <salyzyn@google.com>
Thu, 11 Feb 2016 22:20:24 +0000 (14:20 -0800)
committerMark Salyzyn <salyzyn@google.com>
Fri, 12 Feb 2016 16:23:37 +0000 (08:23 -0800)
- Added plumbing for CTS tests
- Divide Required into CTS and gTest and
  Recommended into gTest
- Added check of CONFIG_ANDROID_LOGGER
- test typically completes after 3ms

Bug: 19173869
Change-Id: I13a92081bfa9b53abb69923b160b82e3be2142ab

tests/kernel.config/Android.mk
tests/kernel.config/AndroidTest.xml [new file with mode: 0644]
tests/kernel.config/logger_test.cpp [new file with mode: 0644]
tests/kernel.config/sysvipc_test.cpp

index b97ec93..7a02521 100644 (file)
@@ -14,16 +14,57 @@ test_c_flags := \
     -fno-builtin \
     -std=gnu++11
 
-test_src_files := \
+# Required Tests
+cts_src_files := \
     multicast_test.cpp \
-    mmc_max_speed_test.cpp \
     pstore_test.cpp \
-    sysvipc_test.cpp
+    sysvipc_test.cpp \
+    logger_test.cpp
+
+# Required plus Recommended Tests
+test_src_files := \
+    $(cts_src_files) \
+    mmc_max_speed_test.cpp \
+
+cts_executable := CtsKernelConfigTestCases
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := kernel-config-unit-tests
 LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS += $(test_c_flags)
+LOCAL_CFLAGS := $(test_c_flags)
+LOCAL_CFLAGS := -DHAS_KCMP
 LOCAL_SRC_FILES := $(test_src_files)
 include $(BUILD_NATIVE_TEST)
 
+include $(CLEAR_VARS)
+LOCAL_MODULE := $(cts_executable)
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := $(test_c_flags)
+LOCAL_CFLAGS := -DHAS_KCMP
+LOCAL_SRC_FILES := $(cts_src_files)
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
+
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+LOCAL_CTS_TEST_PACKAGE := android.kernel.config
+include $(BUILD_CTS_EXECUTABLE)
+
+ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := $(cts_executable)_list
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := $(test_c_flags)
+LOCAL_C_INCLUDES := external/gtest/include
+LOCAL_SRC_FILES := $(cts_src_files)
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_CXX_STL := libc++
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+include $(BUILD_HOST_NATIVE_TEST)
+
+endif  # ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
diff --git a/tests/kernel.config/AndroidTest.xml b/tests/kernel.config/AndroidTest.xml
new file mode 100644 (file)
index 0000000..4fe3192
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for CTS Kernel Config test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="cleanup" value="true" />
+        <option name="push" value="CtsKernelConfigTestCases->/data/local/tmp/CtsKernelConfigTestCases" />
+        <option name="append-bitness" value="true" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.GTest" >
+        <option name="native-test-device-path" value="/data/local/tmp" />
+        <option name="module-name" value="CtsKernelConfigTestCases" />
+    </test>
+</configuration>
diff --git a/tests/kernel.config/logger_test.cpp b/tests/kernel.config/logger_test.cpp
new file mode 100644 (file)
index 0000000..f0874d8
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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, NOT_CONFIG_ANDROID_LOGGER) {
+  EXPECT_NE(0, access("/dev/log/main", F_OK));
+  EXPECT_NE(0, access("/dev/log_main", F_OK));
+  EXPECT_NE(0, access("/dev/log/radio", F_OK));
+  EXPECT_NE(0, access("/dev/log_radio", F_OK));
+  EXPECT_NE(0, access("/dev/log/events", F_OK));
+  EXPECT_NE(0, access("/dev/log_events", F_OK));
+  EXPECT_NE(0, access("/dev/log/system", F_OK));
+  EXPECT_NE(0, access("/dev/log_system", F_OK));
+}
index d62b91c..49952f0 100644 (file)
  * limitations under the License.
  */
 #include <errno.h>
+#ifdef HAS_KCMP
 #include <linux/kcmp.h>
 #include <sys/syscall.h>
+#endif
 #include <unistd.h>
 
 #include <gtest/gtest.h>
 
+#ifdef HAS_KCMP
 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);
 }
+#endif
 
 TEST(kernel_config, NOT_CONFIG_SYSVIPC) {
+#ifdef HAS_KCMP
   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);
+#endif
   EXPECT_EQ(-1, access("/proc/sysvipc", F_OK));
+  EXPECT_EQ(-1, access("/proc/sysvipc/msg", F_OK));
+  EXPECT_EQ(-1, access("/proc/sysvipc/sem", F_OK));
+  EXPECT_EQ(-1, access("/proc/sysvipc/shm", F_OK));
 }