Home | History | Annotate | Line # | Download | only in fuzz
Makefile revision 1.1.1.5.2.1
      1      1.1.1.5  christos # Copyright (c) 2019-2023 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.1.5  christos # SPDX-License-Identifier: BSD-2-Clause
      5          1.1  christos 
      6  1.1.1.5.2.1  perseant IMAGE		:= libfido2-coverage:1.16.0
      7          1.1  christos RUNNER		:= libfido2-runner
      8      1.1.1.5  christos PROFDATA	:= llvm-profdata
      9      1.1.1.5  christos COV		:= llvm-cov
     10  1.1.1.5.2.1  perseant TARGETS		:= fuzz_assert fuzz_attobj fuzz_bio fuzz_cred fuzz_credman \
     11  1.1.1.5.2.1  perseant 		   fuzz_hid fuzz_largeblob fuzz_netlink fuzz_mgmt fuzz_pcsc
     12          1.1  christos CORPORA		:= $(foreach f,${TARGETS},${f}/corpus)
     13          1.1  christos MINIFY		:= $(foreach f,${TARGETS},/minify/${f}/corpus)
     14          1.1  christos REMOTE		:= gs://libfido2-corpus.clusterfuzz-external.appspot.com
     15          1.1  christos .DEFAULT_GOAL	:= all
     16          1.1  christos 
     17          1.1  christos all: ${TARGETS}
     18          1.1  christos 
     19          1.1  christos build:
     20          1.1  christos 	docker build -t ${IMAGE} - < Dockerfile
     21          1.1  christos 
     22          1.1  christos run: build
     23          1.1  christos 	-docker run -it -d --name ${RUNNER} ${IMAGE}
     24          1.1  christos 	docker start ${RUNNER}
     25          1.1  christos 
     26          1.1  christos sync: run
     27          1.1  christos 	tar Ccf .. - src fuzz | docker exec -i ${RUNNER} tar Cxf /libfido2 -
     28      1.1.1.5  christos 	docker exec ${RUNNER} make -C /libfido2/build
     29          1.1  christos 
     30          1.1  christos corpus: sync
     31      1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'cd /libfido2/fuzz && rm -rf ${TARGETS}'
     32          1.1  christos 	docker exec ${RUNNER} tar Czxf /libfido2/fuzz /libfido2/fuzz/corpus.tgz
     33          1.1  christos 
     34          1.1  christos ${TARGETS}: corpus sync
     35          1.1  christos 	docker exec -e LLVM_PROFILE_FILE=/profraw/$@ ${RUNNER} \
     36      1.1.1.2  christos 		/bin/sh -c 'rm -f /profraw/$@ && /libfido2/build/fuzz/$@ \
     37          1.1  christos 		-runs=1 /libfido2/fuzz/$@'
     38          1.1  christos 
     39          1.1  christos ${MINIFY}: /minify/%/corpus: %
     40      1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -rf $@ && mkdir -p $@ && \
     41          1.1  christos 		/libfido2/build/fuzz/$< -use_value_profile=1 -merge=1 $@ \
     42          1.1  christos 		/libfido2/fuzz/$</corpus'
     43          1.1  christos 
     44          1.1  christos corpus.tgz-: ${MINIFY}
     45          1.1  christos 	docker exec -i ${RUNNER} tar Czcf /minify - ${TARGETS} > $@
     46          1.1  christos 
     47          1.1  christos profdata: run
     48      1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -f /$@ && ${PROFDATA} \
     49      1.1.1.5  christos 		merge -sparse /profraw/* -o /$@'
     50          1.1  christos 
     51          1.1  christos report.tgz: profdata
     52      1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -rf /report && mkdir /report && \
     53          1.1  christos 		${COV} show -format=html -tab-size=8 -instr-profile=/$< \
     54      1.1.1.5  christos 		-ignore-filename-regex=pcsclite.h --show-branch-summary=false \
     55          1.1  christos 		-output-dir=/report /libfido2/build/src/libfido2.so'
     56          1.1  christos 	docker exec -i ${RUNNER} tar Czcf / - report > $@
     57          1.1  christos 
     58          1.1  christos summary.txt: profdata
     59          1.1  christos 	docker exec ${RUNNER} ${COV} report -use-color=false \
     60      1.1.1.5  christos 		-ignore-filename-regex=pcsclite.h --show-branch-summary=false \
     61          1.1  christos 		/libfido2/build/src/libfido2.so -instr-profile=/$< > $@
     62          1.1  christos 
     63          1.1  christos functions.txt: profdata
     64      1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c '${COV} report -use-color=false \
     65      1.1.1.5  christos 		-ignore-filename-regex=pcsclite.h -show-functions \
     66      1.1.1.5  christos 		--show-branch-summary=false -instr-profile=/$< \
     67          1.1  christos 		/libfido2/build/src/libfido2.so /libfido2/src/*.[ch]' > $@
     68          1.1  christos 
     69          1.1  christos clean: run
     70      1.1.1.2  christos 	docker exec ${RUNNER} /bin/sh -c 'rm -rf /profraw /profdata && \
     71          1.1  christos 		make -C /libfido2/build clean'
     72          1.1  christos 	-docker stop ${RUNNER}
     73          1.1  christos 	rm -rf ${TARGETS}
     74          1.1  christos 
     75          1.1  christos ${CORPORA}:
     76          1.1  christos 	-mkdir -p $@
     77          1.1  christos 	gsutil -q -m rsync -d -r ${REMOTE}/libFuzzer/libfido2_$(@:/corpus=) $@
     78          1.1  christos 
     79      1.1.1.5  christos fetch-oss-fuzz: ${CORPORA}
     80      1.1.1.5  christos 	find ${TARGETS} -type f -size +8192c -print0 | xargs -0 rm
     81      1.1.1.5  christos 
     82      1.1.1.5  christos fetch-franz:
     83      1.1.1.5  christos 	ssh franz tar -C corpus -cf- . | tar -xf-
     84      1.1.1.5  christos 
     85      1.1.1.5  christos corpus.tgz:
     86          1.1  christos 	tar zcf $@ ${TARGETS}
     87          1.1  christos 
     88          1.1  christos .PHONY: build run sync corpus ${TARGETS} ${CORPORA}
     89          1.1  christos .PHONY: report.tgz summary.txt functions.txt
     90      1.1.1.5  christos .PHONY: fetch-oss-fuzz fetch-franz corpus.tgz
     91