Merge pull request #27579 from taosdata/enh/TD-31556-3.0
enh: add assert CI test case
This commit is contained in:
commit
f9f8c42bc8
|
@ -39,7 +39,6 @@ typedef void (*_ref_fn_t)(const void *pObj);
|
|||
// set the initial reference count value
|
||||
#define T_REF_INIT_VAL(x, _v) \
|
||||
do { \
|
||||
assert(_v >= 0); \
|
||||
atomic_store_32(&((x)->_ref.val), (_v)); \
|
||||
} while (0)
|
||||
|
||||
|
@ -64,8 +63,6 @@ typedef void (*_ref_fn_t)(const void *pObj);
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define T_REF_VAL_CHECK(x) assert((x)->_ref.val >= 0);
|
||||
|
||||
#define T_REF_VAL_GET(x) (x)->_ref.val
|
||||
|
||||
// single writer multiple reader lock
|
||||
|
|
|
@ -787,9 +787,6 @@ void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) {
|
|||
|
||||
STrashElem *pElem = pCacheObj->pTrash;
|
||||
while (pElem) {
|
||||
T_REF_VAL_CHECK(pElem->pData);
|
||||
// A S S E R T(pElem->next != pElem && pElem->prev != pElem);
|
||||
|
||||
if (force || (T_REF_VAL_GET(pElem->pData) == 0)) {
|
||||
uDebug("cache:%s, key:%p, %p removed from trashcan. numOfElem in trashcan:%d", pCacheObj->name, pElem->pData->key,
|
||||
pElem->pData->data, pCacheObj->numOfElemsInTrash - 1);
|
||||
|
|
|
@ -455,9 +455,7 @@ static void taosLockList(int64_t *lockedBy) {
|
|||
|
||||
static void taosUnlockList(int64_t *lockedBy) {
|
||||
int64_t tid = taosGetSelfPthreadId();
|
||||
if (atomic_val_compare_exchange_64(lockedBy, tid, 0) != tid) {
|
||||
ASSERTS(false, "atomic_val_compare_exchange_64 tid failed");
|
||||
}
|
||||
(void)atomic_val_compare_exchange_64(lockedBy, tid, 0);
|
||||
}
|
||||
|
||||
static void taosInitRefModule(void) { (void)taosThreadMutexInit(&tsRefMutex, NULL); }
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
# List of source directories to search
|
||||
source_dirs = [
|
||||
"community/source",
|
||||
"community/include",
|
||||
"enterprise/src/plugins/"
|
||||
]
|
||||
|
||||
# List of directories to exclude
|
||||
exclude_dirs = [
|
||||
"community/source/client/jni"
|
||||
]
|
||||
|
||||
# List of files to exclude
|
||||
exclude_source_files = [
|
||||
"community/source/libs/parser/src/sql.c",
|
||||
"community/source/util/src/tlog.c",
|
||||
"community/include/util/tlog.h"
|
||||
]
|
||||
|
||||
def grep_asserts_in_file(file_path, summary_list, detaild_list):
|
||||
"""Search for assert, ASSERTS, or ASSERT function calls in a file and print them."""
|
||||
match_count = 0
|
||||
with open(file_path, 'r') as file:
|
||||
for line_number, line in enumerate(file, start=1):
|
||||
if re.search(r'\bassert\(.*\)|\bASSERT\(.*\)|\bASSERTS\(.*\)|\bASSERT_CORE\(.*\)', line):
|
||||
detaild_list.append(f"{file_path}:{line_number}: {line.strip()}")
|
||||
match_count += 1
|
||||
if match_count > 0:
|
||||
summary_list.append(f"Total matches in {file_path}: {match_count}")
|
||||
|
||||
def traverse_and_grep(source_dirs, exclude_dirs, exclude_source_files):
|
||||
"""Traverse directories and grep for assert, ASSERTS, or ASSERT function calls in .h and .c files."""
|
||||
summary_list = []
|
||||
detaild_list = []
|
||||
for source_dir in source_dirs:
|
||||
for root, _, files in os.walk(source_dir):
|
||||
# Skip directories named 'test' or 'tests' and directories in exclude_dirs
|
||||
if 'test' in root.split(os.sep) or 'tests' in root.split(os.sep) or any(excluded in root for excluded in exclude_dirs):
|
||||
continue
|
||||
for file in files:
|
||||
if file.endswith((".h", ".c")):
|
||||
file_path = os.path.join(root, file)
|
||||
if file_path not in exclude_source_files:
|
||||
grep_asserts_in_file(file_path, summary_list, detaild_list)
|
||||
return summary_list, detaild_list
|
||||
|
||||
if __name__ == "__main__":
|
||||
summary_list, detaild_list = traverse_and_grep(source_dirs, exclude_dirs, exclude_source_files)
|
||||
print("\n".join(summary_list))
|
||||
# print("\n".join(detaild_list))
|
Loading…
Reference in New Issue