Home | History | Annotate | Line # | Download | only in fuzz
Makefile revision 1.1.1.2
      1      1.1  christos # Copyright (c) 2019 Yubico AB. All rights reserved.
      2      1.1  christos # Use of this source code is governed by a BSD-style
      3      1.1  christos # license that can be found in the LICENSE file.
      4      1.1  christos 
      5  1.1.1.2  christos IMAGE		:= libfido2-coverage:1.5.0
      6      1.1  christos RUNNER		:= libfido2-runner
      7  1.1.1.2  christos PROFDATA	:= llvm-profdata-10
      8  1.1.1.2  christos COV		:= llvm-cov-10
      9      1.1  christos TARGETS		:= fuzz_assert fuzz_bio fuzz_cred fuzz_credman fuzz_mgmt
     10      1.1  christos CORPORA		:= $(foreach f,${TARGETS},${f}/corpus)
     11      1.1  christos MINIFY		:= $(foreach f,${TARGETS},/minify/${f}/corpus)
     12      1.1  christos REMOTE		:= gs://libfido2-corpus.clusterfuzz-external.appspot.com
     13      1.1  christos .DEFAULT_GOAL	:= all
     14      1.1  christos 
     15      1.1  christos all: ${TARGETS}
     16      1.1  christos 
     17      1.1  christos build:
     18      1.1  christos 	docker build -t ${IMAGE} - < Dockerfile
     19      1.1  christos 
     20      1.1  christos run: build
     21      1.1  christos 	-docker run -it -d --name ${RUNNER} ${IMAGE}
     22      1.1  christos 	docker start ${RUNNER}
     23      1.1  christos 
     24      1.1  christos sync: run
     25      1.1  christos 	tar Ccf .. - src fuzz | docker exec -i ${RUNNER} tar Cxf /libfido2 -
     26      1.1  christos 	docker exec ${RUNNER} make -C libfido2/build
     27      1.1  christos 
     28      1.1  christos corpus: sync
     29  1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'cd /libfido2/fuzz && rm -rf ${TARGETS}'
     30      1.1  christos 	docker exec ${RUNNER} tar Czxf /libfido2/fuzz /libfido2/fuzz/corpus.tgz
     31      1.1  christos 
     32      1.1  christos ${TARGETS}: corpus sync
     33      1.1  christos 	docker exec -e LLVM_PROFILE_FILE=/profraw/$@ ${RUNNER} \
     34  1.1.1.2  christos 		/bin/sh -c 'rm -f /profraw/$@ && /libfido2/build/fuzz/$@ \
     35      1.1  christos 		-runs=1 /libfido2/fuzz/$@'
     36      1.1  christos 
     37      1.1  christos ${MINIFY}: /minify/%/corpus: %
     38  1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -rf $@ && mkdir -p $@ && \
     39      1.1  christos 		/libfido2/build/fuzz/$< -use_value_profile=1 -merge=1 $@ \
     40      1.1  christos 		/libfido2/fuzz/$</corpus'
     41      1.1  christos 
     42      1.1  christos corpus.tgz-: ${MINIFY}
     43      1.1  christos 	docker exec -i ${RUNNER} tar Czcf /minify - ${TARGETS} > $@
     44      1.1  christos 
     45      1.1  christos profdata: run
     46  1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -f /$@ && ${PROFDATA} \
     47      1.1  christos 		merge -sparse profraw/* -o $@'
     48      1.1  christos 
     49      1.1  christos report.tgz: profdata
     50  1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -rf /report && mkdir /report && \
     51      1.1  christos 		${COV} show -format=html -tab-size=8 -instr-profile=/$< \
     52      1.1  christos 		-output-dir=/report /libfido2/build/src/libfido2.so'
     53      1.1  christos 	docker exec -i ${RUNNER} tar Czcf / - report > $@
     54      1.1  christos 
     55      1.1  christos summary.txt: profdata
     56      1.1  christos 	docker exec ${RUNNER} ${COV} report -use-color=false \
     57      1.1  christos 		/libfido2/build/src/libfido2.so -instr-profile=/$< > $@
     58      1.1  christos 
     59      1.1  christos functions.txt: profdata
     60  1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c '${COV} report -use-color=false \
     61      1.1  christos 		-show-functions -instr-profile=/$< \
     62      1.1  christos 		/libfido2/build/src/libfido2.so /libfido2/src/*.[ch]' > $@
     63      1.1  christos 
     64      1.1  christos clean: run
     65  1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -rf /profraw /profdata && \
     66      1.1  christos 		make -C /libfido2/build clean'
     67      1.1  christos 	-docker stop ${RUNNER}
     68      1.1  christos 	rm -rf ${TARGETS}
     69      1.1  christos 
     70      1.1  christos ${CORPORA}:
     71      1.1  christos 	-mkdir -p $@
     72      1.1  christos 	gsutil -q -m rsync -d -r ${REMOTE}/libFuzzer/libfido2_$(@:/corpus=) $@
     73      1.1  christos 
     74      1.1  christos corpus.tgz: ${CORPORA}
     75      1.1  christos 	tar zcf $@ ${TARGETS}
     76      1.1  christos 
     77      1.1  christos .PHONY: build run sync corpus ${TARGETS} ${CORPORA}
     78      1.1  christos .PHONY: report.tgz summary.txt functions.txt
     79