Commit 4541fec3 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'linux-kselftest-4.1-rc1' of...

Merge tag 'linux-kselftest-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:
 "This is a milestone update in a sense.  Several new tests and install
  and packaging support is added in this update.

  This update adds install and packaging tools developed on top of
  back-end shared logic enhancemnets to run and install tests.  In
  addition several timer tests are added.

   - New timer tests from John Stultz

   - rtc test from Prarit Bhargava

   - Enhancements to un and install tests from Michael Ellerman

   - Install and packaging tools from Shuah Khan

   - Cross-compilation enablement from Tyler Baker

   - A couple of bug fixes"

* tag 'linux-kselftest-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (42 commits)
  ftracetest: Do not use usleep directly
  selftest/mqueue: enable cross compilation
  selftest/ipc: enable cross compilation
  selftest/memfd: include default header install path
  selftest/mount: enable cross compilation
  selftest/memfd: enable cross compilation
  kselftests: timers: Make set-timer-lat fail more gracefully for !CAP_WAKE_ALARM
  selftests: Change memory on-off-test.sh name to be unique
  selftests: change cpu on-off-test.sh name to be unique
  selftests/mount: Make git ignore all binaries in mount test suite
  kselftests: timers: Reduce default runtime on inconsistency-check and set-timer-lat
  ftracetest: Convert exit -1 to exit $FAIL
  ftracetest: Cope properly with stack tracer not being enabled
  tools, update rtctest.c to verify passage of time
  Documentation, split up rtc.txt into documentation and test file
  selftests: Add tool to generate kselftest tar archive
  selftests: Add kselftest install tool
  selftests: Set CC using CROSS_COMPILE once in lib.mk
  selftests: Add install support for the powerpc tests
  selftests/timers: Use shared logic to run and install tests
  ...
parents 39a88044 2bfd4d1f
......@@ -204,266 +204,4 @@ Some common examples:
* RTC_PIE_ON, RTC_PIE_OFF: These are also emulated by the generic code.
If all else fails, check out the rtc-test.c driver!
-------------------- 8< ---------------- 8< -----------------------------
/*
* Real Time Clock Driver Test/Example Program
*
* Compile with:
* gcc -s -Wall -Wstrict-prototypes rtctest.c -o rtctest
*
* Copyright (C) 1996, Paul Gortmaker.
*
* Released under the GNU General Public License, version 2,
* included herein by reference.
*
*/
#include <stdio.h>
#include <linux/rtc.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
/*
* This expects the new RTC class driver framework, working with
* clocks that will often not be clones of what the PC-AT had.
* Use the command line to specify another RTC if you need one.
*/
static const char default_rtc[] = "/dev/rtc0";
int main(int argc, char **argv)
{
int i, fd, retval, irqcount = 0;
unsigned long tmp, data;
struct rtc_time rtc_tm;
const char *rtc = default_rtc;
switch (argc) {
case 2:
rtc = argv[1];
/* FALLTHROUGH */
case 1:
break;
default:
fprintf(stderr, "usage: rtctest [rtcdev]\n");
return 1;
}
fd = open(rtc, O_RDONLY);
if (fd == -1) {
perror(rtc);
exit(errno);
}
fprintf(stderr, "\n\t\t\tRTC Driver Test Example.\n\n");
/* Turn on update interrupts (one per second) */
retval = ioctl(fd, RTC_UIE_ON, 0);
if (retval == -1) {
if (errno == ENOTTY) {
fprintf(stderr,
"\n...Update IRQs not supported.\n");
goto test_READ;
}
perror("RTC_UIE_ON ioctl");
exit(errno);
}
fprintf(stderr, "Counting 5 update (1/sec) interrupts from reading %s:",
rtc);
fflush(stderr);
for (i=1; i<6; i++) {
/* This read will block */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1) {
perror("read");
exit(errno);
}
fprintf(stderr, " %d",i);
fflush(stderr);
irqcount++;
}
fprintf(stderr, "\nAgain, from using select(2) on /dev/rtc:");
fflush(stderr);
for (i=1; i<6; i++) {
struct timeval tv = {5, 0}; /* 5 second timeout on select */
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
/* The select will wait until an RTC interrupt happens. */
retval = select(fd+1, &readfds, NULL, NULL, &tv);
if (retval == -1) {
perror("select");
exit(errno);
}
/* This read won't block unlike the select-less case above. */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1) {
perror("read");
exit(errno);
}
fprintf(stderr, " %d",i);
fflush(stderr);
irqcount++;
}
/* Turn off update interrupts */
retval = ioctl(fd, RTC_UIE_OFF, 0);
if (retval == -1) {
perror("RTC_UIE_OFF ioctl");
exit(errno);
}
test_READ:
/* Read the RTC time/date */
retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
if (retval == -1) {
perror("RTC_RD_TIME ioctl");
exit(errno);
}
fprintf(stderr, "\n\nCurrent RTC date/time is %d-%d-%d, %02d:%02d:%02d.\n",
rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900,
rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
/* Set the alarm to 5 sec in the future, and check for rollover */
rtc_tm.tm_sec += 5;
if (rtc_tm.tm_sec >= 60) {
rtc_tm.tm_sec %= 60;
rtc_tm.tm_min++;
}
if (rtc_tm.tm_min == 60) {
rtc_tm.tm_min = 0;
rtc_tm.tm_hour++;
}
if (rtc_tm.tm_hour == 24)
rtc_tm.tm_hour = 0;
retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
if (retval == -1) {
if (errno == ENOTTY) {
fprintf(stderr,
"\n...Alarm IRQs not supported.\n");
goto test_PIE;
}
perror("RTC_ALM_SET ioctl");
exit(errno);
}
/* Read the current alarm settings */
retval = ioctl(fd, RTC_ALM_READ, &rtc_tm);
if (retval == -1) {
perror("RTC_ALM_READ ioctl");
exit(errno);
}
fprintf(stderr, "Alarm time now set to %02d:%02d:%02d.\n",
rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
/* Enable alarm interrupts */
retval = ioctl(fd, RTC_AIE_ON, 0);
if (retval == -1) {
perror("RTC_AIE_ON ioctl");
exit(errno);
}
fprintf(stderr, "Waiting 5 seconds for alarm...");
fflush(stderr);
/* This blocks until the alarm ring causes an interrupt */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1) {
perror("read");
exit(errno);
}
irqcount++;
fprintf(stderr, " okay. Alarm rang.\n");
/* Disable alarm interrupts */
retval = ioctl(fd, RTC_AIE_OFF, 0);
if (retval == -1) {
perror("RTC_AIE_OFF ioctl");
exit(errno);
}
test_PIE:
/* Read periodic IRQ rate */
retval = ioctl(fd, RTC_IRQP_READ, &tmp);
if (retval == -1) {
/* not all RTCs support periodic IRQs */
if (errno == ENOTTY) {
fprintf(stderr, "\nNo periodic IRQ support\n");
goto done;
}
perror("RTC_IRQP_READ ioctl");
exit(errno);
}
fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp);
fprintf(stderr, "Counting 20 interrupts at:");
fflush(stderr);
/* The frequencies 128Hz, 256Hz, ... 8192Hz are only allowed for root. */
for (tmp=2; tmp<=64; tmp*=2) {
retval = ioctl(fd, RTC_IRQP_SET, tmp);
if (retval == -1) {
/* not all RTCs can change their periodic IRQ rate */
if (errno == ENOTTY) {
fprintf(stderr,
"\n...Periodic IRQ rate is fixed\n");
goto done;
}
perror("RTC_IRQP_SET ioctl");
exit(errno);
}
fprintf(stderr, "\n%ldHz:\t", tmp);
fflush(stderr);
/* Enable periodic interrupts */
retval = ioctl(fd, RTC_PIE_ON, 0);
if (retval == -1) {
perror("RTC_PIE_ON ioctl");
exit(errno);
}
for (i=1; i<21; i++) {
/* This blocks */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1) {
perror("read");
exit(errno);
}
fprintf(stderr, " %d",i);
fflush(stderr);
irqcount++;
}
/* Disable periodic interrupts */
retval = ioctl(fd, RTC_PIE_OFF, 0);
if (retval == -1) {
perror("RTC_PIE_OFF ioctl");
exit(errno);
}
}
done:
fprintf(stderr, "\n\n\t\t\t *** Test complete ***\n");
close(fd);
return 0;
}
If all else fails, check out the tools/testing/selftests/timers/rtctest.c test!
......@@ -8559,6 +8559,7 @@ F: include/uapi/linux/timex.h
F: kernel/time/clocksource.c
F: kernel/time/time*.c
F: kernel/time/ntp.c
F: tools/testing/selftests/timers/
SC1200 WDT DRIVER
M: Zwane Mwaikambo <zwanem@gmail.com>
......
......@@ -55,7 +55,40 @@ clean_hotplug:
make -C $$TARGET clean; \
done;
INSTALL_PATH ?= install
INSTALL_PATH := $(abspath $(INSTALL_PATH))
ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
install:
ifdef INSTALL_PATH
@# Ask all targets to install their files
mkdir -p $(INSTALL_PATH)
for TARGET in $(TARGETS); do \
mkdir -p $(INSTALL_PATH)/$$TARGET ; \
make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
done;
@# Ask all targets to emit their test scripts
echo "#!/bin/bash" > $(ALL_SCRIPT)
echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
for TARGET in $(TARGETS); do \
echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
echo "echo ========================================" >> $(ALL_SCRIPT); \
echo "cd $$TARGET" >> $(ALL_SCRIPT); \
make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
done;
chmod u+x $(ALL_SCRIPT)
else
$(error Error: set INSTALL_PATH to use install)
endif
clean:
for TARGET in $(TARGETS); do \
make -C $$TARGET clean; \
done;
.PHONY: install
......@@ -16,8 +16,9 @@ else
echo "Not an x86 target, can't build breakpoints selftests"
endif
run_tests:
@./breakpoint_test || echo "breakpoints selftests: [FAIL]"
TEST_PROGS := breakpoint_test
include ../lib.mk
clean:
rm -fr breakpoint_test
all:
run_tests:
@/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
TEST_PROGS := cpu-on-off-test.sh
include ../lib.mk
run_full_test:
@/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
@/bin/bash ./cpu-on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
clean:
CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall
test_objs = open-unlink create-read
all: $(test_objs)
run_tests: all
@/bin/bash ./efivarfs.sh || echo "efivarfs selftests: [FAIL]"
TEST_PROGS := efivarfs.sh
TEST_FILES := $(test_objs)
include ../lib.mk
clean:
rm -f $(test_objs)
File mode changed from 100644 to 100755
CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall
BINARIES = execveat
DEPS = execveat.symlink execveat.denatured script subdir
......@@ -18,8 +17,12 @@ execveat.denatured: execveat
%: %.c
$(CC) $(CFLAGS) -o $@ $^
run_tests: all
./execveat
TEST_PROGS := execveat
TEST_FILES := $(DEPS)
include ../lib.mk
override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
clean:
rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
......@@ -3,25 +3,9 @@
# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
all:
fw_filesystem:
@if /bin/sh ./fw_filesystem.sh ; then \
echo "fw_filesystem: ok"; \
else \
echo "fw_filesystem: [FAIL]"; \
exit 1; \
fi
TEST_PROGS := fw_filesystem.sh fw_userhelper.sh
fw_userhelper:
@if /bin/sh ./fw_userhelper.sh ; then \
echo "fw_userhelper: ok"; \
else \
echo "fw_userhelper: [FAIL]"; \
exit 1; \
fi
run_tests: all fw_filesystem fw_userhelper
include ../lib.mk
# Nothing to clean up.
clean:
.PHONY: all clean run_tests fw_filesystem fw_userhelper
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
all:
run_tests:
@/bin/sh ./ftracetest || echo "ftrace selftests: [FAIL]"
TEST_PROGS := ftracetest
include ../lib.mk
clean:
rm -rf logs/*
......@@ -2,4 +2,4 @@
# description: Basic event tracing check
test -f available_events -a -f set_event -a -d events
# check scheduler events are available
grep -q sched available_events && exit 0 || exit -1
\ No newline at end of file
grep -q sched available_events && exit 0 || exit $FAIL
......@@ -9,7 +9,11 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit -1
exit $FAIL
}
yield() {
ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
}
if [ ! -f set_event -o ! -d events/sched ]; then
......@@ -21,7 +25,8 @@ reset_tracer
do_reset
echo 'sched:sched_switch' > set_event
usleep 1
yield
count=`cat trace | grep sched_switch | wc -l`
if [ $count -eq 0 ]; then
......@@ -31,7 +36,8 @@ fi
do_reset
echo 1 > events/sched/sched_switch/enable
usleep 1
yield
count=`cat trace | grep sched_switch | wc -l`
if [ $count -eq 0 ]; then
......@@ -41,7 +47,8 @@ fi
do_reset
echo 0 > events/sched/sched_switch/enable
usleep 1
yield
count=`cat trace | grep sched_switch | wc -l`
if [ $count -ne 0 ]; then
......
......@@ -9,7 +9,11 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit -1
exit $FAIL
}
yield() {
ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
}
if [ ! -f set_event -o ! -d events/sched ]; then
......@@ -21,7 +25,8 @@ reset_tracer
do_reset
echo 'sched:*' > set_event
usleep 1
yield
count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -lt 3 ]; then
......@@ -31,7 +36,8 @@ fi
do_reset
echo 1 > events/sched/enable
usleep 1
yield
count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -lt 3 ]; then
......@@ -41,7 +47,8 @@ fi
do_reset
echo 0 > events/sched/enable
usleep 1
yield
count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -ne 0 ]; then
......
......@@ -9,7 +9,11 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit -1
exit $FAIL
}
yield() {
ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
}
if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
......@@ -21,6 +25,9 @@ reset_tracer
do_reset
echo '*:*' > set_event
yield
count=`cat trace | grep -v ^# | wc -l`
if [ $count -eq 0 ]; then
fail "none of events are recorded"
......@@ -29,6 +36,9 @@ fi
do_reset
echo 1 > events/enable
yield
count=`cat trace | grep -v ^# | wc -l`
if [ $count -eq 0 ]; then
fail "none of events are recorded"
......@@ -37,6 +47,9 @@ fi
do_reset
echo 0 > events/enable
yield
count=`cat trace | grep -v ^# | wc -l`
if [ $count -ne 0 ]; then
fail "any of events should not be recorded"
......
......@@ -16,7 +16,9 @@ fi
do_reset() {
reset_tracer
echo 0 > /proc/sys/kernel/stack_tracer_enabled
if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then
echo 0 > /proc/sys/kernel/stack_tracer_enabled
fi
enable_tracing
clear_trace
echo > set_ftrace_filter
......@@ -25,7 +27,7 @@ do_reset() {
fail() { # msg
do_reset
echo $1
exit -1
exit $FAIL
}
disable_tracing
......
......@@ -17,7 +17,7 @@ do_reset() {
fail() { # msg
do_reset
echo $1
exit -1
exit $FAIL
}
disable_tracing
......
......@@ -31,7 +31,7 @@ fail() { # mesg
reset_tracer
echo > set_ftrace_filter
echo $1
exit -1
exit $FAIL
}
echo "Testing function tracer with profiler:"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment