Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-4.11-rc1' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/shuah/linux-kselftest

Pull Kselftest update from Shuah Khan:
 "This update consists of:

   - fixes to several existing tests from Stafford Horne

   - cpufreq tests from Viresh Kumar

   - Selftest build and install fixes from Bamvor Jian Zhang and Michael
     Ellerman

   - Fixes to protection-keys tests from Dave Hansen

   - Warning fixes from Shuah Khan"

* tag 'linux-kselftest-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (28 commits)
  selftests/powerpc: Fix remaining fallout from recent changes
  selftests/powerpc: Fix the clean rule since recent changes
  selftests: Fix the .S and .S -> .o rules
  selftests: Fix the .c linking rule
  selftests: Fix selftests build to just build, not run tests
  selftests, x86, protection_keys: fix wrong offset in siginfo
  selftests, x86, protection_keys: fix uninitialized variable warning
  selftest: cpufreq: Update MAINTAINERS file
  selftest: cpufreq: Add special tests
  selftest: cpufreq: Add support to test cpufreq modules
  selftest: cpufreq: Add suspend/resume/hibernate support
  selftest: cpufreq: Add support for cpufreq tests
  selftests: Add intel_pstate to TARGETS
  selftests/intel_pstate: Update makefile to match new style
  selftests/intel_pstate: Fix warning on loop index overflow
  cpupower: Restore format of frequency-info limit
  selftests/futex: Add headers to makefile dependencies
  selftests/futex: Add stdio used for logging
  selftests: x86 protection_keys remove dead code
  selftests: x86 protection_keys fix unused variable compile warnings
  ...
  • Loading branch information
torvalds committed Feb 25, 2017
2 parents cb41955 + 68bd42d commit c4f3f22
Show file tree
Hide file tree
Showing 59 changed files with 1,325 additions and 402 deletions.
12 changes: 12 additions & 0 deletions Documentation/kselftest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ In general, the rules for selftests are

* Don't cause the top-level "make run_tests" to fail if your feature is
unconfigured.

Contributing new tests(details)
===============================

* Use TEST_GEN_XXX if such binaries or files are generated during
compiling.
TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
default.
TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
executable which is not tested by default.
TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
test.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3452,6 +3452,7 @@ B: https://bugzilla.kernel.org
F: Documentation/cpu-freq/
F: drivers/cpufreq/
F: include/linux/cpufreq.h
F: tools/testing/selftests/cpufreq/

CPU FREQUENCY DRIVERS - ARM BIG LITTLE
M: Viresh Kumar <[email protected]>
Expand Down
21 changes: 12 additions & 9 deletions tools/power/cpupower/utils/cpufreq-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,24 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)

/* --hwlimits / -l */

static int get_hardware_limits(unsigned int cpu)
static int get_hardware_limits(unsigned int cpu, unsigned int human)
{
unsigned long min, max;

printf(_(" hardware limits: "));
if (cpufreq_get_hardware_limits(cpu, &min, &max)) {
printf(_("Not Available\n"));
return -EINVAL;
}

print_speed(min);
printf(" - ");
print_speed(max);
printf("\n");
if (human) {
printf(_(" hardware limits: "));
print_speed(min);
printf(" - ");
print_speed(max);
printf("\n");
} else {
printf("%lu %lu\n", min, max);
}
return 0;
}

Expand Down Expand Up @@ -456,7 +460,7 @@ static void debug_output_one(unsigned int cpu)
get_related_cpus(cpu);
get_affected_cpus(cpu);
get_latency(cpu, 1);
get_hardware_limits(cpu);
get_hardware_limits(cpu, 1);

freqs = cpufreq_get_available_frequencies(cpu);
if (freqs) {
Expand Down Expand Up @@ -622,7 +626,7 @@ int cmd_freq_info(int argc, char **argv)
ret = get_driver(cpu);
break;
case 'l':
ret = get_hardware_limits(cpu);
ret = get_hardware_limits(cpu, human);
break;
case 'w':
ret = get_freq_hardware(cpu, human);
Expand All @@ -639,7 +643,6 @@ int cmd_freq_info(int argc, char **argv)
}
if (ret)
return ret;
printf("\n");
}
return ret;
}
38 changes: 29 additions & 9 deletions tools/testing/selftests/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
TARGETS = bpf
TARGETS += breakpoints
TARGETS += capabilities
TARGETS += cpufreq
TARGETS += cpu-hotplug
TARGETS += efivarfs
TARGETS += exec
TARGETS += firmware
TARGETS += ftrace
TARGETS += futex
TARGETS += gpio
TARGETS += intel_pstate
TARGETS += ipc
TARGETS += kcmp
TARGETS += lib
Expand Down Expand Up @@ -49,29 +51,44 @@ override LDFLAGS =
override MAKEFLAGS =
endif

BUILD := $(O)
ifndef BUILD
BUILD := $(KBUILD_OUTPUT)
endif
ifndef BUILD
BUILD := $(shell pwd)
endif

export BUILD
all:
for TARGET in $(TARGETS); do \
make -C $$TARGET; \
for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
mkdir $$BUILD_TARGET -p; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
done;

run_tests: all
for TARGET in $(TARGETS); do \
make -C $$TARGET run_tests; \
BUILD_TARGET=$$BUILD/$$TARGET; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
done;

hotplug:
for TARGET in $(TARGETS_HOTPLUG); do \
make -C $$TARGET; \
BUILD_TARGET=$$BUILD/$$TARGET; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
done;

run_hotplug: hotplug
for TARGET in $(TARGETS_HOTPLUG); do \
make -C $$TARGET run_full_test; \
BUILD_TARGET=$$BUILD/$$TARGET; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
done;

clean_hotplug:
for TARGET in $(TARGETS_HOTPLUG); do \
make -C $$TARGET clean; \
BUILD_TARGET=$$BUILD/$$TARGET; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;

run_pstore_crash:
Expand All @@ -86,7 +103,8 @@ ifdef INSTALL_PATH
@# Ask all targets to install their files
mkdir -p $(INSTALL_PATH)
for TARGET in $(TARGETS); do \
make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
BUILD_TARGET=$$BUILD/$$TARGET; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
done;

@# Ask all targets to emit their test scripts
Expand All @@ -95,10 +113,11 @@ ifdef INSTALL_PATH
echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)

for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
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); \
make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
done;

Expand All @@ -109,7 +128,8 @@ endif

clean:
for TARGET in $(TARGETS); do \
make -C $$TARGET clean; \
BUILD_TARGET=$$BUILD/$$TARGET; \
make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;

.PHONY: install
10 changes: 2 additions & 8 deletions tools/testing/selftests/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ BPFOBJ := $(LIBDIR)/bpf/bpf.o

CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR)

test_objs = test_verifier test_tag test_maps test_lru_map test_lpm_map
TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map

TEST_PROGS := $(test_objs) test_kmod.sh
TEST_FILES := $(test_objs)
TEST_PROGS := test_kmod.sh

.PHONY: all clean force

all: $(test_objs)

# force a rebuild of BPFOBJ when its dependencies are updated
force:

Expand All @@ -21,6 +18,3 @@ $(BPFOBJ): force
$(test_objs): $(BPFOBJ)

include ../lib.mk

clean:
$(RM) $(test_objs)
10 changes: 3 additions & 7 deletions tools/testing/selftests/breakpoints/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)

ifeq ($(ARCH),x86)
TEST_PROGS := breakpoint_test
TEST_GEN_PROGS := breakpoint_test
endif
ifeq ($(ARCH),aarch64)
TEST_PROGS := breakpoint_test_arm64
TEST_GEN_PROGS := breakpoint_test_arm64
endif

TEST_PROGS += step_after_suspend_test

all: $(TEST_PROGS)
TEST_GEN_PROGS += step_after_suspend_test

include ../lib.mk

clean:
rm -fr breakpoint_test breakpoint_test_arm64 step_after_suspend_test
11 changes: 2 additions & 9 deletions tools/testing/selftests/capabilities/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
TEST_FILES := validate_cap
TEST_PROGS := test_execve

BINARIES := $(TEST_FILES) $(TEST_PROGS)
TEST_GEN_FILES := validate_cap
TEST_GEN_PROGS := test_execve

CFLAGS += -O2 -g -std=gnu99 -Wall
LDLIBS += -lcap-ng -lrt -ldl

all: $(BINARIES)

clean:
$(RM) $(BINARIES)

include ../lib.mk

8 changes: 8 additions & 0 deletions tools/testing/selftests/cpufreq/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all:

TEST_PROGS := main.sh
TEST_FILES := cpu.sh cpufreq.sh governor.sh module.sh special-tests.sh

include ../lib.mk

clean:
84 changes: 84 additions & 0 deletions tools/testing/selftests/cpufreq/cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash
#
# CPU helpers

# protect against multiple inclusion
if [ $FILE_CPU ]; then
return 0
else
FILE_CPU=DONE
fi

source cpufreq.sh

for_each_cpu()
{
cpus=$(ls $CPUROOT | grep "cpu[0-9].*")
for cpu in $cpus; do
$@ $cpu
done
}

for_each_non_boot_cpu()
{
cpus=$(ls $CPUROOT | grep "cpu[1-9].*")
for cpu in $cpus; do
$@ $cpu
done
}

#$1: cpu
offline_cpu()
{
printf "Offline $1\n"
echo 0 > $CPUROOT/$1/online
}

#$1: cpu
online_cpu()
{
printf "Online $1\n"
echo 1 > $CPUROOT/$1/online
}

#$1: cpu
reboot_cpu()
{
offline_cpu $1
online_cpu $1
}

# Reboot CPUs
# param: number of times we want to run the loop
reboot_cpus()
{
printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n"

for i in `seq 1 $1`; do
for_each_non_boot_cpu offline_cpu
for_each_non_boot_cpu online_cpu
printf "\n"
done

printf "\n%s\n\n" "------------------------------------------------"
}

# Prints warning for all CPUs with missing cpufreq directory
print_unmanaged_cpus()
{
for_each_cpu cpu_should_have_cpufreq_directory
}

# Counts CPUs with cpufreq directories
count_cpufreq_managed_cpus()
{
count=0;

for cpu in `ls $CPUROOT | grep "cpu[0-9].*"`; do
if [ -d $CPUROOT/$cpu/cpufreq ]; then
let count=count+1;
fi
done

echo $count;
}
Loading

0 comments on commit c4f3f22

Please sign in to comment.