Add mocks for libmosquitto_common

This commit is contained in:
Roger A. Light
2025-08-28 20:07:10 +01:00
parent 5f2717cc9d
commit f497c01ad1
17 changed files with 709 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
add_subdirectory(libcommon)
add_subdirectory(lib)
add_subdirectory(apps)
+24
View File
@@ -0,0 +1,24 @@
add_library(libmosquitto_common_mock OBJECT
libmosquitto_common_mock.hpp
libmosquitto_common_mock.cpp
base64_common_mock.cpp
file_common_mock.cpp
memory_common_mock.cpp
mqtt_common_mock.cpp
password_common_mock.cpp
property_common_mock.cpp
random_common_mock.cpp
strings_common_mock.cpp
time_common_mock.cpp
topic_common_mock.cpp
utf8_common_mock.cpp
)
target_include_directories(libmosquitto_common_mock
PUBLIC
${mosquitto_SOURCE_DIR}
${mosquitto_SOURCE_DIR}/include
${mosquitto_SOURCE_DIR}/lib
${mosquitto_SOURCE_DIR}/test/mock
${mosquitto_SOURCE_DIR}/test/mock/lib
)
+44
View File
@@ -0,0 +1,44 @@
R=../../..
include ${R}/config.mk
.PHONY: all check test-compile test clean
LOCAL_CPPFLAGS+= \
-I../ \
-I${R}/include \
-I${R} \
-I${R}/lib \
-I${R}/test/mock
LOCAL_CXXFLAGS+=-std=c++20 -Wall -ggdb -D TEST_SOURCE_DIR='"$(realpath .)"'
MOCK_OBJS = \
base64_common_mock.o \
file_common_mock.o \
libmosquitto_common_mock.o \
memory_common_mock.o \
mqtt_common_mock.o \
password_common_mock.o \
property_common_mock.o \
random_common_mock.o \
strings_common_mock.o \
time_common_mock.o \
topic_common_mock.o \
utf8_common_mock.o
all : test-compile
test-compile: ${MOCK_OBJS}
check : test
# MOCKS
${MOCK_OBJS} : %.o: %.cpp libmosquitto_common_mock.hpp
$(CROSS_COMPILE)$(CXX) $(LOCAL_CPPFLAGS) $(LOCAL_CXXFLAGS) -c $< -o $@
clean :
-rm -rf *.o *.gcda *.gcno
install:
uninstall:
@@ -0,0 +1,14 @@
#include "libmosquitto_common_mock.hpp"
int mosquitto_base64_encode(const unsigned char *in, size_t in_len, char **encoded)
{
return LibMosquittoCommonMock::get_mock().mosquitto_base64_encode(
in, in_len, encoded);
}
int mosquitto_base64_decode(const char *in, unsigned char **decoded, unsigned int *decoded_len)
{
return LibMosquittoCommonMock::get_mock().mosquitto_base64_decode(
in, decoded, decoded_len);
}
+7
View File
@@ -0,0 +1,7 @@
#include "libmosquitto_common_mock.hpp"
cJSON *mosquitto_properties_to_json(const mosquitto_property *properties)
{
return LibMosquittoCommonMock::get_mock().mosquitto_properties_to_json(
properties);
}
+29
View File
@@ -0,0 +1,29 @@
#include "libmosquitto_common_mock.hpp"
FILE *mosquitto_fopen(const char *path, const char *mode, bool restrict_read)
{
return LibMosquittoCommonMock::get_mock().mosquitto_fopen(
path, mode, restrict_read);
}
char *mosquitto_trimblanks(char *str)
{
return LibMosquittoCommonMock::get_mock().mosquitto_trimblanks(str);
}
char *mosquitto_fgets(char **buf, int *buflen, FILE *stream)
{
return LibMosquittoCommonMock::get_mock().mosquitto_fgets(buf, buflen, stream);
}
int mosquitto_write_file(const char* target_path, bool restrict_read, int (*write_fn)(FILE* fptr, void* user_data), void* user_data, void (*log_fn)(const char* msg))
{
return LibMosquittoCommonMock::get_mock().mosquitto_write_file(
target_path, restrict_read, write_fn, user_data, log_fn);
}
int mosquitto_read_file(const char *file, char **buf, size_t *buflen)
{
return LibMosquittoCommonMock::get_mock().mosquitto_read_file(
file, buf, buflen);
}
@@ -0,0 +1,4 @@
#include "libmosquitto_common_mock.hpp"
LibMosquittoCommonMock::LibMosquittoCommonMock() {};
LibMosquittoCommonMock::~LibMosquittoCommonMock() {};
@@ -0,0 +1,124 @@
#pragma once
#include <gmock/gmock.h>
#include <mosquitto.h>
#include "c_function_mock.hpp"
class LibMosquittoCommonMock : public CFunctionMock<LibMosquittoCommonMock> {
public:
LibMosquittoCommonMock();
virtual ~LibMosquittoCommonMock();
/* base64_common.c */
MOCK_METHOD(int, mosquitto_base64_encode, (const unsigned char *in, size_t in_len, char **encoded));
MOCK_METHOD(int, mosquitto_base64_decode, (const char *in, unsigned char **decoded, unsigned int *decoded_len));
/* cjson_common.c */
MOCK_METHOD(cJSON *, mosquitto_properties_to_json, (const mosquitto_property *properties));
/* file_common.c */
MOCK_METHOD(FILE *, mosquitto_fopen, (const char *path, const char *mode, bool restrict_read));
MOCK_METHOD(char *, mosquitto_trimblanks, (char *str));
MOCK_METHOD(char *, mosquitto_fgets, (char **buf, int *buflen, FILE *stream));
MOCK_METHOD(int, mosquitto_write_file, (const char* target_path, bool restrict_read,
int (*write_fn)(FILE* fptr, void* user_data), void* user_data, void (*log_fn)(const char* msg)));
MOCK_METHOD(int, mosquitto_read_file, (const char *file, char **buf, size_t *buflen));
/* memory_common.c */
MOCK_METHOD(void, mosquitto_memory_set_limit, (size_t lim));
MOCK_METHOD(unsigned long, mosquitto_memory_used, ());
MOCK_METHOD(unsigned long, mosquitto_max_memory_used, ());
MOCK_METHOD(void *, mosquitto_malloc, (size_t size));
MOCK_METHOD(void *, mosquitto_realloc, (void *ptr, size_t size));
MOCK_METHOD(void, mosquitto_free, (void *mem));
MOCK_METHOD(void *, mosquitto_calloc, (size_t nmemb, size_t size));
MOCK_METHOD(char *, mosquitto_strdup, (const char *s));
MOCK_METHOD(char *, mosquitto_strndup, (const char *s, size_t n));
/* mqtt_common.c */
MOCK_METHOD(unsigned int, mosquitto_varint_bytes, (uint32_t word));
/* password_common.c */
MOCK_METHOD(int, mosquitto_pw_new, (struct mosquitto_pw **pw, enum mosquitto_pwhash_type hashtype));
MOCK_METHOD(int, mosquitto_pw_hash_encoded, (struct mosquitto_pw *pw, const char *password));
MOCK_METHOD(int, mosquitto_pw_verify, (struct mosquitto_pw *pw, const char *password));
MOCK_METHOD(void, mosquitto_pw_set_valid, (struct mosquitto_pw *pw, bool valid));
MOCK_METHOD(bool, mosquitto_pw_is_valid, (struct mosquitto_pw *pw));
MOCK_METHOD(int, mosquitto_pw_decode, (struct mosquitto_pw *pw, const char *password));
MOCK_METHOD(const char *, mosquitto_pw_get_encoded, (struct mosquitto_pw *pw));
MOCK_METHOD(int, mosquitto_pw_set_param, (struct mosquitto_pw *pw, int param, int value));
MOCK_METHOD(void, mosquitto_pw_cleanup, (struct mosquitto_pw *pw));
/* property_common.c */
MOCK_METHOD(void, mosquitto_property_free, (mosquitto_property **property));
MOCK_METHOD(void, mosquitto_property_free_all, (mosquitto_property **property));
MOCK_METHOD(unsigned int, mosquitto_property_get_length, (const mosquitto_property *property));
MOCK_METHOD(unsigned int, mosquitto_property_get_length_all, (const mosquitto_property *property));
MOCK_METHOD(int, mosquitto_property_check_command, (int command, int identifier));
MOCK_METHOD(const char *, mosquitto_property_identifier_to_string, (int identifier));
MOCK_METHOD(int, mosquitto_string_to_property_info, (const char *propname, int *identifier, int *type));
MOCK_METHOD(int, mosquitto_property_add_byte, (mosquitto_property **proplist, int identifier, uint8_t value));
MOCK_METHOD(int, mosquitto_property_add_int16, (mosquitto_property **proplist, int identifier, uint16_t value));
MOCK_METHOD(int, mosquitto_property_add_int32, (mosquitto_property **proplist, int identifier, uint32_t value));
MOCK_METHOD(int, mosquitto_property_add_varint, (mosquitto_property **proplist, int identifier, uint32_t value));
MOCK_METHOD(int, mosquitto_property_add_binary, (mosquitto_property **proplist, int identifier, const void *value, uint16_t len));
MOCK_METHOD(int, mosquitto_property_add_string, (mosquitto_property **proplist, int identifier, const char *value));
MOCK_METHOD(int, mosquitto_property_add_string_pair, (mosquitto_property **proplist, int identifier, const char *name, const char *value));
MOCK_METHOD(int, mosquitto_property_check_all, (int command, const mosquitto_property *properties));
MOCK_METHOD(int, mosquitto_property_identifier, (const mosquitto_property *property));
MOCK_METHOD(int, mosquitto_property_type, (const mosquitto_property *property));
MOCK_METHOD(mosquitto_property *, mosquitto_property_next, (const mosquitto_property *proplist));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_byte, (const mosquitto_property *proplist, int identifier, uint8_t *value, bool skip_first));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_int16, (const mosquitto_property *proplist, int identifier, uint16_t *value, bool skip_first));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_int32, (const mosquitto_property *proplist, int identifier, uint32_t *value, bool skip_first));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_varint, (const mosquitto_property *proplist, int identifier, uint32_t *value, bool skip_first));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_binary, (const mosquitto_property *proplist, int identifier, void **value, uint16_t *len, bool skip_first));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_string, (const mosquitto_property *proplist, int identifier, char **value, bool skip_first));
MOCK_METHOD(const mosquitto_property *, mosquitto_property_read_string_pair, (const mosquitto_property *proplist, int identifier, char **name, char **value, bool skip_first));
MOCK_METHOD(int, mosquitto_property_remove, (mosquitto_property **proplist, const mosquitto_property *property));
MOCK_METHOD(int, mosquitto_property_copy_all, (mosquitto_property **dest, const mosquitto_property *src));
MOCK_METHOD(uint8_t, mosquitto_property_byte_value, (const mosquitto_property *property));
MOCK_METHOD(uint16_t, mosquitto_property_int16_value, (const mosquitto_property *property));
MOCK_METHOD(uint32_t, mosquitto_property_int32_value, (const mosquitto_property *property));
MOCK_METHOD(uint32_t, mosquitto_property_varint_value, (const mosquitto_property *property));
MOCK_METHOD(const void *, mosquitto_property_binary_value, (const mosquitto_property *property));
MOCK_METHOD(uint16_t, mosquitto_property_binary_value_length, (const mosquitto_property *property));
MOCK_METHOD(const char *, mosquitto_property_string_value, (const mosquitto_property *property));
MOCK_METHOD(uint16_t, mosquitto_property_string_value_length, (const mosquitto_property *property));
MOCK_METHOD(const char *, mosquitto_property_string_name, (const mosquitto_property *property));
MOCK_METHOD(uint16_t, mosquitto_property_string_name_length, (const mosquitto_property *property));
MOCK_METHOD(unsigned int, mosquitto_property_get_remaining_length, (const mosquitto_property *props));
/* random_common.c */
MOCK_METHOD(int, mosquitto_getrandom, (void *bytes, int count));
/* strings_common.c */
MOCK_METHOD(const char *, mosquitto_strerror, (int mosq_errno));
MOCK_METHOD(const char *, mosquitto_connack_string, (int connack_code));
MOCK_METHOD(const char *, mosquitto_reason_string, (int reason_code));
MOCK_METHOD(int, mosquitto_string_to_command, (const char *str, int *cmd));
/* time_common.c */
MOCK_METHOD(void, mosquitto_time_init, ());
MOCK_METHOD(time_t, mosquitto_time, ());
MOCK_METHOD(void, mosquitto_time_ns, (time_t *s, long *ns));
MOCK_METHOD(long, mosquitto_time_cmp, (time_t t1_s, long t1_ns, time_t t2_s, long t2_ns));
/* topic_common.c */
MOCK_METHOD(int, mosquitto_pub_topic_check, (const char *str));
MOCK_METHOD(int, mosquitto_pub_topic_check2, (const char *str, size_t len));
MOCK_METHOD(int, mosquitto_sub_topic_check, (const char *str));
MOCK_METHOD(int, mosquitto_sub_topic_check2, (const char *str, size_t len));
MOCK_METHOD(int, mosquitto_sub_matches_acl, (const char *acl, const char *sub, bool *result));
MOCK_METHOD(int, mosquitto_sub_matches_acl_with_pattern, (const char *acl, const char *sub, const char *clientid, const char *username, bool *result));
MOCK_METHOD(int, mosquitto_topic_matches_sub, (const char *sub, const char *topic, bool *result));
MOCK_METHOD(int, mosquitto_topic_matches_sub_with_pattern, (const char *sub, const char *topic, const char *clientid, const char *username, bool *result));
MOCK_METHOD(int, mosquitto_topic_matches_sub2, (const char *sub, size_t sublen, const char *topic, size_t topiclen, bool *result));
MOCK_METHOD(int, mosquitto_sub_topic_tokenise, (const char *subtopic, char ***topics, int *count));
MOCK_METHOD(int, mosquitto_sub_topic_tokens_free, (char ***topics, int count));
/* utf8_common.c */
MOCK_METHOD(int, mosquitto_validate_utf8, (const char *str, int len));
};
@@ -0,0 +1,46 @@
#include "libmosquitto_common_mock.hpp"
void mosquitto_memory_set_limit(size_t lim)
{
LibMosquittoCommonMock::get_mock().mosquitto_memory_set_limit(lim);
}
unsigned long mosquitto_memory_used(void)
{
return LibMosquittoCommonMock::get_mock().mosquitto_memory_used();
}
unsigned long mosquitto_max_memory_used(void)
{
return LibMosquittoCommonMock::get_mock().mosquitto_max_memory_used();
}
void *mosquitto_malloc(size_t size)
{
return LibMosquittoCommonMock::get_mock().mosquitto_malloc(size);
}
void *mosquitto_realloc(void *ptr, size_t size)
{
return LibMosquittoCommonMock::get_mock().mosquitto_realloc(ptr, size);
}
void mosquitto_free(void *mem)
{
LibMosquittoCommonMock::get_mock().mosquitto_free(mem);
}
void *mosquitto_calloc(size_t nmemb, size_t size)
{
return LibMosquittoCommonMock::get_mock().mosquitto_calloc(nmemb, size);
}
char *mosquitto_strdup(const char *s)
{
return LibMosquittoCommonMock::get_mock().mosquitto_strdup(s);
}
char *mosquitto_strndup(const char *s, size_t n)
{
return LibMosquittoCommonMock::get_mock().mosquitto_strndup(s, n);
}
+6
View File
@@ -0,0 +1,6 @@
#include "libmosquitto_common_mock.hpp"
unsigned int mosquitto_varint_bytes(uint32_t word)
{
return LibMosquittoCommonMock::get_mock().mosquitto_varint_bytes(word);
}
@@ -0,0 +1,52 @@
#include "libmosquitto_common_mock.hpp"
int mosquitto_pw_new(struct mosquitto_pw **pw, enum mosquitto_pwhash_type hashtype)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_new(
pw, hashtype);
}
int mosquitto_pw_hash_encoded(struct mosquitto_pw *pw, const char *password)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_hash_encoded(
pw, password);
}
int mosquitto_pw_verify(struct mosquitto_pw *pw, const char *password)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_verify(
pw, password);
}
void mosquitto_pw_set_valid(struct mosquitto_pw *pw, bool valid)
{
LibMosquittoCommonMock::get_mock().mosquitto_pw_set_valid(
pw, valid);
}
bool mosquitto_pw_is_valid(struct mosquitto_pw *pw)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_is_valid(pw);
}
int mosquitto_pw_decode(struct mosquitto_pw *pw, const char *password)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_decode(
pw, password);
}
const char *mosquitto_pw_get_encoded(struct mosquitto_pw *pw)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_get_encoded(pw);
}
int mosquitto_pw_set_param(struct mosquitto_pw *pw, int param, int value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pw_set_param(
pw, param, value);
}
void mosquitto_pw_cleanup(struct mosquitto_pw *pw)
{
LibMosquittoCommonMock::get_mock().mosquitto_pw_cleanup(pw);
}
@@ -0,0 +1,229 @@
#include "libmosquitto_common_mock.hpp"
void mosquitto_property_free(mosquitto_property **property)
{
LibMosquittoCommonMock::get_mock().mosquitto_property_free(
property);
}
void mosquitto_property_free_all(mosquitto_property **property)
{
LibMosquittoCommonMock::get_mock().mosquitto_property_free_all(
property);
}
unsigned int mosquitto_property_get_length(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_get_length(
property);
}
unsigned int mosquitto_property_get_length_all(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_get_length_all(
property);
}
int mosquitto_property_check_command(int command, int identifier)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_check_command(
command, identifier);
}
const char *mosquitto_property_identifier_to_string(int identifier)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_identifier_to_string(
identifier);
}
int mosquitto_string_to_property_info(const char *propname, int *identifier, int *type)
{
return LibMosquittoCommonMock::get_mock().mosquitto_string_to_property_info(
propname, identifier, type);
}
int mosquitto_property_add_byte(mosquitto_property **proplist, int identifier, uint8_t value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_byte(
proplist, identifier, value);
}
int mosquitto_property_add_int16(mosquitto_property **proplist, int identifier, uint16_t value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_int16(
proplist, identifier, value);
}
int mosquitto_property_add_int32(mosquitto_property **proplist, int identifier, uint32_t value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_int32(
proplist, identifier, value);
}
int mosquitto_property_add_varint(mosquitto_property **proplist, int identifier, uint32_t value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_varint(
proplist, identifier, value);
}
int mosquitto_property_add_binary(mosquitto_property **proplist, int identifier, const void *value, uint16_t len)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_binary(
proplist, identifier, value, len);
}
int mosquitto_property_add_string(mosquitto_property **proplist, int identifier, const char *value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_string(
proplist, identifier, value);
}
int mosquitto_property_add_string_pair(mosquitto_property **proplist, int identifier, const char *name, const char *value)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_add_string_pair(
proplist, identifier, name, value);
}
int mosquitto_property_check_all(int command, const mosquitto_property *properties)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_check_all(
command, properties);
}
int mosquitto_property_identifier(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_identifier(
property);
}
int mosquitto_property_type(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_type(
property);
}
mosquitto_property *mosquitto_property_next(const mosquitto_property *proplist)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_next(
proplist);
}
const mosquitto_property *mosquitto_property_read_byte(const mosquitto_property *proplist, int identifier, uint8_t *value, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_byte(
proplist, identifier, value, skip_first);
}
const mosquitto_property *mosquitto_property_read_int16(const mosquitto_property *proplist, int identifier, uint16_t *value, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_int16(
proplist, identifier, value, skip_first);
}
const mosquitto_property *mosquitto_property_read_int32(const mosquitto_property *proplist, int identifier, uint32_t *value, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_int32(
proplist, identifier, value, skip_first);
}
const mosquitto_property *mosquitto_property_read_varint(const mosquitto_property *proplist, int identifier, uint32_t *value, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_varint(
proplist, identifier, value, skip_first);
}
const mosquitto_property *mosquitto_property_read_binary(const mosquitto_property *proplist, int identifier, void **value, uint16_t *len, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_binary(
proplist, identifier, value, len, skip_first);
}
const mosquitto_property *mosquitto_property_read_string(const mosquitto_property *proplist, int identifier, char **value, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_string(
proplist, identifier, value, skip_first);
}
const mosquitto_property *mosquitto_property_read_string_pair(const mosquitto_property *proplist, int identifier, char **name, char **value, bool skip_first)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_read_string_pair(
proplist, identifier, name, value, skip_first);
}
int mosquitto_property_remove(mosquitto_property **proplist, const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_remove(
proplist, property);
}
int mosquitto_property_copy_all(mosquitto_property **dest, const mosquitto_property *src)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_copy_all(
dest, src);
}
uint8_t mosquitto_property_byte_value(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_byte_value(
property);
}
uint16_t mosquitto_property_int16_value(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_int16_value(
property);
}
uint32_t mosquitto_property_int32_value(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_int32_value(
property);
}
uint32_t mosquitto_property_varint_value(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_varint_value(
property);
}
const void *mosquitto_property_binary_value(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_binary_value(
property);
}
uint16_t mosquitto_property_binary_value_length(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_binary_value_length(
property);
}
const char *mosquitto_property_string_value(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_string_value(
property);
}
uint16_t mosquitto_property_string_value_length(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_string_value_length(
property);
}
const char *mosquitto_property_string_name(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_string_name(
property);
}
uint16_t mosquitto_property_string_name_length(const mosquitto_property *property)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_string_name_length(
property);
}
unsigned int mosquitto_property_get_remaining_length(const mosquitto_property *props)
{
return LibMosquittoCommonMock::get_mock().mosquitto_property_get_remaining_length(
props);
}
@@ -0,0 +1,7 @@
#include "libmosquitto_common_mock.hpp"
int mosquitto_getrandom(void *bytes, int count)
{
return LibMosquittoCommonMock::get_mock().mosquitto_getrandom(
bytes, count);
}
@@ -0,0 +1,25 @@
#include "libmosquitto_common_mock.hpp"
const char *mosquitto_strerror(int mosq_errno)
{
return LibMosquittoCommonMock::get_mock().mosquitto_strerror(
mosq_errno);
}
const char *mosquitto_connack_string(int connack_code)
{
return LibMosquittoCommonMock::get_mock().mosquitto_connack_string(
connack_code);
}
const char *mosquitto_reason_string(int reason_code)
{
return LibMosquittoCommonMock::get_mock().mosquitto_reason_string(
reason_code);
}
int mosquitto_string_to_command(const char *str, int *cmd)
{
return LibMosquittoCommonMock::get_mock().mosquitto_string_to_command(
str, cmd);
}
+23
View File
@@ -0,0 +1,23 @@
#include "libmosquitto_common_mock.hpp"
void mosquitto_time_init(void)
{
LibMosquittoCommonMock::get_mock().mosquitto_time_init();
}
time_t mosquitto_time(void)
{
return LibMosquittoCommonMock::get_mock().mosquitto_time();
}
void mosquitto_time_ns(time_t *s, long *ns)
{
return LibMosquittoCommonMock::get_mock().mosquitto_time_ns(
s, ns);
}
long mosquitto_time_cmp(time_t t1_s, long t1_ns, time_t t2_s, long t2_ns)
{
return LibMosquittoCommonMock::get_mock().mosquitto_time_cmp(
t1_s, t1_ns, t2_s, t2_ns);
}
+67
View File
@@ -0,0 +1,67 @@
#include "libmosquitto_common_mock.hpp"
int mosquitto_pub_topic_check(const char *str)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pub_topic_check(
str);
}
int mosquitto_pub_topic_check2(const char *str, size_t len)
{
return LibMosquittoCommonMock::get_mock().mosquitto_pub_topic_check2(
str, len);
}
int mosquitto_sub_topic_check(const char *str)
{
return LibMosquittoCommonMock::get_mock().mosquitto_sub_topic_check(
str);
}
int mosquitto_sub_topic_check2(const char *str, size_t len)
{
return LibMosquittoCommonMock::get_mock().mosquitto_sub_topic_check2(
str, len);
}
int mosquitto_sub_matches_acl(const char *acl, const char *sub, bool *result)
{
return LibMosquittoCommonMock::get_mock().mosquitto_sub_matches_acl(
acl, sub, result);
}
int mosquitto_sub_matches_acl_with_pattern(const char *acl, const char *sub, const char *clientid, const char *username, bool *result)
{
return LibMosquittoCommonMock::get_mock().mosquitto_sub_matches_acl_with_pattern(
acl, sub, clientid, username, result);
}
int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result)
{
return LibMosquittoCommonMock::get_mock().mosquitto_topic_matches_sub(
sub, topic, result);
}
int mosquitto_topic_matches_sub_with_pattern(const char *sub, const char *topic, const char *clientid, const char *username, bool *result)
{
return LibMosquittoCommonMock::get_mock().mosquitto_topic_matches_sub_with_pattern(
sub, topic, clientid, username, result);
}
int mosquitto_topic_matches_sub2(const char *sub, size_t sublen, const char *topic, size_t topiclen, bool *result)
{
return LibMosquittoCommonMock::get_mock().mosquitto_topic_matches_sub2(
sub, sublen, topic, topiclen, result);
}
int mosquitto_sub_topic_tokenise(const char *subtopic, char ***topics, int *count)
{
return LibMosquittoCommonMock::get_mock().mosquitto_sub_topic_tokenise(
subtopic, topics, count);
}
int mosquitto_sub_topic_tokens_free(char ***topics, int count)
{
return LibMosquittoCommonMock::get_mock().mosquitto_sub_topic_tokens_free(
topics, count);
}
+7
View File
@@ -0,0 +1,7 @@
#include "libmosquitto_common_mock.hpp"
int mosquitto_validate_utf8(const char *str, int len)
{
return LibMosquittoCommonMock::get_mock().mosquitto_validate_utf8(
str, len);
}