Imported Upstream version 0.3.113
[platform/upstream/libaio.git] / harness / Makefile
1 # foo.
2 TEST_SRCS:=$(shell find cases/ -name \*.t | sort -n -t/ -k2)
3 EXTRAPROGS:=cases/8.p cases/10.p
4 PARTPROGS:=$(filter-out $(EXTRAPROGS), $(patsubst %.t,%.p,$(TEST_SRCS)))
5 PROGS:=$(PARTPROGS) $(EXTRAPROGS)
6 HARNESS_SRCS:=main.c
7 # io_queue.c
8
9 CFLAGS+=-Wall -Werror -I../src -g -O2
10 #-lpthread -lrt
11
12 # gcc-11 does not like the test case in 3.t that
13 # passes an invalid pointer (-1) to the kernel, so
14 # tell the compiler we do not need a warning here
15 cases/3.p:      CFLAGS+=-Wno-stringop-overflow
16
17 # Change this on the build line to run tests against the installed libraries:
18 # make LIBAIO=-laio partcheck
19 LIBAIO?=../src/libaio.a
20
21 all: $(PROGS)
22
23 $(PROGS): %.p: %.t $(HARNESS_SRCS)
24         $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c $(LIBAIO) -lpthread
25
26 clean:
27         rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
28
29 .PHONY:
30
31 testdir/rofile: testdir .PHONY
32         rm -f $@
33         echo "test" >$@
34         chmod 400 $@
35
36 testdir/wofile: testdir .PHONY
37         rm -f $@
38         echo "test" >$@
39         chmod 200 $@
40
41 testdir/rwfile: testdir .PHONY
42         rm -f $@
43         echo "test" >$@
44         chmod 600 $@
45
46 testdir testdir.enospc testdir.ext2:
47         mkdir $@
48
49 root: .PHONY
50         @if [ `id -u` -ne 0 ]; then echo Need root for check, try partcheck >&2; exit 1; fi
51
52 partcheck: $(PARTPROGS) testdir/rofile testdir/rwfile testdir/wofile
53         ./runtests.sh $(PARTPROGS)
54
55 ext2.img:
56         dd if=/dev/zero bs=1M count=10 of=$@
57         mke2fs -F -b 4096 $@
58
59 extracheck: $(EXTRAPROGS) root testdir.ext2 testdir.enospc ext2.img
60         mount -o loop -t ext2 ext2-enospc.img testdir.enospc
61         ./runtests.sh cases/10.p; ret=$$?; umount testdir.enospc; exit $$ret
62         mount -o loop -t ext2 ext2.img testdir.ext2
63         ./runtests.sh cases/8.p; ret=$$?; umount testdir.ext2; exit $$ret
64
65 check: partcheck extracheck