enh: add makefile of passwdTest.c for windows

This commit is contained in:
kailixu 2024-11-07 13:43:08 +08:00
parent 05075cb2a0
commit 089456fa5b
2 changed files with 52 additions and 7 deletions

View File

@ -0,0 +1,20 @@
# Makefile.mak for win64
TARGET = passwdTest.exe
CC = cl
CFLAGS = /W4 /EHsc /I"C:\TDengine\include" /D_WINDOWS
LDFLAGS = /link /LIBPATH:"C:\TDengine\driver" taos.lib
SRCS = passwdTest.c
OBJS = $(SRCS:.c=.obj)
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(OBJS) $(LDFLAGS)
.c.obj:
$(CC) $(CFLAGS) /c $<
clean:
del $(OBJS) $(TARGET)

View File

@ -20,12 +20,27 @@
* passwdTest.c * passwdTest.c
* - Run the test case in clear TDengine environment with default root passwd 'taosdata' * - Run the test case in clear TDengine environment with default root passwd 'taosdata'
*/ */
#ifdef WINDOWS
#include <winsock2.h>
#include <windows.h>
#include <stdint.h>
#ifndef PRId64
#define PRId64 "I64d"
#endif
#ifndef PRIu64
#define PRIu64 "I64u"
#endif
#else
#include <inttypes.h> #include <inttypes.h>
#include <unistd.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "taos.h" // TAOS header file #include "taos.h" // TAOS header file
#define nDup 1 #define nDup 1
@ -50,6 +65,16 @@ void sysInfoTest(TAOS *taos, const char *host, char *qstr);
void userDroppedTest(TAOS *taos, const char *host, char *qstr); void userDroppedTest(TAOS *taos, const char *host, char *qstr);
void clearTestEnv(TAOS *taos, const char *host, char *qstr); void clearTestEnv(TAOS *taos, const char *host, char *qstr);
void taosMsleep(int64_t ms) {
if (ms < 0) return;
#ifdef WINDOWS
Sleep(ms);
#else
usleep(ms * 1000);
#endif
}
int nPassVerNotified = 0; int nPassVerNotified = 0;
int nUserDropped = 0; int nUserDropped = 0;
TAOS *taosu[nRoot] = {0}; TAOS *taosu[nRoot] = {0};
@ -283,20 +308,20 @@ void passVerTestMulti(const char *host, char *qstr) {
printf("%s:%d [%d] second(s) elasped, passVer notification received:%d, total:%d\n", __func__, __LINE__, i, printf("%s:%d [%d] second(s) elasped, passVer notification received:%d, total:%d\n", __func__, __LINE__, i,
nPassVerNotified, nConn); nPassVerNotified, nConn);
if (nPassVerNotified >= nConn) break; if (nPassVerNotified >= nConn) break;
sleep(1); taosMsleep(1000);
} }
// close the taos_conn // close the taos_conn
for (int i = 0; i < nRoot; ++i) { for (int i = 0; i < nRoot; ++i) {
taos_close(taos[i]); taos_close(taos[i]);
printf("%s:%d close taos[%d]\n", __func__, __LINE__, i); printf("%s:%d close taos[%d]\n", __func__, __LINE__, i);
// sleep(1); // taosMsleep(1000);
} }
for (int i = 0; i < nUser; ++i) { for (int i = 0; i < nUser; ++i) {
taos_close(taosu[i]); taos_close(taosu[i]);
printf("%s:%d close taosu[%d]\n", __func__, __LINE__, i); printf("%s:%d close taosu[%d]\n", __func__, __LINE__, i);
// sleep(1); // taosMsleep(1000);
} }
fprintf(stderr, "######## %s #########\n", __func__); fprintf(stderr, "######## %s #########\n", __func__);
@ -356,7 +381,7 @@ _REP:
fprintf(stderr, "%s:%d sleep 2 seconds to wait HB take effect\n", __func__, __LINE__); fprintf(stderr, "%s:%d sleep 2 seconds to wait HB take effect\n", __func__, __LINE__);
for (int i = 1; i <= 2; ++i) { for (int i = 1; i <= 2; ++i) {
sleep(1); taosMsleep(1000);
} }
res = taos_query(taos[0], qstr); res = taos_query(taos[0], qstr);
@ -372,7 +397,7 @@ _REP:
queryDB(taosRoot, "alter user user0 sysinfo 1"); queryDB(taosRoot, "alter user user0 sysinfo 1");
fprintf(stderr, "%s:%d sleep 2 seconds to wait HB take effect\n", __func__, __LINE__); fprintf(stderr, "%s:%d sleep 2 seconds to wait HB take effect\n", __func__, __LINE__);
for (int i = 1; i <= 2; ++i) { for (int i = 1; i <= 2; ++i) {
sleep(1); taosMsleep(1000);
} }
if(++nRep < 5) { if(++nRep < 5) {
@ -426,7 +451,7 @@ _loop:
printf("%s:%d [%d] second(s) elasped, user dropped notification received:%d, total:%d\n", __func__, __LINE__, i, printf("%s:%d [%d] second(s) elasped, user dropped notification received:%d, total:%d\n", __func__, __LINE__, i,
nUserDropped, nConn); nUserDropped, nConn);
if (nUserDropped >= nConn) break; if (nUserDropped >= nConn) break;
sleep(1); taosMsleep(1000);
} }
for (int i = 0; i < nTestUsers; ++i) { for (int i = 0; i < nTestUsers; ++i) {