提交 b628b891 编写于 作者: S Shengliang Guan

[TD-992]

上级 9400d5b4
...@@ -30,19 +30,24 @@ int taosFSendFileImp(FILE* out_file, FILE* in_file, int64_t* offset, int32_t ...@@ -30,19 +30,24 @@ int taosFSendFileImp(FILE* out_file, FILE* in_file, int64_t* offset, int32_t
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size) #define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#define taosFSendFile(outfile, infile, offset, count) taosTSendFileImp(fileno(outfile), fileno(infile), offset, size) #define taosFSendFile(outfile, infile, offset, count) taosTSendFileImp(fileno(outfile), fileno(infile), offset, size)
#ifndef TAOS_RANDOM_FILE_FAIL #define taosTRead(fd, buf, count) taosTReadImp(fd, buf, count)
#define taosTRead(fd, buf, count) taosTReadImp(fd, buf, count) #define taosTWrite(fd, buf, count) taosTWriteImp(fd, buf, count)
#define taosTWrite(fd, buf, count) taosTWriteImp(fd, buf, count) #define taosLSeek(fd, offset, whence) lseek(fd, offset, whence)
#define taosLSeek(fd, offset, whence) lseek(fd, offset, whence)
#else #ifdef TAOS_RANDOM_FILE_FAIL
void taosSetRandomFileFailFactor(int factor); void taosSetRandomFileFailFactor(int factor);
void taosSetRandomFileFailOutput(const char *path); void taosSetRandomFileFailOutput(const char *path);
ssize_t taosReadFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line); #ifdef TAOS_RANDOM_FILE_FAIL_TEST
ssize_t taosWriteFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line); ssize_t taosReadFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line);
off_t taosLSeekRandomFail(int fd, off_t offset, int whence, const char *file, uint32_t line); ssize_t taosWriteFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line);
#define taosTRead(fd, buf, count) taosReadFileRandomFail(fd, buf, count, __FILE__, __LINE__) off_t taosLSeekRandomFail(int fd, off_t offset, int whence, const char *file, uint32_t line);
#define taosTWrite(fd, buf, count) taosWriteFileRandomFail(fd, buf, count, __FILE__, __LINE__) #undef taosTRead
#define taosLSeek(fd, offset, whence) taosLSeekRandomFail(fd, offset, whence, __FILE__, __LINE__) #undef taosTWrite
#undef taosLSeek
#define taosTRead(fd, buf, count) taosReadFileRandomFail(fd, buf, count, __FILE__, __LINE__)
#define taosTWrite(fd, buf, count) taosWriteFileRandomFail(fd, buf, count, __FILE__, __LINE__)
#define taosLSeek(fd, offset, whence) taosLSeekRandomFail(fd, offset, whence, __FILE__, __LINE__)
#endif
#endif #endif
// TAOS_OS_FUNC_FILE_GETTMPFILEPATH // TAOS_OS_FUNC_FILE_GETTMPFILEPATH
......
...@@ -46,29 +46,38 @@ void taosTMemset(void *ptr, int c); ...@@ -46,29 +46,38 @@ void taosTMemset(void *ptr, int c);
} \ } \
} while (0); } while (0);
#ifndef TAOS_MEM_CHECK #define taosMalloc(size) malloc(size)
#define taosMalloc(size) malloc(size) #define taosCalloc(num, size) calloc(num, size)
#define taosCalloc(num, size) calloc(num, size) #define taosRealloc(ptr, size) realloc(ptr, size)
#define taosRealloc(ptr, size) realloc(ptr, size) #define taosFree(ptr) free(ptr)
#define taosFree(ptr) free(ptr) #define taosStrdup(str) taosStrdupImp(str)
#define taosStrdup(str) taosStrdupImp(str) #define taosStrndup(str, size) taosStrndupImp(str, size)
#define taosStrndup(str, size) taosStrndupImp(str, size) #define taosGetline(lineptr, n, stream) taosGetlineImp(lineptr, n, stream)
#define taosGetline(lineptr, n, stream) taosGetlineImp(lineptr, n, stream)
#else #ifdef TAOS_MEM_CHECK
void * taos_malloc(size_t size, const char *file, uint32_t line); #ifdef TAOS_MEM_CHECK_TEST
void * taos_calloc(size_t num, size_t size, const char *file, uint32_t line); void * taos_malloc(size_t size, const char *file, uint32_t line);
void * taos_realloc(void *ptr, size_t size, const char *file, uint32_t line); void * taos_calloc(size_t num, size_t size, const char *file, uint32_t line);
void taos_free(void *ptr, const char *file, uint32_t line); void * taos_realloc(void *ptr, size_t size, const char *file, uint32_t line);
char * taos_strdup(const char *str, const char *file, uint32_t line); void taos_free(void *ptr, const char *file, uint32_t line);
char * taos_strndup(const char *str, size_t size, const char *file, uint32_t line); char * taos_strdup(const char *str, const char *file, uint32_t line);
ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char *file, uint32_t line); char * taos_strndup(const char *str, size_t size, const char *file, uint32_t line);
#define taosMalloc(size) taos_malloc(size, __FILE__, __LINE__) ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char *file, uint32_t line);
#define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__) #undef taosMalloc
#define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__) #undef taosCalloc
#define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__) #undef taosRealloc
#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__) #undef taosFree
#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__) #undef taosStrdup
#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__) #undef taosStrndup
#undef taosGetline
#define taosMalloc(size) taos_malloc(size, __FILE__, __LINE__)
#define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__)
#define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__)
#define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__)
#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__)
#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
#endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -35,18 +35,20 @@ extern "C" { ...@@ -35,18 +35,20 @@ extern "C" {
#define taosClose(x) taosCloseSocket(x) #define taosClose(x) taosCloseSocket(x)
#ifdef TAOS_RANDOM_NETWORK_FAIL #ifdef TAOS_RANDOM_NETWORK_FAIL
ssize_t taosSendRandomFail(int sockfd, const void *buf, size_t len, int flags); #ifdef TAOS_RANDOM_NETWORK_FAIL_TEST
ssize_t taosSendToRandomFail(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); ssize_t taosSendRandomFail(int sockfd, const void *buf, size_t len, int flags);
ssize_t taosReadSocketRandomFail(int fd, void *buf, size_t count); ssize_t taosSendToRandomFail(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
ssize_t taosWriteSocketRandomFail(int fd, const void *buf, size_t count); ssize_t taosReadSocketRandomFail(int fd, void *buf, size_t count);
#undef taosSend ssize_t taosWriteSocketRandomFail(int fd, const void *buf, size_t count);
#undef taosSendto #undef taosSend
#undef taosReadSocket #undef taosSendto
#undef taosWriteSocket #undef taosReadSocket
#define taosSend(sockfd, buf, len, flags) taosSendRandomFail(sockfd, buf, len, flags) #undef taosWriteSocket
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) taosSendToRandomFail(sockfd, buf, len, flags, dest_addr, addrlen) #define taosSend(sockfd, buf, len, flags) taosSendRandomFail(sockfd, buf, len, flags)
#define taosReadSocket(fd, buf, len) taosReadSocketRandomFail(fd, buf, len) #define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) taosSendToRandomFail(sockfd, buf, len, flags, dest_addr, addrlen)
#define taosWriteSocket(fd, buf, len) taosWriteSocketRandomFail(fd, buf, len) #define taosReadSocket(fd, buf, len) taosReadSocketRandomFail(fd, buf, len)
#define taosWriteSocket(fd, buf, len) taosWriteSocketRandomFail(fd, buf, len)
#endif
#endif #endif
// TAOS_OS_FUNC_SOCKET // TAOS_OS_FUNC_SOCKET
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "talgo.h" #include "talgo.h"
#include "tchecksum.h" #include "tchecksum.h"
#include "tsdbMain.h" #include "tsdbMain.h"
#include "tutil.h" #include "tutil.h"
#define TAOS_RANDOM_FILE_FAIL_TEST
#ifdef TSDB_IDX #ifdef TSDB_IDX
const char *tsdbFileSuffix[] = {".idx", ".head", ".data", ".last", "", ".i", ".h", ".l"}; const char *tsdbFileSuffix[] = {".idx", ".head", ".data", ".last", "", ".i", ".h", ".l"};
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
*/ */
// no test file errors here // no test file errors here
#undef TAOS_RANDOM_FILE_FAIL
#include "tsdbMain.h" #include "tsdbMain.h"
#include "os.h" #include "os.h"
#include "talgo.h" #include "talgo.h"
...@@ -25,7 +23,6 @@ ...@@ -25,7 +23,6 @@
#include "tsdb.h" #include "tsdb.h"
#include "tulog.h" #include "tulog.h"
#define TSDB_CFG_FILE_NAME "config" #define TSDB_CFG_FILE_NAME "config"
#define TSDB_DATA_DIR_NAME "data" #define TSDB_DATA_DIR_NAME "data"
#define TSDB_META_FILE_NAME "meta" #define TSDB_META_FILE_NAME "meta"
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "tcoding.h" #include "tcoding.h"
#include "tscompression.h" #include "tscompression.h"
#include "tsdbMain.h" #include "tsdbMain.h"
#define TAOS_RANDOM_FILE_FAIL_TEST
#define TSDB_GET_COMPCOL_LEN(nCols) (sizeof(SCompData) + sizeof(SCompCol) * (nCols) + sizeof(TSCKSUM)) #define TSDB_GET_COMPCOL_LEN(nCols) (sizeof(SCompData) + sizeof(SCompCol) * (nCols) + sizeof(TSCKSUM))
#define TSDB_KEY_COL_OFFSET 0 #define TSDB_KEY_COL_OFFSET 0
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "tcoding.h" #include "tcoding.h"
#include "tkvstore.h" #include "tkvstore.h"
#include "tulog.h" #include "tulog.h"
#define TAOS_RANDOM_FILE_FAIL_TEST
#define TD_KVSTORE_HEADER_SIZE 512 #define TD_KVSTORE_HEADER_SIZE 512
#define TD_KVSTORE_MAJOR_VERSION 1 #define TD_KVSTORE_MAJOR_VERSION 1
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
// no test file errors here
#undef TAOS_RANDOM_FILE_FAIL
#include "os.h" #include "os.h"
#include "tulog.h" #include "tulog.h"
#include "tlog.h" #include "tlog.h"
......
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// no test file errors here #include "os.h"
#undef TAOS_RANDOM_FILE_FAIL
#include "tnote.h" #include "tnote.h"
taosNoteInfo m_HttpNote; taosNoteInfo m_HttpNote;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "taoserror.h" #include "taoserror.h"
#include "twal.h" #include "twal.h"
#include "tqueue.h" #include "tqueue.h"
#define TAOS_RANDOM_FILE_FAIL_TEST
#define walPrefix "wal" #define walPrefix "wal"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册