Run fuzzer unit tests in Kokoro

This CL adjusts the scripts to be able to run AST and regex
fuzzer unit tests in Kokoro. Only clang is supported for now.

Change-Id: Ibc9ebb9cf0dc40f47317abf88875aa738811919d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61642
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Vasyl Teliman <vasniktel@gmail.com>
This commit is contained in:
Vasyl Teliman 2021-08-11 14:10:05 +00:00 committed by Tint LUCI CQ
parent 9e3e54b932
commit 4ebede411e
4 changed files with 20 additions and 6 deletions

View File

@ -12,10 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if (NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))
message(FATAL_ERROR "Libfuzzer is supported only on clang")
endif ()
set(PROTOBUF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/protobufs/tint_ast_fuzzer.proto) set(PROTOBUF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/protobufs/tint_ast_fuzzer.proto)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobufs) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobufs)

View File

@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
set(LIBTINT_REGEX_FUZZER_SOURCES set(LIBTINT_REGEX_FUZZER_SOURCES
util.h
wgsl_mutator.cc wgsl_mutator.cc
wgsl_mutator.h) wgsl_mutator.h)

View File

@ -94,8 +94,8 @@ void ReplaceRegion(size_t idx1,
size_t id2_len, size_t id2_len,
std::string& wgsl_code); std::string& wgsl_code);
/// Replaces an interval of length interval1_len starting at start_index /// Replaces an interval of length `length` starting at start_index
/// with the interval interval2. /// with the `replacement_text`.
/// @param start_index - starting position of the interval to be replaced. /// @param start_index - starting position of the interval to be replaced.
/// @param length - length of the interval to be replaced. /// @param length - length of the interval to be replaced.
/// @param replacement_text - the interval that will be used as a replacement. /// @param replacement_text - the interval that will be used as a replacement.

View File

@ -91,6 +91,9 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then
if [ "$BUILD_TOOLCHAIN" == "clang" ]; then if [ "$BUILD_TOOLCHAIN" == "clang" ]; then
using clang-10.0.0 using clang-10.0.0
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_FUZZERS=1" COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_FUZZERS=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_SPIRV_TOOLS_FUZZER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_AST_FUZZER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_REGEX_FUZZER=1"
elif [ "$BUILD_TOOLCHAIN" == "gcc" ]; then elif [ "$BUILD_TOOLCHAIN" == "gcc" ]; then
using gcc-9 using gcc-9
fi fi
@ -126,6 +129,20 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then
./tint_unittests ./tint_unittests
hide_cmds hide_cmds
if [ -f ./tint_ast_fuzzer_unittests ]; then
status "Running tint_ast_fuzzer_unittests"
show_cmds
./tint_ast_fuzzer_unittests
hide_cmds
fi
if [ -f ./tint_regex_fuzzer_unittests ]; then
status "Running tint_regex_fuzzer_unittests"
show_cmds
./tint_regex_fuzzer_unittests
hide_cmds
fi
status "Testing test/test-all.sh" status "Testing test/test-all.sh"
show_cmds show_cmds
${SRC_DIR}/test/test-all.sh "${BUILD_DIR}/tint" --verbose ${SRC_DIR}/test/test-all.sh "${BUILD_DIR}/tint" --verbose