Coverage Report

Created: 2025-11-24 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tpm2-tss/test/fuzz/main-sys.c
Line
Count
Source
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
/***********************************************************************
3
 * Copyright (c) 2018, Intel Corporation
4
 *
5
 * All rights reserved.
6
 ***********************************************************************/
7
#ifdef HAVE_CONFIG_H
8
#include "config.h" // IWYU pragma: keep
9
#endif
10
11
#include <stdbool.h>
12
#include <stdlib.h>
13
14
#define LOGMODULE test
15
#include "tcti/tcti-fuzzing.h"
16
#include "test.h"
17
#include "tss2-sys/sysapi_util.h"
18
#include "tss2_sys.h"
19
#include "tss2_tcti.h"
20
#include "util/log.h"
21
22
#include "test-common.h"
23
24
int
25
438
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
26
438
    TSS2_TEST_SYS_CONTEXT     *test_sys_ctx;
27
438
    TSS2_TCTI_FUZZING_CONTEXT *tcti_fuzzing = NULL;
28
438
    TSS2_RC                    rc;
29
438
    int                        ret;
30
31
438
    ret = test_sys_setup(&test_sys_ctx);
32
438
    if (ret != 0) {
33
438
        return ret;
34
438
    }
35
36
0
    ret = test_sys_checks_pre(test_sys_ctx);
37
0
    if (ret != 0) {
38
0
        return ret;
39
0
    }
40
41
0
    tcti_fuzzing = tcti_fuzzing_context_cast(test_sys_ctx->tcti_ctx);
42
0
    tcti_fuzzing->data = Data;
43
0
    tcti_fuzzing->size = Size;
44
45
0
    rc = test_invoke(test_sys_ctx->sys_ctx);
46
0
    if (rc != 0 && ret != 77) {
47
0
        LOG_ERROR("Test returned %08x", rc);
48
0
        exit(1);
49
0
    }
50
51
0
    ret = test_sys_checks_post(test_sys_ctx);
52
0
    if (ret != 0) {
53
0
        exit(1);
54
0
    }
55
56
0
    test_sys_teardown(test_sys_ctx);
57
58
0
    return 0; // Non-zero return values are reserved for future use.
59
0
}