xref: /xnu-12377.81.4/tests/unit/mocks/mock_3rd_party.c (revision 043036a2b3718f7f0be807e2870f8f47d3fa0796) !
1 /*
2  * Copyright (c) 2000-2024 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 
29 #include <stdint.h>
30 #include <stdbool.h>
31 
32 #include <firehose/firehose_types_private.h>
33 #include <firehose/tracepoint_private.h>
34 
35 // This usually comes from tightbeam library. This is not needed by the tester so it is mocked here are a no-op
36 void
tb_transport_startup(void)37 tb_transport_startup(void)
38 {
39 }
40 
41 #if !__BUILDING_FOR_COVERAGE__
42 // These __llvm_* functions usually come from cc_kext library and are used for profiling.
43 // This functionality is not needed by the tester so they are mocked here as a no-op to resolve their linking.
44 // linking to cc_kext is not possible because it is compiled with -mkernel
45 // When building unit-tests for coverage, these function come from the user-mode coverage lib, so they shouldn't
46 // be redefined here.
47 uint64_t
__llvm_profile_get_size_for_buffer_internal(const char * DataBegin,const char * DataEnd,const char * CountersBegin,const char * CountersEnd,const char * NamesBegin,const char * NamesEnd)48 __llvm_profile_get_size_for_buffer_internal(const char *DataBegin,
49     const char *DataEnd,
50     const char *CountersBegin,
51     const char *CountersEnd,
52     const char *NamesBegin,
53     const char *NamesEnd)
54 {
55 	return 0;
56 }
57 
58 int
__llvm_profile_write_buffer_internal(char * Buffer,const char * DataBegin,const char * DataEnd,const char * CountersBegin,const char * CountersEnd,const char * NamesBegin,const char * NamesEnd)59 __llvm_profile_write_buffer_internal(char *Buffer,
60     const char *DataBegin,
61     const char *DataEnd,
62     const char *CountersBegin,
63     const char *CountersEnd,
64     const char *NamesBegin,
65     const char *NamesEnd)
66 {
67 	return 0;
68 }
69 #endif // !__BUILDING_FOR_COVERAGE__
70 
71 // These __firehose_* functions usually come from libfirehose_kernel are used for logging
72 // This functionality is not needed and is mocked by the tester, so these functions are mocked as no-op
73 // to resolve their linking.
74 // Linking to libfirehose_kernel is not possible because it is compiled with -mkernel
75 
76 firehose_buffer_t
__firehose_buffer_create(size_t * size)77 __firehose_buffer_create(size_t *size)
78 {
79 	return NULL;
80 }
81 
82 void
__firehose_buffer_tracepoint_flush(firehose_tracepoint_t vat,firehose_tracepoint_id_u vatid)83 __firehose_buffer_tracepoint_flush(firehose_tracepoint_t vat,
84     firehose_tracepoint_id_u vatid)
85 {
86 }
87 
88 firehose_tracepoint_t
__firehose_buffer_tracepoint_reserve(uint64_t stamp,firehose_stream_t stream,uint16_t pubsize,uint16_t privsize,uint8_t ** privptr)89 __firehose_buffer_tracepoint_reserve(uint64_t stamp, firehose_stream_t stream,
90     uint16_t pubsize, uint16_t privsize, uint8_t **privptr)
91 {
92 	return NULL;
93 }
94 
95 int
__firehose_kernel_configuration_valid(uint8_t chunk_count,uint8_t io_pages)96 __firehose_kernel_configuration_valid(uint8_t chunk_count, uint8_t io_pages)
97 {
98 	return 0;
99 }
100 
101 bool
__firehose_merge_updates(firehose_push_reply_t update)102 __firehose_merge_updates(firehose_push_reply_t update)
103 {
104 	return false;
105 }
106 
107 
108