Commit e42c3452 authored by root's avatar root

first commit on github

parent e45561e7
This diff is collapsed.
/*
Copyright (c) 2012 Unixmedia S.r.l. <info@unixmedia.it>
Copyright (c) 2012 Franco (nextime) Lanza <franco@unixmedia.it>
Domotika System Domain utils header [http://trac.unixmedia.it]
This file is part of DMDomain.
DMDomain is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DMDOMAIN_H
#define __DMDOMAIN_H
#define DOMAIN_VALIDATION_MATCH
#define DOMAIN_VALIDATION_CONTROL
#define DOMAIN_VALIDATION_CONTROL_SAVE
#ifndef DOMAIN_MAXLEN
#define DOMAIN_MAXLEN (32u)
#endif
#if defined(__GNUC__)
typedef unsigned char BYTE;
#endif
#if defined(DOMAIN_VALIDATION_MATCH) || defined(DOMAIN_VALIDATION_CONTROL) || defined(DOMAIN_VALIDATION_CONTROL_SAVE)
#define DOMAIN_TYPE_MATCH (0x00)
#define DOMAIN_TYPE_CONTROL (0x01)
void ValidateDomainString(BYTE *DomainStr, BYTE DomainType, BYTE DomainLen);
#endif
BYTE DMDomainMatch(BYTE *ControlStr, BYTE *MatchStr, BYTE ControlLen);
#endif
PYINCLUDE=$(shell python-config --includes)
PYINSTALL_PATH=$(shell python -c 'import sys; print [ i for i in sys.path if i.endswith("-packages") ][0]')
MYSQL_LIB=$(shell mysql_config --cflags --libs)
MYSQL_PLUGINDIR=$(shell mysql_config --plugindir)
command:
gcc -Wall -o dmdomain DMDomain.c
all: lib python command
lib:
gcc -Wall -fPIC -c -o libdmdomain.o DMDomain.c
gcc -Wall -shared -o libdmdomain.so libdmdomain.o
pymodulegen:
python modulegen.py > _DMDomain.c
patch -p0 < _DMDomain_fix.patch
python: lib
gcc -Wall -fPIC ${PYINCLUDE} -c -o _DMDomain.o _DMDomain.c
gcc -Wall -shared -o _DMDomain.so -L. -ldmdomain _DMDomain.o
mysql: lib
gcc -Wall ${MYSQL_LIB} -ldmdomain -fPIC -shared -o mysql_udf_dmdomain.so mysql_udf_dmdomain.c
mysql_install: lib_install
install -m 0644 mysql_udf_dmdomain.so ${MYSQL_PLUGINDIR}
lib_install:
install -m 0644 libdmdomain.so /usr/lib
ldconfig
install: lib_install
install -m 0755 dmdomain /usr/bin/
mkdir -p ${PYINSTALL_PATH}/DMDomain
install -m 0644 _DMDomain.so ${PYINSTALL_PATH}/DMDomain/_DMDomain.so
install -m 0644 py/* ${PYINSTALL_PATH}/DMDomain/
debug:
gcc -Wall -DDEBUG -o dmdomain DMDomain.c
clean:
rm -f dmdomain
rm -f libdmdomain*
rm -f _DMDomain.o
rm -f *.so
create function DMDOMAIN returns INTEGER soname 'mysql_udf_dmdomain.so';
/* This file was generated by PyBindGen 0.15.0 */
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <stddef.h>
#if PY_VERSION_HEX < 0x020400F0
#define PyEval_ThreadsInitialized() 1
#define Py_CLEAR(op) \
do { \
if (op) { \
PyObject *tmp = (PyObject *)(op); \
(op) = NULL; \
Py_DECREF(tmp); \
} \
} while (0)
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((PyObject *)(op), arg); \
if (vret) \
return vret; \
} \
} while (0)
#endif
#if PY_VERSION_HEX < 0x020500F0
typedef int Py_ssize_t;
# define PY_SSIZE_T_MAX INT_MAX
# define PY_SSIZE_T_MIN INT_MIN
typedef inquiry lenfunc;
typedef intargfunc ssizeargfunc;
typedef intobjargproc ssizeobjargproc;
#endif
#if __GNUC__ > 2
# define PYBINDGEN_UNUSED(param) param __attribute__((__unused__))
#elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
# define PYBINDGEN_UNUSED(param) __attribute__((__unused__)) param
#else
# define PYBINDGEN_UNUSED(param) param
#endif /* !__GNUC__ */
typedef enum _PyBindGenWrapperFlags {
PYBINDGEN_WRAPPER_FLAG_NONE = 0,
PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED = (1<<0),
} PyBindGenWrapperFlags;
#include "DMDomain.h"
/* --- module functions --- */
PyObject *
_wrap__DMDomainValidateDomainString(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
BYTE *DomainStr;
BYTE DomainType;
BYTE DomainLen;
const char *keywords[] = {"DomainStr", "DomainType", "DomainLen", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "scc", (char **) keywords, &DomainStr, &DomainType, &DomainLen)) {
return NULL;
}
ValidateDomainString(DomainStr, DomainType, DomainLen);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap__DMDomainValidateDomainString(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs);
PyObject *
_wrap__DMDomainDMDomainMatch(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
BYTE retval;
BYTE *ControlStr;
BYTE *MatchStr;
BYTE ControlLen;
const char *keywords[] = {"ControlStr", "MatchStr", "ControlLen", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ssc", (char **) keywords, &ControlStr, &MatchStr, &ControlLen)) {
return NULL;
}
retval = DMDomainMatch(ControlStr, MatchStr, ControlLen);
py_retval = Py_BuildValue((char *) "c", (int) retval);
return py_retval;
}
PyObject * _wrap__DMDomainDMDomainMatch(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs);
static PyMethodDef _DMDomain_functions[] = {
{(char *) "ValidateDomainString", (PyCFunction) _wrap__DMDomainValidateDomainString, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "DMDomainMatch", (PyCFunction) _wrap__DMDomainDMDomainMatch, METH_KEYWORDS|METH_VARARGS, NULL },
{NULL, NULL, 0, NULL}
};
PyMODINIT_FUNC
#if defined(__GNUC__) && __GNUC__ >= 4
__attribute__ ((visibility("default")))
#endif
init_DMDomain(void)
{
PyObject *m;
m = Py_InitModule3((char *) "_DMDomain", _DMDomain_functions, NULL);
if (m == NULL) {
return;
}
}
--- _DMDomain.c 2012-07-02 01:22:25.000000000 +0200
+++ aaa.c 2012-07-02 01:22:19.000000000 +0200
@@ -65,9 +65,9 @@
_wrap__DMDomainValidateDomainString(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
- char *DomainStr;
- char DomainType;
- char DomainLen;
+ BYTE *DomainStr;
+ BYTE DomainType;
+ BYTE DomainLen;
const char *keywords[] = {"DomainStr", "DomainType", "DomainLen", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "scc", (char **) keywords, &DomainStr, &DomainType, &DomainLen)) {
@@ -85,10 +85,10 @@
_wrap__DMDomainDMDomainMatch(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
- char retval;
- char *ControlStr;
- char *MatchStr;
- char ControlLen;
+ BYTE retval;
+ BYTE *ControlStr;
+ BYTE *MatchStr;
+ BYTE ControlLen;
const char *keywords[] = {"ControlStr", "MatchStr", "ControlLen", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ssc", (char **) keywords, &ControlStr, &MatchStr, &ControlLen)) {
File added
#! /usr/bin/env python
import sys
import pybindgen
from pybindgen import ReturnValue, Parameter, Module, Function, FileCodeSink
def my_module_gen(out_file):
mod = Module('_DMDomain')
mod.add_include('"DMDomain.h"')
mod.add_function('ValidateDomainString', None, [
Parameter.new('char*', 'DomainStr', transfer_ownership=False),
Parameter.new('char', 'DomainType'),
Parameter.new('char', 'DomainLen')])
mod.add_function('DMDomainMatch', 'char', [
Parameter.new('char*', 'ControlStr', transfer_ownership=False),
Parameter.new('char*', 'MatchStr', transfer_ownership=False),
Parameter.new('char', 'ControlLen')])
mod.generate(FileCodeSink(out_file) )
if __name__ == '__main__':
my_module_gen(sys.stdout)
/* Copyright (c) 2012, Franco (nextime) Lanza (nextime@nexlab.it). All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifdef STANDARD
/* STANDARD is defined, don't use any mysql functions */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef __WIN__
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
typedef __int64 longlong;
#else
typedef unsigned long long ulonglong;
typedef long long longlong;
#endif /*__WIN__*/
#else
#include <my_global.h>
#include <my_sys.h>
#if defined(MYSQL_SERVER)
#include <m_string.h> /* To get strmov() */
#else
/* when compiled as standalone */
#include <string.h>
#define strmov(a,b) stpcpy(a,b)
#define bzero(a,b) memset(a,0,b)
#endif
#endif
#include <mysql.h>
#include <ctype.h>
#ifdef _WIN32
/* inet_aton needs winsock library */
#pragma comment(lib, "ws2_32")
#endif
#ifdef HAVE_DLOPEN
#include "DMDomain.h"
my_bool DMDOMAIN_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
longlong DMDOMAIN(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error);
void DMDOMAIN_deinit(UDF_INIT *initid);
typedef struct _DMDOMAINS
{
BYTE FirstStr[DOMAIN_MAXLEN];
unsigned long firstlen;
BYTE SecondStr[DOMAIN_MAXLEN];
unsigned long secondlen;
int Reversed;
int FirstIdx;
int SecondIdx;
} DOMAIN_STRUCT;
my_bool DMDOMAIN_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
DOMAIN_STRUCT DomainData;
if (args->arg_count != 2
|| args->arg_type[0] != STRING_RESULT
|| args->arg_type[1] != STRING_RESULT
|| (!args->args[1] && !args->args[0])
)
{
strcpy(message,"DMDOMAIN require 2 string arguments -> DMDOMAIN(matchdomain,controldomain)");
return 1;
}
initid->maybe_null=1;
initid->decimals=0;
initid->max_length=1;
if(args->args[1])
{
// FirstStr is the Control with wildcards
// SecondStr is the Match
DomainData.Reversed=0;
DomainData.FirstIdx=1;
DomainData.SecondIdx=0;
} else {
// SecondStr is the Control with wildcards
// FirstStr is the Match
DomainData.Reversed=1;
DomainData.FirstIdx=0;
DomainData.SecondIdx=1;
}
if( !(initid->ptr = (char *) malloc( sizeof(DomainData) ))) {
strcpy(message,"Couldn't allocate memory!");
return 1;
}
DomainData.firstlen=args->lengths[DomainData.FirstIdx];
if(DomainData.firstlen>DOMAIN_MAXLEN)
DomainData.firstlen=DOMAIN_MAXLEN;
else if(DomainData.firstlen<DOMAIN_MAXLEN)
DomainData.FirstStr[DomainData.firstlen]='\0';
memcpy((char*)DomainData.FirstStr,args->args[DomainData.FirstIdx],(size_t)DomainData.firstlen);
if(DomainData.Reversed) {
ValidateDomainString((BYTE *)DomainData.FirstStr,
(BYTE)DOMAIN_TYPE_MATCH, (BYTE)DomainData.firstlen);
} else {
ValidateDomainString((BYTE *)DomainData.FirstStr,
(BYTE)DOMAIN_TYPE_CONTROL, (BYTE)DomainData.firstlen);
}
//strcpy(message, (const char*)DomainData.FirstStr);
//return 1;
memcpy((char*)initid->ptr, (char*)&DomainData, sizeof(DomainData));
return 0;
}
void DMDOMAIN_deinit(UDF_INIT *initid __attribute__((unused)))
{
if (initid->ptr)
free(initid->ptr);
}
longlong DMDOMAIN(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
{
DOMAIN_STRUCT DomainData;
memcpy((char*)&DomainData, (char*)initid->ptr, sizeof(DomainData));
DomainData.secondlen=args->lengths[DomainData.SecondIdx];
if(DomainData.secondlen>DOMAIN_MAXLEN)
DomainData.secondlen=DOMAIN_MAXLEN;
else if(DomainData.secondlen<DOMAIN_MAXLEN)
DomainData.SecondStr[DomainData.secondlen]='\0';
memcpy((char*)DomainData.SecondStr,
args->args[DomainData.SecondIdx], (size_t)DomainData.secondlen);
if(DomainData.Reversed) {
ValidateDomainString((BYTE *)DomainData.SecondStr,
(BYTE)DOMAIN_TYPE_CONTROL, (BYTE)DomainData.secondlen);
if(DMDomainMatch((BYTE *)DomainData.SecondStr, (BYTE *)DomainData.FirstStr,
(BYTE)strlen((const char*)DomainData.SecondStr)))
return 1;
} else {
ValidateDomainString((BYTE *)DomainData.SecondStr,
(BYTE)DOMAIN_TYPE_MATCH, (BYTE)DomainData.secondlen);
if(DMDomainMatch((BYTE *)DomainData.FirstStr, (BYTE *)DomainData.SecondStr,
(BYTE)strlen((const char*)DomainData.FirstStr)))
return 1;
}
return 0;
}
#endif /* HAVE_DLOPEN */
import struct
import _DMDomain
import copy
DOMAIN_TYPE_MATCH="\x00"
DOMAIN_TYPE_CONTROL="\x01"
def ValidateDomainString(DomainStr, DomainType, DomainLen):
_DMDomain.ValidateDomainString(DomainStr, DomainType, struct.pack('<B', DomainLen))
stend=DomainStr.find("\x00")
if stend==-1:
stend=len(DomainStr)
if stend > 32:
stend=32
DomainStr=copy.deepcopy(DomainStr[0:stend])
return DomainStr
def DMDomainMatch(ControlStr, MatchStr, ControlLen):
return bool(struct.unpack('<B',
_DMDomain.DMDomainMatch(ControlStr, MatchStr, struct.pack('<B',ControlLen)))[0])
#!/bin/bash
##################################################################
# Copyright (c) 2012 Unixmedia S.r.l. <info@unixmedia.it>
# Copyright (c) 2012 Franco (nextime) Lanza <franco@unixmedia.it>
#
# Domotika System Domain unit tester [http://trac.unixmedia.it]
#
# This file is part of DMDomain.
#
# DMDomain is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################
ERED='\e[1;31m'
NO_COLOR='\e[0m'
EGREEN='\e[1;32m'
EYELLOW='\e[1;33m'
EBLUE='\e[1;34m'
EMAGENTA='\e[1;35m'
ECYAN='\e[1;36m'
EWHITE='\e[1;37m'
DEBUG="n"
echo
echo -e "$EWHITE\t\t DOMOTIKA DOMAIN TESTER \t\t$NO_COLOR\n"
if [ -f Makefile ] ; then
make clean
make debug
echo
fi
if [ \! -f ./dmdomain ] ; then
echo "dmdomain binary not found"
exit 1
fi
TCOLS=$(stty -a | tr -s ';' '\n' | grep "column" | sed s/'[^[:digit:]]'//g)
PBMIN=0 # progressbar min value
PBMAX=100 # progressbar max value
PBSYM="=" # symbol used for building the progressbar
PBPERCLEN=7 # length of % string, i.e. "[100%] " => 7 chars
# create the progressbar
function GetPBLine()
{
PBVAL=$1 # current progressbar value (function param)
RVAL=$2
PBUCOLS=$(($TCOLS-$PBPERCLEN-7)) # usable columns
PBNUM=$((($PBVAL*$PBUCOLS)/($PBMAX-$PBMIN)))
for((j=0; j<$PBNUM; j++)); do
PBLINE="$PBLINE$PBSYM"
done
PBPERC=$(printf "[%3d%%] " $PBVAL) # i.e. "[ 12%] "
echo -e "${EBLUE}$PBPERC$PBLINE> $2${NO_COLOR}\r"
echo -ne "\033[K$3 $4 $5 $6\r"
echo -ne "\033[1A\r"
}
c=0
o=0
e=0
p=0
RES=""
FILE=$1
if [ x"$1" = x"verbose" ] ; then
FILE=$2
fi
if [ x"$1" = x"debug" ] ; then
FILE=$2
DEBUG="y"
fi
if [ x"$FILE" = x"" ] ; then
FILE="tests/*.list"
else
if [ \! -f $FILE ] ; then
echo "File $FILE doesn't exists"
exit 0
fi
fi
echo -ne "$(GetPBLine $p $c 'Starting...')\r"
tot=`cat $FILE | grep -v "^#" | grep -v "^$" | wc -l`
for i in `cat $FILE | grep -v "^#" | grep -v "^$" `
do
c=$[ c+1 ]
uno=`echo $i | awk -F ':' '{print $1}'`
due=`echo $i | awk -F ':' '{print $2}'`
tre=`echo $i | awk -F ':' '{print $3}'`
echo -ne "$(GetPBLine $p $c 'RUNNING TEST: ./dmdomain' \'${uno}\' \'${due}\')\r"
totprova=$(./dmdomain "${uno}" "${due}")
prova=`echo -en "$totprova" | tail -n 1`
if [ "$DEBUG" = "y" ] ; then
echo -en "\n\n DEBUG: \n $totprova \n ------------- \n"
fi
if [ ${prova} != ${tre} ] ; then
RES="${RES}\n${ERED}ERROR: ${EYELLOW}$uno ${ECYAN}$due${EMAGENTA} -> $prova${EWHITE} (need: $tre)${NO_COLOR}| ./dmdomain '${uno}' '${due}'"
e=$[ e+1 ]
else
o=$[ o+1 ]
if [ "$1" = "verbose" ] || [ "$1" = "debug" ] ; then
RES="${RES}\n${EGREEN}OK: ${EYELLOW}$uno ${ECYAN}$due${EMAGENTA} -> $prova${EWHITE} (need: $tre)${NO_COLOR}| ./dmdomain '${uno}' '${due}'"
fi
fi
if [ "$DEBUG" = "y" ] ; then
echo -e "$RES"
RES=""
fi
p=$[ c*100/tot ]
echo -ne "$(GetPBLine $p $c 'RUNNING TEST: ./dmdomain' ${uno} ${due})\r"
done
echo -ne "$(GetPBLine 100 $c 'Done.')\r"
echo
echo -ne ${RES}
echo
echo "------------------------------------"
echo "FINAL REPORT:"
echo
pok=$[ o*100/tot ]
per=$[ 100-pok ]
echo -e " TESTS:$ECYAN $c$NO_COLOR - OK:$EGREEN $o ($pok%)$NO_COLOR ERRORS:$ERED $e ($per%)$NO_COLOR"
echo
echo "------------------------------------"
#!/bin/bash
##################################################################
# Copyright (c) 2012 Unixmedia S.r.l. <info@unixmedia.it>
# Copyright (c) 2012 Franco (nextime) Lanza <franco@unixmedia.it>
#
# Domotika System Domain unit tester [http://trac.unixmedia.it]
#
# This file is part of DMDomain.
#
# DMDomain is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################
ERED='\e[1;31m'
NO_COLOR='\e[0m'
EGREEN='\e[1;32m'
EYELLOW='\e[1;33m'
EBLUE='\e[1;34m'
EMAGENTA='\e[1;35m'
ECYAN='\e[1;36m'
EWHITE='\e[1;37m'
DEBUG="n"
echo
echo -e "$EWHITE\t\t DOMOTIKA DOMAIN TESTER \t\t$NO_COLOR\n"
TCOLS=$(stty -a | tr -s ';' '\n' | grep "column" | sed s/'[^[:digit:]]'//g)
PBMIN=0 # progressbar min value
PBMAX=100 # progressbar max value
PBSYM="=" # symbol used for building the progressbar
PBPERCLEN=7 # length of % string, i.e. "[100%] " => 7 chars
# create the progressbar
function GetPBLine()
{
PBVAL=$1 # current progressbar value (function param)
RVAL=$2
PBUCOLS=$(($TCOLS-$PBPERCLEN-7)) # usable columns
PBNUM=$((($PBVAL*$PBUCOLS)/($PBMAX-$PBMIN)))
for((j=0; j<$PBNUM; j++)); do
PBLINE="$PBLINE$PBSYM"
done
PBPERC=$(printf "[%3d%%] " $PBVAL) # i.e. "[ 12%] "
echo -e "${EBLUE}$PBPERC$PBLINE> $2${NO_COLOR}\r"
echo -ne "\033[K$3 $4 $5 $6\r"
echo -ne "\033[1A\r"
}
c=0
o=0
e=0
p=0
RES=""
FILE="tests/*.list"
echo -ne "$(GetPBLine $p $c 'Starting...')\r"
tot=`cat $FILE | grep -v "^#" | grep -v "^$" | wc -l`
for i in `cat $FILE | grep -v "^#" | grep -v "^$" `
do
c=$[ c+1 ]
uno=`echo $i | awk -F ':' '{print $1}'`
due=`echo $i | awk -F ':' '{print $2}'`
tre=`echo $i | awk -F ':' '{print $3}'`
#echo -ne "$(GetPBLine $p $c 'RUNNING TEST:' \'$uno\' \'$due\')\r "
totprova=$(mysql -u$1 -p$2 -e "SELECT IF((select DMDOMAIN('${due}', '${uno}')), TRUE, FALSE)" domotika | tail -n 1)
if [ "$totprova" = "0" ] ; then
provata="False"
else
provata="True"
fi
if [ ${provata} != ${tre} ] ; then
RES="${RES}\n${ERED}ERROR: ${EYELLOW}$uno ${ECYAN}$due${EMAGENTA} -> $provata${EWHITE} (need: $tre)${NO_COLOR}"
e=$[ e+1 ]
#echo
#echo
#echo
#echo $(mysql -u$1 -p$2 -e "SELECT IF((select DMDOMAIN('${due}', '${uno}')), TRUE, FALSE)" domotika )
else
o=$[ o+1 ]
fi
p=$[ c*100/tot ]
echo -ne "$(GetPBLine $p $c 'RUNNING TEST: ' \'$uno\' \'$due\')\r"
done
echo -ne "$(GetPBLine 100 $c 'Done.')\r"
echo
echo -ne ${RES}
echo
echo "------------------------------------"
echo "FINAL REPORT:"
echo
pok=$[ o*100/tot ]
per=$[ 100-pok ]
echo -e " TESTS:$ECYAN $c$NO_COLOR - OK:$EGREEN $o ($pok%)$NO_COLOR ERRORS:$ERED $e ($per%)$NO_COLOR"
echo
echo "------------------------------------"
test:tesa:False
test:testa:False
tes:test:False
test:test:True
test:test.a:False
test.a:test.a:True
test.a:test.ab:False
test.aaa:test.a:False
tes.aaa:test:False
tes:test:False
testa.aaa:test:False
testa:test:False
test.aaa.due:test.aaa:False
test.aaa:test.aaa.due:False
test.aaa:test:False
test..:test:True
test.:test:True
test.:test.:True
test:test.:True
uno.due.tre.quattro:uno.tre.due.quattro:False
uno.due.tre.quattro:uno.due.tre.quattro:True
uno.due.tre.quattro:uno.due.tre:False
uno.due.tre:uno.due.tre.quattro:False
uno.due.tre:uno.due.t:False
uno.due.tre:uno.due.tree:False
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:True
luce.taverna.salagiochi.centrale:luce.taverna.sala.centrale:False
[uno|due]:uno:True
[antani|sarca]:sarca:True
[sarca|antani]:sarca:True
[uno|due]:due:True
[uno|due]:tre:False
[uno]:uno:True
[uno|due|tre]:tre:True
[uno|due|tre]:uno:True
[uno|due|tre]:due:True
[uno|due|tre]:uno.due.tre:False
[uno|due|tre]:un:False
[uno|due|tre]:du:False
[uno|due|tre]:tr:False
[uno|due|tre]:aa:False
[uno|due]:un:False
[uno|due|]:uno:True
[uno|due|]:due:True
[uno].due:due:False
[uno].due:uno:False
[uno].due:uno.due:True
[uno].due:due.due:False
[uno.due]:uno:True
[uno.due]:due:False
[uno|due].tre:uno.tre:True
[uno|due].tre:due.tre:True
[uno|due].tre:un.tre:False
[uno|due].tre:unoo.tre:False
[uno|due].tre.quattro:uno.tre.quattro:True
[uno|due].tre.quattro:due.tre:False
[uno|due].tre.quattro:due.tre.quattro:True
[uno|due].due.[tre|ant].rim:uno.due.tre.rim:True
!:*:False
*:a]:True
*.!*:antani.sarca.pippo:True
!test.aaa.[*].![aa|sarca].[antani|sarca]:sarca.aaa.f.bb.anta:True
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:True
[*].[*].!anta.[sa|pt].![pt|aa].*:pro.o.en.sa.ff.htyf.mg:True
[*].[*].!anta.[sa|pt].![pt|aa].*:pro.o.en.a.ff.htyf.mg:False
prova.![sarca|sarc].pippo.a:prov.swefe.pippo.a:False
prov.![sarca|sarc].pippo.a:prov.swefe.pippo.a:True
luce.![sarca|antani]:luce.antani:False
luce.![sarca|antani]:luce.sarca:False
*.!padr.*:tapp.p1.camera.padr.ovest:False
*.padr.*:tapp.p1.camera.padre.ovest:False
*.!padr.*:tapp.p1.camera.padre.ovest:True
*.!padr.*:tapp.pt.ufficio:True
*.!padr.anta:app.pt.ufficio:False
*.!padr.anta:app.pt.ufficio.sar:False
*.!padr.anta:app.pt.padr:False
*.!padr.anta:app.pt.padr.anta:False
*.!padr.anta:app.pt.pad.anta:True
*.!padr.anta:app.pt.padrr.anta:True
*.!padr.anta:app.pt.pade.anta:True
*.!padr.anta:app.pt.pade.antr:False
*.!padr:tapp.p1.camera.padr.ovest:True
*.!padr:tapp.p1.camera.eee:True
*.![padr|pade]:tapp.p1.camera.eee:True
*.![padr|pade]:tapp.p1.camera.pade:False
*.![padr|pade]:tapp.p1.camera.pad:True
*.![padr|pade]:tapp.p1.camera.padr:False
*.![padr|pade]:tapp.p1.camera.padre:True
*.![padr|pade].*:tapp.p1.camera.padr.ovest:False
*.![padr|pade].*:tapp.p1.camera.padre.ovest:True
*.![padr|pade].*:tapp.p1.pade.padre.ovest:False
*.[uno|due].*:prova.uno.cinque:True
*.[uno|due].*:prova.due.cinque:True
*.[uno|due|tre].*:prova.due.cinque:True
*.[uno|due|tre].*:prova.uno.cinque:True
*.[uno|due|tre].*:prova.tre.cinque:True
*.[sarca|prova].*:prova.due.cinque:False
test.!a:test.a:False
luce.!antani:luce.antani:False
test.!aa:test.d:True
test.!:test:True
test.!:test.!:True
test.!a:test.d:True
test.!aa:test.d:True
test.!aa:test.aa:False
test.!aa:test.a:True
test.!ab:test.ac:True
test.!aaa:test.aab:True
test.!aaa:test.aa:True
test.!aa:test.aaa:True
test.!aa:test.!aaa:False
test.!:test.!aaa:True
test.!aa:test.aba:True
test.!aa:test.aab:True
test.!aa:test.ab.aaa:False
test.!aa:test.ab:True
test.!aa.due:test.aief.due:True
test.!aa.due:test.aa.due:False
test.!aa.due:test.a.due:True
!test:test:False
!test:anta:True
!test.anta:test.anta:False
!test.!anta:anta.test:True
!test.!anta:!anta.test:False
!test.!anta:sarca.biga:True
!test.!anta:!test.!anta:False
!123456789A123456789B123456789C1:123456789A123456789B123456789C1:False
!123456789A123456789B123456789C1:123456789A123456789B123456789C12:True
!123456789A123456789B123456789C1:123456789A123456789B123456789C1X:True
!123456789A123456789B123456789C1:123456789A123456789B123456789CX:True
uno.!due.tre.!quattro:uno.due.tre.qua:False
uno.!due.tre.!quattro:uno.due.tre.quattro:False
uno.!due.tre.!quattro:uno.due.tre.quattroo:False
uno.!due.tre.!quattro:uno.tre:False
!uno.!due.!tre.!quattro:quattro.tre.due.uno:True
![uno|due]:uno:False
![uno|due]:due:False
![uno|due]:tre:True
![uno]:uno:False
![uno].tre:un.tre:True
![uno].tre:unoo.tre:True
![uno|due].tre:uni.tre:True
![uno|due|tre]:tre:False
![uno|due|tre]:uno:False
![uno|due|tre]:due:False
![uno|due|tre]:uno.due.tre:False
![uno|due|tre]:un:True
![uno|due|tre]:du:True
![uno|due|tre]:tr:True
![uno|due|tre]:aa:True
![aaa|bbb|ccc].tre:ccc.tre:False
![aaa|bbb|ccc].tre:bbb.tre:False
![aaa|bbb|ccc].tre:aaa.tre:False
![uno|due]:un:True
![uno|due|]:uno:False
![uno|due|]:due:False
![uno].due:due:False
![uno].due:uno:False
![uno].due:uno.due:False
![uno].due:due.due:True
![uno.due]:uno:False
![uno.due]:due:True
![uno|due].tre:uno.tre:False
![uno|due].tre:due.tre:False
![uno|due].tre:un.tre:True
![uno|due].tre:unoo.tre:True
![uno|due].tre.quattro:uno.tre.quattro:False
![uno|due].tre.quattro:due.tre:False
![uno|due].tre.quattro:due.tre.quattro:False
![uno].![due|tre].![aaa|bbb|ccc|ddd]:aaa.bbb.due.tre:False
![uno].![due|tre].![aaa|bbb|ccc|ddd]:aaa.bbb.due:True
![uno].![due|tre].![aaa|bbb|ccc|due]:aaa.bbb.ccc:False
![uno].![due|tre].![aaa|bbb|ccc|ddd]:aaa.tre.due:False
![uno].![due|tre].![aaa|bbb|ccc|ddd]:aa.bb.du:True
![uno].![due|tre].![aaa|bbb|ccc|ddd]:aaaf.bbbe.due:True
*::False
*:anta:True
*:antani.sarca:True
*:anta.*:True
*:!:False
*:a]:True
.*::False
.*:a:False
*.prova:a:False
*.prova:a.anta.sarca.prova:True
*.prova:prova:False
*.prova:a.prova:True
*.prova:antani.prova:True
*.prova:tani.provaz:False
*.prova:tani.pro:False
antani*.prova:antani.prova:False
antani*.prova:antani*.prova:True
antani*.prova:antani:True
antani.*:antani.prova:True
antani.*.*.sarca:antani.prova.pippo.ciao:False
*.*:antani:True
*.*.antani:antani:False
*.*:antani.sarca:True
*.*:antani.sarca.pippo:True
*.!*:antani.sarca.pippo:True
*.prova:a.kprovdkk:False
*.prova:a.pro:False
*.prova:a.provd:False
*.a:aa.b.b.b.b.b.b.b.b.b.b.b.b.b.b.a:True
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.*:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.b:True
*:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.b:True
*.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.b:False
*.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:b.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:True
*.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:False
*.aaa:ccc.aaaaaaaaaaaaaaaaaaaaaaaaaaaa:False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment