aqhome-react: added program rules with test code.

This commit is contained in:
Martin Preuss
2024-04-26 01:29:27 +02:00
parent 2342dfbe4a
commit c9d82cc88e
8 changed files with 733 additions and 13 deletions

View File

@@ -15,6 +15,7 @@
#include "./loop.h"
#include "./net_read.h"
#include "aqhome-react/units/u_timer.h"
#include "aqhome-react/types/prgrule-t.h"
#include "aqhome/aqhome.h"
@@ -25,6 +26,7 @@
#include <gwenhywfar/debug.h>
#include <gwenhywfar/cgui.h>
#include <gwenhywfar/text.h>
#include <gwenhywfar/testframework.h>
#ifdef HAVE_SIGNAL_H
# include <signal.h>
@@ -60,6 +62,7 @@
*/
static void _serve(AQHOME_REACT *aqh);
static int _testModules(int argc, char **argv);
#ifdef HAVE_SIGNAL_H
static int _setSignalHandlers(void);
@@ -107,24 +110,32 @@ int main(int argc, char **argv)
return 2;
}
gui=GWEN_Gui_CGui_new();
aqh=AqHomeReact_new();
rv=AqHomeReact_Init(aqh, argc, argv);
dbArgs=AqHomeReact_GetDbArgs(aqh);
DBG_ERROR(NULL, "RV=%d", rv);
if (rv<0) {
if (rv==GWEN_ERROR_CLOSE)
return 1;
DBG_INFO(NULL, "here (%d)", rv);
return 2;
}
else if (rv>0) {
argc-=rv;
argv+=rv;
rv=_testModules(argc, argv);
}
else {
s=GWEN_DB_GetCharValue(dbArgs, "charset", 0, NULL);
if (s && *s)
GWEN_Gui_SetCharSet(gui, s);
GWEN_Gui_SetGui(gui);
dbArgs=AqHomeReact_GetDbArgs(aqh);
gui=GWEN_Gui_CGui_new();
s=GWEN_DB_GetCharValue(dbArgs, "charset", 0, NULL);
if (s && *s)
GWEN_Gui_SetCharSet(gui, s);
GWEN_Gui_SetGui(gui);
_serve(aqh);
_serve(aqh);
rv=0;
}
AqHomeReact_Fini(aqh);
AqHomeReact_free(aqh);
@@ -132,7 +143,7 @@ int main(int argc, char **argv)
GWEN_Gui_SetGui(NULL);
GWEN_Gui_free(gui);
return 0;
return rv;
}
@@ -273,4 +284,39 @@ void _signalHandler(int s)
int _testModules(int argc, char **argv)
{
GWEN_GUI *gui;
GWEN_TEST_FRAMEWORK *tf;
int rv;
gui=GWEN_Gui_CGui_new();
GWEN_Gui_SetGui(gui);
tf=TestFramework_new();
rv=AQHREACT_PrgRule_AddTests(TestFramework_GetModulesRoot(tf));
if (rv<0) {
fprintf(stderr, "Adding module failed.\n");
return 2;
}
argc--;
argv++;
rv=TestFramework_Run(tf, argc, argv);
if (rv) {
fprintf(stderr, "SomeError in tests failed.\n");
GWEN_Gui_SetGui(NULL);
GWEN_Gui_free(gui);
return 2;
}
TestFramework_free(tf);
GWEN_Gui_SetGui(NULL);
GWEN_Gui_free(gui);
return 0;
}