@@ -122,15 +122,30 @@ function run_fuzz_target {
122122 # Extract fuzztest binary name from fuzztest wrapper script.
123123 target=(${target//@/ } [0])
124124 fi
125- profraw_update.py $OUT /$target -i $profraw_file_mask
125+ # XXX: readelf: Error: Not an ELF file - it has the wrong magic
126+ # bytes at the start.
127+ grep -q " luarocks" " $target "
128+ is_lua=$?
129+ if [[ " $is_lua " -ne 0 ]]; then
130+ profraw_update.py $OUT /$target -i $profraw_file_mask
131+ fi
126132 llvm-profdata merge -j=1 -sparse $profraw_file_mask -o $profdata_file
127133
128134 # Delete unnecessary and (potentially) large .profraw files.
129135 rm $profraw_file_mask
130136
131- shared_libraries=$( coverage_helper shared_libs -build-dir=$OUT -object=$target )
137+ # `coverage_helper shared_libraries` raise an exception because
138+ # it runs `ldd` on a test wrapper and `ldd` returns a non-zero
139+ # exit code.
140+ test_dir=$( dirname $( realpath " $target " ) )
141+ if [[ " $is_lua " -ne 0 ]]; then
142+ shared_libraries=$( coverage_helper shared_libs -build-dir=$OUT -object=$objects )
143+ else
144+ shared_libraries=$( find $test_dir -name " *.so" ! -name ' luzer_impl.so' ! -name ' libfuzzer_with_ubsan.so' ! -name ' libcustom_mutator.so' ! -name ' libfuzzer_with_asan.so' -type f -print | tr " \n" " " )
145+ fi
132146
133- llvm-cov export -summary-only -instr-profile=$profdata_file -object=$target \
147+ # Lua runtime must have name `lua`.
148+ llvm-cov export -summary-only -instr-profile=$profdata_file -object=$test_dir /lua \
134149 $shared_libraries $LLVM_COV_COMMON_ARGS > $FUZZER_STATS_DIR /$target .json
135150
136151 # If grep returned zero an error was matched.
@@ -406,6 +421,7 @@ function generate_html {
406421
407422 llvm-cov export -summary-only $llvm_cov_args > $summary_file
408423
424+ # support Lua
409425 coverage_helper -v post_process -src-root-dir=/ -summary-file=$summary_file \
410426 -output-dir=$output_dir $PATH_EQUIVALENCE_ARGS
411427}
@@ -624,7 +640,17 @@ else
624640
625641 # TODO(mmoroz): add script from Chromium for rendering directory view reports.
626642 # The first path in $objects does not have -object= prefix (llvm-cov format).
627- shared_libraries=$( coverage_helper shared_libs -build-dir=$OUT -object=$objects )
643+ # `coverage_helper shared_libraries` raise an exception because
644+ # it runs `ldd` on a test wrapper and `ldd` returns a non-zero
645+ # exit code.
646+ grep -q " luarocks" " $target "
647+ is_lua=$?
648+ if [[ " $is_lua " -ne 0 ]]; then
649+ shared_libraries=$( coverage_helper shared_libs -build-dir=$OUT -object=$objects )
650+ else
651+ test_dir=$( dirname $( realpath " $target " ) )
652+ shared_libraries=$( find $test_dir -name " *.so" ! -name ' luzer_impl.so' ! -name ' libfuzzer_with_ubsan.so' ! -name ' libcustom_mutator.so' ! -name ' libfuzzer_with_asan.so' -type f -print | tr " \n" " " )
653+ fi
628654 objects=" $objects $shared_libraries "
629655
630656 generate_html $PROFILE_FILE " $shared_libraries " " $objects " " $REPORT_ROOT_DIR "
0 commit comments