^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) function test_ex {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) make -C ex V=1 clean > ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) make -C ex V=1 >> ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) if [ ! -x ./ex/ex ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) echo FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) exit -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) make -C ex V=1 clean > /dev/null 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) rm -f ex.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) function test_ex_suffix {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) make -C ex V=1 clean > ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # use -rR to disable make's builtin rules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) make -rR -C ex V=1 ex.o >> ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) make -rR -C ex V=1 ex.i >> ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) make -rR -C ex V=1 ex.s >> ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if [ -x ./ex/ex ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) echo FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) exit -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if [ ! -f ./ex/ex.o -o ! -f ./ex/ex.i -o ! -f ./ex/ex.s ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) echo FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) exit -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) make -C ex V=1 clean > /dev/null 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) rm -f ex.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) function test_ex_include {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) make -C ex V=1 clean > ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) # build with krava.h include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) touch ex/krava.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) make -C ex V=1 CFLAGS=-DINCLUDE >> ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if [ ! -x ./ex/ex ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) echo FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) exit -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) # build without the include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) rm -f ex/krava.h ex/ex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) make -C ex V=1 >> ex.out 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if [ ! -x ./ex/ex ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) echo FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) exit -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) make -C ex V=1 clean > /dev/null 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) rm -f ex.out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) echo -n Testing..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) test_ex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) test_ex_suffix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) test_ex_include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) echo OK