Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Add test for missing include

The current build framework fails to cope with header file removal. The
reason is that the removed header file stays in the .cmd file target
rule and forces the build to fail.

This issue is fixed and explained in the following patches.

Adding a new build test that simulates header removal.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1443004442-32660-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
0c00c3fb ab6201d0

+39 -1
+1
tools/build/tests/ex/Build
··· 4 4 ex-y += b.o 5 5 ex-y += empty/ 6 6 ex-y += empty2/ 7 + ex-y += inc.o 7 8 8 9 libex-y += c.o 9 10 libex-y += d.o
+1 -1
tools/build/tests/ex/Makefile
··· 1 - export srctree := ../../../.. 1 + export srctree := $(abspath ../../../..) 2 2 export CC := gcc 3 3 export LD := ld 4 4 export AR := ar
+2
tools/build/tests/ex/ex.c
··· 5 5 int d(void); 6 6 int e(void); 7 7 int f(void); 8 + int inc(void); 8 9 9 10 int main(void) 10 11 { ··· 15 14 d(); 16 15 e(); 17 16 f(); 17 + inc(); 18 18 19 19 return 0; 20 20 }
+8
tools/build/tests/ex/inc.c
··· 1 + #ifdef INCLUDE 2 + #include "krava.h" 3 + #endif 4 + 5 + int inc(void) 6 + { 7 + return 0; 8 + }
+27
tools/build/tests/run.sh
··· 34 34 make -C ex V=1 clean > /dev/null 2>&1 35 35 rm -f ex.out 36 36 } 37 + 38 + function test_ex_include { 39 + make -C ex V=1 clean > ex.out 2>&1 40 + 41 + # build with krava.h include 42 + touch ex/krava.h 43 + make -C ex V=1 CFLAGS=-DINCLUDE >> ex.out 2>&1 44 + 45 + if [ ! -x ./ex/ex ]; then 46 + echo FAILED 47 + exit -1 48 + fi 49 + 50 + # build without the include 51 + rm -f ex/krava.h ex/ex 52 + make -C ex V=1 >> ex.out 2>&1 53 + 54 + if [ ! -x ./ex/ex ]; then 55 + echo FAILED 56 + exit -1 57 + fi 58 + 59 + make -C ex V=1 clean > /dev/null 2>&1 60 + rm -f ex.out 61 + } 62 + 37 63 echo -n Testing.. 38 64 39 65 test_ex 40 66 test_ex_suffix 67 + test_ex_include 41 68 42 69 echo OK