<commit_before>#
#  Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""This file contains basic functions for cc fuzz test."""

load("@rules_cc//cc:defs.bzl", "cc_test")
load("//fuzzing:common.bzl", "fuzzing_launcher")

def cc_fuzz_test(
        name,
        srcs,
        copts = [],
        linkopts = [],
        deps = [],
        tags = [],
        visibility = None):
    """This macro provide two targets:
    <name>: the executable file built by cc_test.
    <name>_run: an executable to launch the fuzz test.
"""

    cc_test(
        name = name,
        srcs = srcs,
        copts = ["-fsanitize=fuzzer"] + copts,
        linkopts = ["-fsanitize=fuzzer"] + linkopts,
        deps = deps,
        tags = tags + ["fuzz_test"],
        visibility = visibility,
    )

    fuzzing_launcher(
        name = name + "_run",
        target = name,
        # Since the script depends on the _fuzz_test above, which is a cc_test,
        # this attribute must be set.
        testonly = True,
    )
<commit_msg>Use **kwargs to forward attributes in cc_fuzz_test (#39)<commit_after>#
#  Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""This file contains basic functions for cc fuzz test."""

load("@rules_cc//cc:defs.bzl", "cc_test")
load("//fuzzing:common.bzl", "fuzzing_launcher")

def cc_fuzz_test(
        name,
        **kwargs):
    """Macro for c++ fuzzing test

    This macro provides two targets:
    <name>: the executable file built by cc_test.
    <name>_run: an executable to launch the fuzz test.
"""

    # Add fuzz_test tag
    kwargs.setdefault("tags", []).append("fuzz_test")

    cc_test(
        name = name,
        **kwargs
    )

    fuzzing_launcher(
        name = name + "_run",
        target = name,
        # Since the script depends on the _fuzz_test above, which is a cc_test,
        # this attribute must be set.
        testonly = True,
    )

{'fraction_non_alphanumeric': 0.10020449897750511, 'fraction_numerical': 0.006134969325153374, 'mean_word_length': 2.8466579292267364, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6394735', 'n_tokens_mistral': 883, 'n_tokens_neox': 853, 'n_words': 335}