# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---

transforms:
    - taskgraph.transforms.task_context

kind-dependencies:
    - build

task-defaults:
    run:
        using: run-task
        checkout:
            nss:
                path: nss
        command: "${{VCS_PATH}}/nss/automation/taskcluster/scripts/fuzz.sh {target} {corpus} -max_total_time={MAX_FUZZ_TIME}"
    worker:
        env:
            GTESTFILTER: "*Fuzz*"
            ASAN_OPTIONS: "allocator_may_return_null=1:detect_stack_use_after_return=1"
            UBSAN_OPTIONS: "print_stacktrace=1"
            NSS_DISABLE_ARENA_FREE_LIST: "1"
            NSS_DISABLE_UNLOAD: "1"
            CC: "clang"
            CCC: "clang++"
            TC_PARENT_TASK_ID: {task-reference: "<build>"}
        allow-ptrace: true
        docker-image: {in-tree: fuzz}
        max-run-time: 3600
    worker-type: t-linux
    task-context:
        from-object:
            MAX_FUZZ_TIME: 300
        substitution-fields:
            - run.command
    attributes:
        retrigger: true
    treeherder:
        kind: test

tasks:
    linux64-asn1:
        description: Linux x64 ASN1
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: ASN1
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: asn1
                corpus: asn1

    linux64-certdn:
        description: Linux x64 CertDN
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: CertDN
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: certDN
                corpus: certDN

    linux64-pkcs7:
        description: Linux x64 PKCS7
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: PKCS7
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: pkcs7
                corpus: pkcs7

    linux64-pkcs8:
        description: Linux x64 PKCS8
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: PKCS8
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: pkcs8
                corpus: pkcs8

    linux64-pkcs12:
        description: Linux x64 PKCS12
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: PKCS12
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: pkcs12
                corpus: pkcs12

    linux64-quickder:
        description: Linux x64 QuickDER
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: QuickDER
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: quickder
                corpus: quickder

    linux64-smime:
        description: Linux x64 SMIME
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: SMIME
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: smime
                corpus: smime

    linux64-tls-client:
        description: Linux x64 TLS Client
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: TLS-Client
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client-no_fuzzer_mode

    linux64-tls-server:
        description: Linux x64 TLS Server
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: TLS-Server
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server-no_fuzzer_mode

    linux64-dtls-client:
        description: Linux x64 DTLS Client
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: DTLS-Client
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client-no_fuzzer_mode

    linux64-dtls-server:
        description: Linux x64 DTLS Server
        dependencies:
            build: build-linux64/debug-fuzz
        treeherder:
            symbol: DTLS-Server
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server-no_fuzzer_mode

    linux64-cryptofuzz:
        description: Cryptofuzz
        dependencies:
            build: build-linux64/debug-fuzz
        run:
            command: "${{VCS_PATH}}/nss/automation/taskcluster/scripts/cryptofuzz.sh -max_total_time={MAX_FUZZ_TIME}"
        treeherder:
            symbol: Cryptofuzz
            platform: linux64/debug-fuzz

    linux64-tlsfuzz-tls-client:
        description: Linux x64 TLS Client
        dependencies:
            build: build-linux64/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Client)
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client

    linux64-tlsfuzz-tls-server:
        description: Linux x64 TLS Server
        dependencies:
            build: build-linux64/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Server)
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server

    linux64-tlsfuzz-dtls-client:
        description: Linux x64 DTLS Client
        dependencies:
            build: build-linux64/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Client)
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client

    linux64-tlsfuzz-dtls-server:
        description: Linux x64 DTLS Server
        dependencies:
            build: build-linux64/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Server)
            platform: linux64/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server

    linux32-asn1:
        description: Linux 32 ASN1
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: ASN1
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: asn1
                corpus: asn1

    linux32-certdn:
        description: Linux 32 CertDN
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: CertDN
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: certDN
                corpus: certDN

    linux32-pkcs7:
        description: Linux 32 PKCS7
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: PKCS7
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: pkcs7
                corpus: pkcs7

    linux32-pkcs8:
        description: Linux 32 PKCS8
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: PKCS8
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: pkcs8
                corpus: pkcs8

    linux32-pkcs12:
        description: Linux 32 PKCS12
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: PKCS12
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: pkcs12
                corpus: pkcs12

    linux32-quickder:
        description: Linux 32 QuickDER
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: QuickDER
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: quickder
                corpus: quickder

    linux32-smime:
        description: Linux 32 SMIME
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: SMIME
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: smime
                corpus: smime

    linux32-tls-client:
        description: Linux 32 TLS Client
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: TLS-Client
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client-no_fuzzer_mode

    linux32-tls-server:
        description: Linux 32 TLS Server
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: TLS-Server
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server-no_fuzzer_mode

    linux32-dtls-client:
        description: Linux 32 DTLS Client
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: DTLS-Client
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client-no_fuzzer_mode

    linux32-dtls-server:
        description: Linux 32 DTLS Server
        dependencies:
            build: build-linux32/debug-fuzz
        treeherder:
            symbol: DTLS-Server
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server-no_fuzzer_mode

    linux32-cryptofuzz:
        description: Cryptofuzz
        dependencies:
            build: build-linux32/debug-fuzz
        run:
            command: "${{VCS_PATH}}/nss/automation/taskcluster/scripts/cryptofuzz.sh -max_total_time={MAX_FUZZ_TIME}"
        treeherder:
            symbol: Cryptofuzz
            platform: linux32/debug-fuzz

    linux32-tlsfuzz-tls-client:
        description: Linux 32 TLS Client
        dependencies:
            build: build-linux32/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Client)
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client

    linux32-tlsfuzz-tls-server:
        description: Linux 32 TLS Server
        dependencies:
            build: build-linux32/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Server)
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server

    linux32-tlsfuzz-dtls-client:
        description: Linux 32 DTLS Client
        dependencies:
            build: build-linux32/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Client)
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client

    linux32-tlsfuzz-dtls-server:
        description: Linux 32 DTLS Server
        dependencies:
            build: build-linux32/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Server)
            platform: linux32/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server
