Added handling of timeout cmd arg for valgrind test. fixed memory leaks.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -12,5 +12,7 @@ aqhome-data.pid
|
|||||||
aqhome-nodes.db
|
aqhome-nodes.db
|
||||||
aqhome-nodes.log
|
aqhome-nodes.log
|
||||||
aqhome-nodes.pid
|
aqhome-nodes.pid
|
||||||
|
aqhome-nodes.vg
|
||||||
|
aqhome-tool.vg
|
||||||
aqhome-mqtt.pid
|
aqhome-mqtt.pid
|
||||||
|
|
||||||
|
|||||||
@@ -157,3 +157,12 @@ void AqHomed_SetDbFile(AQHOMED *aqh, const char *s)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AqHomed_GetTimeout(const AQHOMED *aqh)
|
||||||
|
{
|
||||||
|
return aqh?aqh->timeout:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ void AqHomed_SetPidFile(AQHOMED *aqh, const char *s);
|
|||||||
const char *AqHomed_GetDbFile(const AQHOMED *aqh);
|
const char *AqHomed_GetDbFile(const AQHOMED *aqh);
|
||||||
void AqHomed_SetDbFile(AQHOMED *aqh, const char *s);
|
void AqHomed_SetDbFile(AQHOMED *aqh, const char *s);
|
||||||
|
|
||||||
|
int AqHomed_GetTimeout(const AQHOMED *aqh);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ struct AQHOMED {
|
|||||||
char *logFile;
|
char *logFile;
|
||||||
char *pidFile;
|
char *pidFile;
|
||||||
|
|
||||||
|
int timeout; /* timeout for run e.g. inside valgrind */
|
||||||
|
|
||||||
int nodeAddress;
|
int nodeAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ int AqHomed_Init(AQHOMED *aqh, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aqh->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0);
|
||||||
|
|
||||||
aqh->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR);
|
aqh->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR);
|
||||||
|
|
||||||
_setupDb(aqh, dbArgs);
|
_setupDb(aqh, dbArgs);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void _runService(AQHOMED *aqh);
|
||||||
#ifdef HAVE_SIGNAL_H
|
#ifdef HAVE_SIGNAL_H
|
||||||
static int _setSignalHandlers(void);
|
static int _setSignalHandlers(void);
|
||||||
static int _setupSigAction(struct sigaction *sa, int sig);
|
static int _setupSigAction(struct sigaction *sa, int sig);
|
||||||
@@ -108,10 +109,7 @@ int main(int argc, char **argv)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!stopService) {
|
_runService(aqh);
|
||||||
DBG_DEBUG(NULL, "Next loop");
|
|
||||||
AqHomed_Loop(aqh, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
AqHomed_Fini(aqh);
|
AqHomed_Fini(aqh);
|
||||||
AqHomed_free(aqh);
|
AqHomed_free(aqh);
|
||||||
@@ -124,6 +122,30 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _runService(AQHOMED *aqh)
|
||||||
|
{
|
||||||
|
time_t timeStart;
|
||||||
|
int timeout;
|
||||||
|
|
||||||
|
timeout=AqHomed_GetTimeout(aqh);
|
||||||
|
timeStart=time(NULL);
|
||||||
|
|
||||||
|
while(!stopService) {
|
||||||
|
AqHomed_Loop(aqh, 2000);
|
||||||
|
if (timeout) {
|
||||||
|
time_t now;
|
||||||
|
|
||||||
|
now=time(NULL);
|
||||||
|
if (timeout && ((int)difftime(now, timeStart))>timeout) {
|
||||||
|
DBG_INFO(NULL, "Timeout");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* while */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _setSignalHandlers(void)
|
int _setSignalHandlers(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SIGNAL_H
|
#ifdef HAVE_SIGNAL_H
|
||||||
|
|||||||
@@ -190,10 +190,14 @@ int _doWatch(GWEN_DB_NODE *dbArgs)
|
|||||||
|
|
||||||
void _awaitAndPrintChanges(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds, const char *tmpl)
|
void _awaitAndPrintChanges(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds, const char *tmpl)
|
||||||
{
|
{
|
||||||
|
time_t tStart;
|
||||||
|
|
||||||
|
tStart=time(NULL);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
GWEN_MSG *msg;
|
GWEN_MSG *msg;
|
||||||
|
|
||||||
msg=Utils_WaitForSpecificIpcMessage(epTcp, AQH_MSGTYPE_IPC_DATA_DATACHANGED, timeoutInSeconds);
|
msg=Utils_WaitForSpecificIpcMessage(epTcp, AQH_MSGTYPE_IPC_DATA_DATACHANGED, 2);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
uint16_t code;
|
uint16_t code;
|
||||||
|
|
||||||
@@ -207,6 +211,15 @@ void _awaitAndPrintChanges(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds, const
|
|||||||
GWEN_Msg_free(msg);
|
GWEN_Msg_free(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (timeoutInSeconds) {
|
||||||
|
time_t now;
|
||||||
|
|
||||||
|
now=time(NULL);
|
||||||
|
if ((int)(difftime(now, tStart))>=timeoutInSeconds) {
|
||||||
|
DBG_INFO(NULL, "Timeout");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} /* for */
|
} /* for */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,9 +163,15 @@ int main(int argc, char **argv)
|
|||||||
rv=1;
|
rv=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GWEN_Fini();
|
GWEN_DB_Group_free(dbArgs);
|
||||||
|
|
||||||
AQH_Fini();
|
AQH_Fini();
|
||||||
|
|
||||||
|
GWEN_Gui_SetGui(NULL);
|
||||||
|
GWEN_Gui_free(gui);
|
||||||
|
|
||||||
|
GWEN_Fini();
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ void _freeData(void *bp, void *p)
|
|||||||
|
|
||||||
xmsg=(AQH_MSG_IPC_TAG16*) p;
|
xmsg=(AQH_MSG_IPC_TAG16*) p;
|
||||||
GWEN_Tag16_List_free(xmsg->tagList);
|
GWEN_Tag16_List_free(xmsg->tagList);
|
||||||
|
GWEN_FREE_OBJECT(xmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
18
vg_data.sh
Executable file
18
vg_data.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export AQHOME_LOGLEVEL=info
|
||||||
|
export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
|
# valgrind --tool=memcheck --trace-children=yes -v --log-file=aqf15 --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free --suppressions=../../../../debug/valgrind.supp /usr/local/bin/aqfinance
|
||||||
|
|
||||||
|
# valgrind --tool=memcheck --trace-children=yes -v --log-file=aqhomed.vg --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -T 300
|
||||||
|
|
||||||
|
valgrind \
|
||||||
|
--tool=memcheck --trace-children=yes -v --log-file=aqhome-data.vg --leak-check=full --show-reachable=yes \
|
||||||
|
--track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free \
|
||||||
|
0-build/apps/aqhome-data/aqhome-data \
|
||||||
|
--datafolder=apps/aqhome-data/test/data \
|
||||||
|
-t 127.0.0.1 -P 1899 \
|
||||||
|
-p ./aqhome-data.pid \
|
||||||
|
-T 90
|
||||||
|
|
||||||
15
vg_nodes.sh
Executable file
15
vg_nodes.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export AQHOME_LOGLEVEL=info
|
||||||
|
export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
|
# valgrind --tool=memcheck --trace-children=yes -v --log-file=aqf15 --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free --suppressions=../../../../debug/valgrind.supp /usr/local/bin/aqfinance
|
||||||
|
|
||||||
|
# valgrind --tool=memcheck --trace-children=yes -v --log-file=aqhomed.vg --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -T 300
|
||||||
|
|
||||||
|
valgrind \
|
||||||
|
--tool=memcheck --trace-children=yes -v --log-file=aqhome-nodes.vg --leak-check=full --show-reachable=yes \
|
||||||
|
--track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free \
|
||||||
|
0-build/apps/aqhome-nodes/aqhome-nodes -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid \
|
||||||
|
-T 90
|
||||||
|
|
||||||
25
vg_watch.sh
Executable file
25
vg_watch.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export AQHOME_LOGLEVEL=info
|
||||||
|
export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
|
# valgrind --tool=memcheck --trace-children=yes -v --log-file=aqf15 --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free --suppressions=../../../../debug/valgrind.supp /usr/local/bin/aqfinance
|
||||||
|
|
||||||
|
# valgrind --tool=memcheck --trace-children=yes -v --log-file=aqhomed.vg --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -T 300
|
||||||
|
|
||||||
|
#valgrind \
|
||||||
|
# --tool=memcheck --trace-children=yes -v --log-file=aqhome-mqttlog.vg --leak-check=full --show-reachable=yes \
|
||||||
|
# --track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free \
|
||||||
|
# 0-build/apps/aqhome-mqttlog/aqhome-mqttlog \
|
||||||
|
# -ma 192.168.117.192 -mp 1883 --mqttclientid=AQHOMEMQTTLOGTEST \
|
||||||
|
# -W /tmp/aqhome/mqttlog \
|
||||||
|
# -i apps/aqhome-mqttlog/mqttlog.conf \
|
||||||
|
# -T 30
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
valgrind \
|
||||||
|
--tool=memcheck --trace-children=yes -v --log-file=aqhome-tool.vg --leak-check=full --show-reachable=yes \
|
||||||
|
--track-origins=yes --num-callers=50 --keep-stacktraces=alloc-and-free \
|
||||||
|
0-build/apps/aqhome-tool/aqhome-tool watch \
|
||||||
|
-T 300
|
||||||
Reference in New Issue
Block a user