Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935192AbcCPP1F (ORCPT ); Wed, 16 Mar 2016 11:27:05 -0400 Received: from lists.s-osg.org ([54.187.51.154]:54185 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935092AbcCPP1D (ORCPT ); Wed, 16 Mar 2016 11:27:03 -0400 To: Linus Torvalds Cc: Michal Marek , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan From: Shuah Khan Subject: [GIT PULL] Kselftest updates for 4.6-rc1 Organization: Samsung Open Source Group Message-ID: <56E97B43.30701@osg.samsung.com> Date: Wed, 16 Mar 2016 09:26:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030904030405020100040105" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 18435 Lines: 648 This is a multi-part message in MIME format. --------------030904030405020100040105 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Linus, Please pull the following update for 4.6-rc1. diff attached. thanks, -- Shuah --------------------------------------------------------------------------------- The following changes since commit 92e963f50fc74041b5e9e744c330dca48e04f08d: Linux 4.5-rc1 (2016-01-24 13:06:47 -0800) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-4.6-rc1 for you to fetch changes up to 6accd8e9bf22749f621fb7fb57995fa65f4cd873: selftests: media_dcevice_test fix usage information (2016-02-25 17:22:42 -0700) ---------------------------------------------------------------- linux-kselftest-4.6-rc1 This update for Kselftest adds: - A new feature to create test-specific kconfig fragments. This feature helps configure Kselftests to test specific Kernel Configuration options as opposed to defconfig. - A new test for Media Controller API - A few fixes ---------------------------------------------------------------- Bamvor Jian Zhang (2): selftests: create test-specific kconfig fragments Makefile: add kselftest-merge Greg Hackmann (1): selftests: breakpoint: add step_after_suspend_test Shuah Khan (3): selftests: add a new test for Media Controller API selftests: media_dcevice_test fix to handle ioctl failure case selftests: media_dcevice_test fix usage information Sudeep Holla (1): selftests: add missing .gitignore file or entry Makefile | 10 + tools/testing/selftests/breakpoints/.gitignore | 1 + tools/testing/selftests/breakpoints/Makefile | 4 +- .../breakpoints/step_after_suspend_test.c | 218 +++++++++++++++++++++ tools/testing/selftests/cpu-hotplug/config | 2 + tools/testing/selftests/firmware/config | 1 + tools/testing/selftests/ftrace/config | 1 + tools/testing/selftests/ipc/.gitignore | 1 + tools/testing/selftests/ipc/config | 2 + tools/testing/selftests/media_tests/.gitignore | 1 + tools/testing/selftests/media_tests/Makefile | 7 + .../selftests/media_tests/media_device_test.c | 95 +++++++++ tools/testing/selftests/memory-hotplug/config | 4 + tools/testing/selftests/mount/config | 2 + tools/testing/selftests/net/config | 3 + tools/testing/selftests/pstore/config | 4 + tools/testing/selftests/seccomp/config | 2 + tools/testing/selftests/static_keys/config | 1 + tools/testing/selftests/user/config | 1 + tools/testing/selftests/vm/config | 1 + tools/testing/selftests/zram/config | 2 + 21 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/breakpoints/step_after_suspend_test.c create mode 100644 tools/testing/selftests/cpu-hotplug/config create mode 100644 tools/testing/selftests/firmware/config create mode 100644 tools/testing/selftests/ftrace/config create mode 100644 tools/testing/selftests/ipc/.gitignore create mode 100644 tools/testing/selftests/ipc/config create mode 100644 tools/testing/selftests/media_tests/.gitignore create mode 100644 tools/testing/selftests/media_tests/Makefile create mode 100644 tools/testing/selftests/media_tests/media_device_test.c create mode 100644 tools/testing/selftests/memory-hotplug/config create mode 100644 tools/testing/selftests/mount/config create mode 100644 tools/testing/selftests/net/config create mode 100644 tools/testing/selftests/pstore/config create mode 100644 tools/testing/selftests/seccomp/config create mode 100644 tools/testing/selftests/static_keys/config create mode 100644 tools/testing/selftests/user/config create mode 100644 tools/testing/selftests/vm/config create mode 100644 tools/testing/selftests/zram/config --------------------------------------------------------------------------------- -- Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shuahkh@osg.samsung.com | (970) 217-8978 --------------030904030405020100040105 Content-Type: text/x-diff; name="4.6-rc1_pull_req.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="4.6-rc1_pull_req.diff" diff --git a/Makefile b/Makefile index c65fe37..42e3d1e1 100644 --- a/Makefile +++ b/Makefile @@ -1087,6 +1087,14 @@ kselftest: kselftest-clean: $(Q)$(MAKE) -C tools/testing/selftests clean =20 +PHONY +=3D kselftest-merge +kselftest-merge: + $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config= your kernel first!)) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ + -m $(objtree)/.config \ + $(srctree)/tools/testing/selftests/*/config + +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig + # ----------------------------------------------------------------------= ----- # Modules =20 @@ -1295,6 +1303,8 @@ help: @echo ' Build, install, and boot kernel before' @echo ' running kselftest on it' @echo ' kselftest-clean - Remove all generated kselftest files' + @echo ' kselftest-merge - Merge all the config dependencies of kselft= est to existed' + @echo ' .config.' @echo '' @echo 'Kernel packaging:' @$(MAKE) $(build)=3D$(package-dir) help diff --git a/tools/testing/selftests/breakpoints/.gitignore b/tools/testi= ng/selftests/breakpoints/.gitignore index 9b3193d0..a23bb4a 100644 --- a/tools/testing/selftests/breakpoints/.gitignore +++ b/tools/testing/selftests/breakpoints/.gitignore @@ -1 +1,2 @@ breakpoint_test +step_after_suspend_test diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing= /selftests/breakpoints/Makefile index c0d9570..74e533f 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile @@ -6,9 +6,11 @@ ifeq ($(ARCH),x86) TEST_PROGS :=3D breakpoint_test endif =20 +TEST_PROGS +=3D step_after_suspend_test + all: $(TEST_PROGS) =20 include ../lib.mk =20 clean: - rm -fr breakpoint_test + rm -fr breakpoint_test step_after_suspend_test diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.= c b/tools/testing/selftests/breakpoints/step_after_suspend_test.c new file mode 100644 index 0000000..60b8a95 --- /dev/null +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2016 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../kselftest.h" + +void child(int cpu) +{ + cpu_set_t set; + + CPU_ZERO(&set); + CPU_SET(cpu, &set); + if (sched_setaffinity(0, sizeof(set), &set) !=3D 0) { + perror("sched_setaffinity() failed"); + _exit(1); + } + + if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) !=3D 0) { + perror("ptrace(PTRACE_TRACEME) failed"); + _exit(1); + } + + if (raise(SIGSTOP) !=3D 0) { + perror("raise(SIGSTOP) failed"); + _exit(1); + } + + _exit(0); +} + +bool run_test(int cpu) +{ + int status; + pid_t pid =3D fork(); + pid_t wpid; + + if (pid < 0) { + perror("fork() failed"); + return false; + } + if (pid =3D=3D 0) + child(cpu); + + wpid =3D waitpid(pid, &status, __WALL); + if (wpid !=3D pid) { + perror("waitpid() failed"); + return false; + } + if (!WIFSTOPPED(status)) { + printf("child did not stop\n"); + return false; + } + if (WSTOPSIG(status) !=3D SIGSTOP) { + printf("child did not stop with SIGSTOP\n"); + return false; + } + + if (ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL) < 0) { + if (errno =3D=3D EIO) { + printf("ptrace(PTRACE_SINGLESTEP) not supported on this architecture\= n"); + ksft_exit_skip(); + } + perror("ptrace(PTRACE_SINGLESTEP) failed"); + return false; + } + + wpid =3D waitpid(pid, &status, __WALL); + if (wpid !=3D pid) { + perror("waitpid() failed"); + return false; + } + if (WIFEXITED(status)) { + printf("child did not single-step\n"); + return false; + } + if (!WIFSTOPPED(status)) { + printf("child did not stop\n"); + return false; + } + if (WSTOPSIG(status) !=3D SIGTRAP) { + printf("child did not stop with SIGTRAP\n"); + return false; + } + + if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) { + perror("ptrace(PTRACE_CONT) failed"); + return false; + } + + wpid =3D waitpid(pid, &status, __WALL); + if (wpid !=3D pid) { + perror("waitpid() failed"); + return false; + } + if (!WIFEXITED(status)) { + printf("child did not exit after PTRACE_CONT\n"); + return false; + } + + return true; +} + +void suspend(void) +{ + int power_state_fd; + struct sigevent event =3D {}; + int timerfd; + int err; + struct itimerspec spec =3D {}; + + power_state_fd =3D open("/sys/power/state", O_RDWR); + if (power_state_fd < 0) { + perror("open(\"/sys/power/state\") failed (is this test running as roo= t?)"); + ksft_exit_fail(); + } + + timerfd =3D timerfd_create(CLOCK_BOOTTIME_ALARM, 0); + if (timerfd < 0) { + perror("timerfd_create() failed"); + ksft_exit_fail(); + } + + spec.it_value.tv_sec =3D 5; + err =3D timerfd_settime(timerfd, 0, &spec, NULL); + if (err < 0) { + perror("timerfd_settime() failed"); + ksft_exit_fail(); + } + + if (write(power_state_fd, "mem", strlen("mem")) !=3D strlen("mem")) { + perror("entering suspend failed"); + ksft_exit_fail(); + } + + close(timerfd); + close(power_state_fd); +} + +int main(int argc, char **argv) +{ + int opt; + bool do_suspend =3D true; + bool succeeded =3D true; + cpu_set_t available_cpus; + int err; + int cpu; + + while ((opt =3D getopt(argc, argv, "n")) !=3D -1) { + switch (opt) { + case 'n': + do_suspend =3D false; + break; + default: + printf("Usage: %s [-n]\n", argv[0]); + printf(" -n: do not trigger a suspend/resume cycle before the = test\n"); + return -1; + } + } + + if (do_suspend) + suspend(); + + err =3D sched_getaffinity(0, sizeof(available_cpus), &available_cpus); + if (err < 0) { + perror("sched_getaffinity() failed"); + ksft_exit_fail(); + } + + for (cpu =3D 0; cpu < CPU_SETSIZE; cpu++) { + bool test_success; + + if (!CPU_ISSET(cpu, &available_cpus)) + continue; + + test_success =3D run_test(cpu); + printf("CPU %d: ", cpu); + if (test_success) { + printf("[OK]\n"); + ksft_inc_pass_cnt(); + } else { + printf("[FAILED]\n"); + ksft_inc_fail_cnt(); + succeeded =3D false; + } + } + + ksft_print_cnts(); + if (succeeded) + ksft_exit_pass(); + else + ksft_exit_fail(); +} diff --git a/tools/testing/selftests/cpu-hotplug/config b/tools/testing/s= elftests/cpu-hotplug/config new file mode 100644 index 0000000..e6ab090 --- /dev/null +++ b/tools/testing/selftests/cpu-hotplug/config @@ -0,0 +1,2 @@ +CONFIG_NOTIFIER_ERROR_INJECTION=3Dy +CONFIG_CPU_NOTIFIER_ERROR_INJECT=3Dm diff --git a/tools/testing/selftests/firmware/config b/tools/testing/self= tests/firmware/config new file mode 100644 index 0000000..c8137f7 --- /dev/null +++ b/tools/testing/selftests/firmware/config @@ -0,0 +1 @@ +CONFIG_TEST_FIRMWARE=3Dy diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selfte= sts/ftrace/config new file mode 100644 index 0000000..ef82146 --- /dev/null +++ b/tools/testing/selftests/ftrace/config @@ -0,0 +1 @@ +CONFIG_FTRACE=3Dy diff --git a/tools/testing/selftests/ipc/.gitignore b/tools/testing/selft= ests/ipc/.gitignore new file mode 100644 index 0000000..84b66a3 --- /dev/null +++ b/tools/testing/selftests/ipc/.gitignore @@ -0,0 +1 @@ +msgque_test diff --git a/tools/testing/selftests/ipc/config b/tools/testing/selftests= /ipc/config new file mode 100644 index 0000000..0702447 --- /dev/null +++ b/tools/testing/selftests/ipc/config @@ -0,0 +1,2 @@ +CONFIG_EXPERT=3Dy +CONFIG_CHECKPOINT_RESTORE=3Dy diff --git a/tools/testing/selftests/media_tests/.gitignore b/tools/testi= ng/selftests/media_tests/.gitignore new file mode 100644 index 0000000..1c07117 --- /dev/null +++ b/tools/testing/selftests/media_tests/.gitignore @@ -0,0 +1 @@ +media_device_test diff --git a/tools/testing/selftests/media_tests/Makefile b/tools/testing= /selftests/media_tests/Makefile new file mode 100644 index 0000000..7071bcc --- /dev/null +++ b/tools/testing/selftests/media_tests/Makefile @@ -0,0 +1,7 @@ +TEST_PROGS :=3D media_device_test +all: $(TEST_PROGS) + +include ../lib.mk + +clean: + rm -fr media_device_test diff --git a/tools/testing/selftests/media_tests/media_device_test.c b/to= ols/testing/selftests/media_tests/media_device_test.c new file mode 100644 index 0000000..cbf53a0 --- /dev/null +++ b/tools/testing/selftests/media_tests/media_device_test.c @@ -0,0 +1,95 @@ +/* + * media_devkref_test.c - Media Controller Device Kref API Test + * + * Copyright (c) 2016 Shuah Khan + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * This file is released under the GPLv2. + */ + +/* + * This file adds a test for Media Controller API. + * This test should be run as root and should not be + * included in the Kselftest run. This test should be + * run when hardware and driver that makes use Media + * Controller API are present in the system. + * + * This test opens user specified Media Device and calls + * MEDIA_IOC_DEVICE_INFO ioctl in a loop once every 10 + * seconds. + * + * Usage: + * sudo ./media_device_test -d /dev/mediaX + * + * While test is running, remove the device and + * ensure there are no use after free errors and + * other Oops in the dmesg. Enable KaSan kernel + * config option for use-after-free error detection. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int opt; + char media_device[256]; + int count =3D 0; + struct media_device_info mdi; + int ret; + int fd; + + if (argc < 2) { + printf("Usage: %s [-d ]\n", argv[0]); + exit(-1); + } + + /* Process arguments */ + while ((opt =3D getopt(argc, argv, "d:")) !=3D -1) { + switch (opt) { + case 'd': + strncpy(media_device, optarg, sizeof(media_device) - 1); + media_device[sizeof(media_device)-1] =3D '\0'; + break; + default: + printf("Usage: %s [-d ]\n", argv[0]); + exit(-1); + } + } + + if (getuid() !=3D 0) { + printf("Please run the test as root - Exiting.\n"); + exit(-1); + } + + /* Open Media device and keep it open */ + fd =3D open(media_device, O_RDWR); + if (fd =3D=3D -1) { + printf("Media Device open errno %s\n", strerror(errno)); + exit(-1); + } + + printf("\nNote:\n" + "While test is running, remove the device and\n" + "ensure there are no use after free errors and\n" + "other Oops in the dmesg. Enable KaSan kernel\n" + "config option for use-after-free error detection.\n\n"); + + while (count < 100) { + ret =3D ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi); + if (ret < 0) + printf("Media Device Info errno %s\n", strerror(errno)); + else + printf("Media device model %s driver %s\n", + mdi.model, mdi.driver); + sleep(10); + count++; + } +} diff --git a/tools/testing/selftests/memory-hotplug/config b/tools/testin= g/selftests/memory-hotplug/config new file mode 100644 index 0000000..2fde301 --- /dev/null +++ b/tools/testing/selftests/memory-hotplug/config @@ -0,0 +1,4 @@ +CONFIG_MEMORY_HOTPLUG=3Dy +CONFIG_MEMORY_HOTPLUG_SPARSE=3Dy +CONFIG_NOTIFIER_ERROR_INJECTION=3Dy +CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=3Dm diff --git a/tools/testing/selftests/mount/config b/tools/testing/selftes= ts/mount/config new file mode 100644 index 0000000..b5d881e --- /dev/null +++ b/tools/testing/selftests/mount/config @@ -0,0 +1,2 @@ +CONFIG_USER_NS=3Dy +CONFIG_DEVPTS_MULTIPLE_INSTANCES=3Dy diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests= /net/config new file mode 100644 index 0000000..e57b4ac --- /dev/null +++ b/tools/testing/selftests/net/config @@ -0,0 +1,3 @@ +CONFIG_USER_NS=3Dy +CONFIG_BPF_SYSCALL=3Dy +CONFIG_TEST_BPF=3Dm diff --git a/tools/testing/selftests/pstore/config b/tools/testing/selfte= sts/pstore/config new file mode 100644 index 0000000..6a8e5a9 --- /dev/null +++ b/tools/testing/selftests/pstore/config @@ -0,0 +1,4 @@ +CONFIG_MISC_FILESYSTEMS=3Dy +CONFIG_PSTORE=3Dy +CONFIG_PSTORE_PMSG=3Dy +CONFIG_PSTORE_CONSOLE=3Dy diff --git a/tools/testing/selftests/seccomp/config b/tools/testing/selft= ests/seccomp/config new file mode 100644 index 0000000..db1e11b --- /dev/null +++ b/tools/testing/selftests/seccomp/config @@ -0,0 +1,2 @@ +CONFIG_SECCOMP=3Dy +CONFIG_SECCOMP_FILTER=3Dy diff --git a/tools/testing/selftests/static_keys/config b/tools/testing/s= elftests/static_keys/config new file mode 100644 index 0000000..d538fb7 --- /dev/null +++ b/tools/testing/selftests/static_keys/config @@ -0,0 +1 @@ +CONFIG_TEST_STATIC_KEYS=3Dm diff --git a/tools/testing/selftests/user/config b/tools/testing/selftest= s/user/config new file mode 100644 index 0000000..784ed84 --- /dev/null +++ b/tools/testing/selftests/user/config @@ -0,0 +1 @@ +CONFIG_TEST_USER_COPY=3Dm diff --git a/tools/testing/selftests/vm/config b/tools/testing/selftests/= vm/config new file mode 100644 index 0000000..698c7ed --- /dev/null +++ b/tools/testing/selftests/vm/config @@ -0,0 +1 @@ +CONFIG_USERFAULTFD=3Dy diff --git a/tools/testing/selftests/zram/config b/tools/testing/selftest= s/zram/config new file mode 100644 index 0000000..e0cc47e --- /dev/null +++ b/tools/testing/selftests/zram/config @@ -0,0 +1,2 @@ +CONFIG_ZSMALLOC=3Dy +CONFIG_ZRAM=3Dm --------------030904030405020100040105--