We'd like to be able to better integrate pm-qa into an ebuild system that is used on ChromiumOS' build system. For that we need a few changes, the main one being an install target and better flow so we don't have to add package-specific implementations of src_compile and src_install.
The following patch adds an install target to the main makefile, adds a default prefix of /opt/pm-qa and only uses sudo to invoke the tests, without expecting sudo to run make itself.
The README file has also been updated to reflect the new changes.
utils/utils_sanity.sh has been removed since it had no real purpose.
My make-fu isn't great, so any feedback would be appreciated.
It would also be nice if someone could review this and make sure it is sane for Android builds. It shouldn't change the Android.mk flow though.
Given that, does the patch look OK for pushing?
Thanks, Luis
Signed-off-by: Luis Machado luis.machado@linaro.org
--- Makefile | 25 +++++++++++++++++++++++++ README | 10 +++++++++- Test.mk | 31 ++++++++++++++++++++++--------- utils/utils_sanity.sh | 39 --------------------------------------- 4 files changed, 56 insertions(+), 49 deletions(-) delete mode 100755 utils/utils_sanity.sh
diff --git a/Makefile b/Makefile index d76deb7..8e0cf17 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,19 @@ # - 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) + +.PHONY: all clean check recheck uncheck + +# Build all the utils required by the tests. all: @(cd utils; $(MAKE))
@@ -47,3 +60,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 b976727..c0c0ca4 100644 --- a/README +++ b/README @@ -1,6 +1,10 @@ Commands ======== -- In order to run the tests, invoke as root: +- If you just want to build the supporting utils for the pm-qa tests, invoke: + + make + +- In order to run the tests, invoke:
make check
@@ -12,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 =================== diff --git a/Test.mk b/Test.mk index 44f0ece..441af77 100644 --- a/Test.mk +++ b/Test.mk @@ -24,19 +24,26 @@ 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 -SRC=$(wildcard *.c) -EXEC=$(SRC:%.c=%)
-check: build_utils run_tests +# All utils' source files. +SRC=$(wildcard ../utils/*.c) $(wildcard ../cpuidle/*.c)
-build_utils: - $(CC) ../utils/uevent_reader.c -o ../utils/uevent_reader - $(CC) ../utils/cpucycle.c -o ../utils/cpucycle +# All executable files built from the utils' source files. +EXEC=$(SRC:%.c=%)
+# 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 \ + sudo ./$(SNT); if test "$$?" -eq 0; then echo 0; else \ echo 1; fi; else echo 1; fi)
ifeq "$(SANITY_STATUS)" "1" @@ -48,16 +55,22 @@ 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) # @cat $(<:.sh=.txt) endif
+# Target for building all the utils we need, from sources. +$(EXEC): $(SRC) + $(CC) $(CFLAGS) $(FLAGS) $@.c -o $@ + clean: rm -f *.o $(EXEC)
+check: build_utils run_tests + uncheck: -@$(shell test ! -z "$(LOG)" && rm -f $(LOG))
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