summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTiago Rezende Campos Falcao <developer@tiagofalcao.com>2010-10-27 14:38:40 +0000
committerTiago Rezende Campos Falcao <developer@tiagofalcao.com>2010-10-27 14:38:40 +0000
commit8687aedc100389012b816673a64053d7ff6eb364 (patch)
treeb2bf896cebb20368854e8020d681ad4469971326 /tests
parent9875a4045afbe302fcedabc0fb988b9d61b58218 (diff)
Checkers for API consistence
SVN revision: 53918
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_decl.sh44
-rwxr-xr-xtests/test_eapi.sh40
-rwxr-xr-xtests/test_getter.sh27
-rwxr-xr-xtests/test_setter.sh49
4 files changed, 160 insertions, 0 deletions
diff --git a/tests/test_decl.sh b/tests/test_decl.sh
new file mode 100755
index 0000000..706ffdd
--- /dev/null
+++ b/tests/test_decl.sh
@@ -0,0 +1,44 @@
1#!/bin/bash
2ret=0
3
4check(){
5 i=$1
6 shift
7 sed -n "/^$i(/{g;1!p;};h" $@ >eapi.decl
8 lines=$(wc -l eapi.decl|cut -f1 -d' ')
9 if [ $lines == 0 ]; then
10 echo -e "\e[31;1mNOT IMPLEMENTED\e[m\t $i"
11 ret=1
12 elif [ $lines != 1 ]; then
13 echo -e "\e[31;1mMULTI IMPLEMENTED\e[m\t $i"
14 ret=1
15 else
16 cat eapi.decl | grep -qe '^EAPI'
17 if [ $? != 0 ];then
18 echo -e "\e[31;1mMISSING EAPI\e[m\t $i"
19 ret=1
20 fi
21 fi
22 rm eapi.decl
23}
24
25grep -e "^ *EAPI.*(.*)" src/lib/Elementary.h.in | grep -oe 'elm_\w\+' >eapi.list
26
27for i in $(cat eapi.list); do
28 check $i $(ls -1 src/lib/*.c | grep -v elm_widget | grep -v els_cursor)
29done
30
31grep -e "^ *EAPI.*(.*)" src/lib/Elementary_Cursor.h | grep -oe 'elm_\w\+' >eapi.list
32
33for i in $(cat eapi.list); do
34 check $i src/lib/els_cursor.c src/lib/elm_main.c
35done
36
37grep -e "^ *EAPI.*(.*)" src/lib/elm_widget.h | grep -oe '_\?elm_\w\+' >eapi.list
38
39for i in $(cat eapi.list); do
40 check $i src/lib/elm_widget.c
41done
42
43rm eapi.list
44exit $ret
diff --git a/tests/test_eapi.sh b/tests/test_eapi.sh
new file mode 100755
index 0000000..4a190e5
--- /dev/null
+++ b/tests/test_eapi.sh
@@ -0,0 +1,40 @@
1#!/bin/bash
2ret=0
3
4sed -n '/^EAPI /{n;p;}' src/lib/*.c >eapi.list
5
6for i in $(cat eapi.list|grep -o "^\w\+"); do
7 grep -q "\<$i\>" src/lib/elm_priv.h
8 if [ $? == 0 ]; then
9 echo -e "\e[31;1mEAPI in priv.h\e[m\t $i"
10 ret=1
11 fi
12
13 echo $i | grep -qe '^_\?elm_widget'
14 if [ $? == 0 ]; then
15 grep -qe "EAPI.*\<$i\>" src/lib/elm_widget.h
16 if [ $? != 0 ]; then
17 echo -e "\e[31;1m WIDGET missing in widget.h\e[m\t $i"
18 ret=1
19 fi
20 grep -qe "EAPI.*\<$i\>" src/lib/Elementary.h.in
21 if [ $? == 0 ]; then
22 echo -e "\e[31;1m WIDGET in Elm.h\e[m\t $i"
23 ret=1
24 fi
25 else
26 grep -qe "EAPI.*\<$i\>" src/lib/Elementary.h.in
27 if [ $? != 0 ]; then
28 echo -e "\e[31;1m ELM missing in Elm.h\e[m\t $i"
29 ret=1
30 fi
31 grep -qe "EAPI.*\<$i\>" src/lib/elm_widget.h
32 if [ $? == 0 ]; then
33 echo -e "\e[31;1m ELM in widget.h\e[m\t $i"
34 ret=1
35 fi
36 fi
37done
38
39rm eapi.list
40exit $ret
diff --git a/tests/test_getter.sh b/tests/test_getter.sh
new file mode 100755
index 0000000..749d488
--- /dev/null
+++ b/tests/test_getter.sh
@@ -0,0 +1,27 @@
1#!/bin/bash
2ret=0
3check(){
4 func=$(echo $1 | grep -oe 'elm_\w\+')
5 echo $1 | grep -qe "_get([^\(const \)]\([^,\*)]\)\+\*"
6 if [ $? == 0 ];then
7 echo -e "\e[31;1mNOT CONST\e[m\t $func"
8 ret=1
9 fi
10
11}
12
13HEADERS="src/lib/Elementary.h.in
14src/lib/Elementary_Cursor.h
15src/lib/elm_widget.h"
16
17IFS=$'\n'
18
19for header in $HEADERS; do
20 grep -e "^ *EAPI.*(.*)" $header | grep -e 'elm_\w\+_get' >eapi.list
21
22 for i in $(cat eapi.list); do
23 check $i $header
24 done
25 rm eapi.list
26done
27exit $ret
diff --git a/tests/test_setter.sh b/tests/test_setter.sh
new file mode 100755
index 0000000..2527264
--- /dev/null
+++ b/tests/test_setter.sh
@@ -0,0 +1,49 @@
1#!/bin/bash
2ret=0
3
4check(){
5 func=$(echo $1 | grep -oe 'elm_\w\+')
6 base=${func%_set}
7 echo $1 | grep -qe "_set(const \+[^\(char \+\*\)]"
8 if [ $? == 0 ];then
9 echo -e "\e[31;1mCONST\e[m\t $func"
10 ret=1
11 fi
12 echo $1 | grep -qe "EAPI \+\(void\|Eina_Bool\)"
13 if [ $? != 0 ];then
14 echo -e "\e[31;1mUNKNOWN RETURN\e[m\t $func"
15 ret=1
16 fi
17 echo $1 | grep -qe "\(cb_set\|all_set\)("
18 if [ $? != 0 ];then
19 grep -qe "EAPI.*\<${base}_get\>" $2
20 if [ $? != 0 ];then
21 echo -e "\e[31;1mMISSING GETTER\e[m\t $func"
22 ret=1
23 fi
24 echo $1 | grep -qe "\(content\|icon\|end\)_set(\w\+ \+\*obj, \w\+ \+\*\w\+);"
25 if [ $? == 0 ];then
26 grep -qe "EAPI.*\<${base}_unset\>" $2
27 if [ $? != 0 ];then
28 echo -e "\e[31;1mMISSING UNSETTER\e[m\t $func"
29 ret=1
30 fi
31 fi
32 fi
33}
34
35HEADERS="src/lib/Elementary.h.in
36src/lib/Elementary_Cursor.h
37src/lib/elm_widget.h"
38
39IFS=$'\n'
40
41for header in $HEADERS; do
42 grep -e "^ *EAPI.*(.*)" $header | grep -e 'elm_\w\+_set' >eapi.list
43
44 for i in $(cat eapi.list); do
45 check $i $header
46 done
47 rm eapi.list
48done
49exit $ret