Hi,
For the sake of keeping things organized and easier to review, i've broken up the previous change into smaller pieces.
Luis Machado (6): Make the default target only build the utils Remove utils/utils_sanity.sh Invoke scripts with sudo Adjust compiler flag variables Add install target Add missing phony targets
Makefile | 25 +++++++++++++++++++++++++ README | 8 ++++++++ Test.mk | 32 ++++++++++++++++++++++++-------- utils/utils_sanity.sh | 39 --------------------------------------- 4 files changed, 57 insertions(+), 47 deletions(-) delete mode 100755 utils/utils_sanity.sh
The following patch adjusts the main Makefile and secondary Makefile (Test.mk) so the default target only builds the pm-qa utils from sources, without running the tests.
Also document some variables and targets.
2018-01-11 Luis Machado luis.machado@linaro.org
* Makefile: Document target "all". * README: Document how to build only the pm-qa utils. * Test.mk: Document misc variables and targets. (SRC): Hold list of all utils' .c files. ($(EXEC)): New target to build all utils from sources. (check): Move target closer to uncheck target.
Signed-off-by: Luis Machado luis.machado@linaro.org --- Makefile | 2 ++ README | 4 ++++ Test.mk | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile index d76deb7..1c7bc9b 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,8 @@ # - initial API and implementation # hotplug_allow_cpu0?=0 + +# Build all the utils required by the tests. all: @(cd utils; $(MAKE))
diff --git a/README b/README index b976727..8d1519f 100644 --- a/README +++ b/README @@ -1,5 +1,9 @@ Commands ======== +- If you just want to build the supporting utils for the pm-qa tests, invoke: + + make + - In order to run the tests, invoke as root:
make check diff --git a/Test.mk b/Test.mk index 44f0ece..455dc3a 100644 --- a/Test.mk +++ b/Test.mk @@ -26,14 +26,15 @@ TST=$(sort $(wildcard *[!{sanity}].sh)) LOG=$(TST:.sh=.log) CFLAGS?=-g -Wall -pthread CC?=gcc -SRC=$(wildcard *.c) -EXEC=$(SRC:%.c=%)
-check: build_utils run_tests +# All utils' source files. +SRC=$(wildcard ../utils/*.c) $(wildcard ../cpuidle/*.c) + +# All executable files built from the utils' source files. +EXEC=$(SRC:%.c=%)
-build_utils: - $(CC) ../utils/uevent_reader.c -o ../utils/uevent_reader - $(CC) ../utils/cpucycle.c -o ../utils/cpucycle +# Build the utils and run the tests. +build_utils: $(EXEC)
SANITY_STATUS:= $(shell if test $(SNT) && test -f $(SNT); then \ ./$(SNT); if test "$$?" -eq 0; then echo 0; else \ @@ -55,9 +56,15 @@ run_tests: # @cat $(<:.sh=.txt) endif
+# Target for building all the utils we need, from sources. +$(EXEC): $(SRC) + $(CC) $(CFLAGS) $@.c -o $@ + clean: rm -f *.o $(EXEC)
+check: build_utils run_tests + uncheck: -@$(shell test ! -z "$(LOG)" && rm -f $(LOG))
This sanity check is a dummy one. It doesn't check anything at the moment, so deleting it seems to be appropriate.
2019-01-11 Luis Machado luis.machado@linaro.org
* utils/utils_sanity.sh: Remove.
Signed-off-by: Luis Machado luis.machado@linaro.org --- utils/utils_sanity.sh | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100755 utils/utils_sanity.sh
diff --git a/utils/utils_sanity.sh b/utils/utils_sanity.sh deleted file mode 100755 index c5bdcd7..0000000 --- a/utils/utils_sanity.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# PM-QA validation test suite for the power management on Linux -# -# Copyright (C) 2014, Linaro Limited. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributors: -# Sanjay Singh Rawat sanjay.rawat@linaro.org -# - initial API and implementation -# - -. ../include/functions.sh - -is_root -if [ $? -ne 0 ]; then - log_skip "user is not root" - exit 0 -fi - -check_utils() { - # just returning SUCCESS, so suite doesn't break - return 1 -} - -check_utils
We were requiring the user to run the whole makefile as sudo. The following patch uses sudo to call the sanity check scripts and the functional tests only.
2019-01-11 Luis Machado luis.machado@linaro.org
* Test.mk: Invoke sanity tests and functional tests with sudo.
Signed-off-by: Luis Machado luis.machado@linaro.org --- Test.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Test.mk b/Test.mk index 455dc3a..3c12a9e 100644 --- a/Test.mk +++ b/Test.mk @@ -37,7 +37,7 @@ EXEC=$(SRC:%.c=%) build_utils: $(EXEC)
SANITY_STATUS:= $(shell if test $(SNT) && test -f $(SNT); then \ - ./$(SNT); if test "$$?" -eq 0; then echo 0; else \ + sudo ./$(SNT); if test "$$?" -eq 0; then echo 0; else \ echo 1; fi; else echo 1; fi)
ifeq "$(SANITY_STATUS)" "1" @@ -49,7 +49,7 @@ run_tests: uncheck $(EXEC) $(LOG) @echo -n "### "; cat $(<:.sh=.txt); @echo -n "### "; grep "URL :" ./$< | awk '/http/{print $$NF}' @echo "###" - -@./$< 2> $@ + -@sudo ./$< 2> $@ else run_tests: ./$(SNT)
In order to pass additional compiler flags while still keeping the required flags intact (-pthread for example), we add a local set of flags on top of the exsiting CFLAGS.
2019-01-11 Luis Machado luis.machado@linaro.org
* Test.mk (CFLAGS): Set to "-g -Wall" (FLAGS): New variable. Set to -pthread. Document variables. ($(EXEC): Use FLAGS.
Signed-off-by: Luis Machado luis.machado@linaro.org --- Test.mk | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Test.mk b/Test.mk index 3c12a9e..86e59ab 100644 --- a/Test.mk +++ b/Test.mk @@ -24,7 +24,14 @@ SNT=$(wildcard *sanity.sh) TST=$(sort $(wildcard *[!{sanity}].sh)) LOG=$(TST:.sh=.log) -CFLAGS?=-g -Wall -pthread + +# Default flags passed to the compiler. +CFLAGS?=-g -Wall + +# Required compiler flags to build the utils. +FLAGS?=-pthread + +# Default compiler to build the utils. CC?=gcc
# All utils' source files. @@ -58,7 +65,7 @@ endif
# Target for building all the utils we need, from sources. $(EXEC): $(SRC) - $(CC) $(CFLAGS) $@.c -o $@ + $(CC) $(CFLAGS) $(FLAGS) $@.c -o $@
clean: rm -f *.o $(EXEC)
The following patch adds an install target so we can install the utils/scripts somewhere. The default prefix is /opt/pm-qa.
2019-01-11 Luis Machado luis.machado@linaro.org
* Makefile (prefix, SRC, EXEC, SUBDIRS, INSTALL_FILES): New variables. (install): New target. * README: Document install target.
Signed-off-by: Luis Machado luis.machado@linaro.org --- Makefile | 21 +++++++++++++++++++++ README | 4 ++++ 2 files changed, 25 insertions(+)
diff --git a/Makefile b/Makefile index 1c7bc9b..6c0621f 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,15 @@ # - initial API and implementation # hotplug_allow_cpu0?=0 +prefix := /opt/pm-qa +SRC := $(wildcard utils/*.c) $(wildcard cpuidle/*.c) +EXEC=$(SRC:%.c=%) + +# All directories that need to be created during installation. +SUBDIRS := $(wildcard */.) + +# All files that need to be installed. +INSTALL_FILES := $(wildcard */*.sh */*.txt) $(EXEC)
# Build all the utils required by the tests. all: @@ -49,3 +58,15 @@ recheck: uncheck check clean: @(cd utils; $(MAKE) clean)
+# Copy all the required directories and files to the installation +# directory. +install: all + @echo "Installing files to $(DESTDIR)/$(prefix)" + + @(for dir in $(SUBDIRS); do \ + mkdir -p $(DESTDIR)$(prefix)/$$dir; \ + done;) + + @(for file in $(INSTALL_FILES); do \ + cp -a $$file $(DESTDIR)$(prefix)/$$file; \ + done;) diff --git a/README b/README index 8d1519f..db76ea6 100644 --- a/README +++ b/README @@ -16,6 +16,10 @@ Commands
make -C cpufreq check
+- If you want to install the pm-qa suite somewhere (default prefix is + /opt/pm-qa), invoke: + + make install DESTDIR=<destination_directory>
Test Specifications ===================
The following patch adds some missing phony targets.
2019-01-11 Luis Machado luis.machado@linaro.org
* Makefile: New phony target list. * Test.mk: Likewise.
Signed-off-by: Luis Machado luis.machado@linaro.org --- Makefile | 2 ++ Test.mk | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/Makefile b/Makefile index 6c0621f..624ce31 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,8 @@ SUBDIRS := $(wildcard */.) # All files that need to be installed. INSTALL_FILES := $(wildcard */*.sh */*.txt) $(EXEC)
+.PHONY: all check clean install recheck uncheck + # Build all the utils required by the tests. all: @(cd utils; $(MAKE)) diff --git a/Test.mk b/Test.mk index 86e59ab..acf62a4 100644 --- a/Test.mk +++ b/Test.mk @@ -40,6 +40,8 @@ SRC=$(wildcard ../utils/*.c) $(wildcard ../cpuidle/*.c) # All executable files built from the utils' source files. EXEC=$(SRC:%.c=%)
+.PHONY: build_utils check clean recheck run_tests uncheck + # Build the utils and run the tests. build_utils: $(EXEC)
Hi Luis,
On Fri, Jan 11, 2019 at 9:53 AM Luis Machado luis.machado@linaro.org wrote:
Hi,
For the sake of keeping things organized and easier to review, i've broken up the previous change into smaller pieces.
Luis Machado (6): Make the default target only build the utils Remove utils/utils_sanity.sh Invoke scripts with sudo Adjust compiler flag variables Add install target Add missing phony targets
Thanks for your patchset. I've applied all of them.
Makefile | 25 +++++++++++++++++++++++++ README | 8 ++++++++ Test.mk | 32 ++++++++++++++++++++++++-------- utils/utils_sanity.sh | 39 --------------------------------------- 4 files changed, 57 insertions(+), 47 deletions(-) delete mode 100755 utils/utils_sanity.sh
-- 2.17.1
Thanks Lisa!
On 1/13/19 10:11 PM, Lisa Nguyen wrote:
Hi Luis,
On Fri, Jan 11, 2019 at 9:53 AM Luis Machado luis.machado@linaro.org wrote:
Hi,
For the sake of keeping things organized and easier to review, i've broken up the previous change into smaller pieces.
Luis Machado (6): Make the default target only build the utils Remove utils/utils_sanity.sh Invoke scripts with sudo Adjust compiler flag variables Add install target Add missing phony targets
Thanks for your patchset. I've applied all of them.
Makefile | 25 +++++++++++++++++++++++++ README | 8 ++++++++ Test.mk | 32 ++++++++++++++++++++++++-------- utils/utils_sanity.sh | 39 --------------------------------------- 4 files changed, 57 insertions(+), 47 deletions(-) delete mode 100755 utils/utils_sanity.sh
-- 2.17.1