Translation update done using Pootle.
[gammu.git] / tests / gen-include-test.sh
bloba1fe993da0c8035477d406fc652ca73fbd8545e0
1 #!/bin/sh
3 # Generates set of files which simply include one of Gammu headers
4 # This verifies
5 # - header completeness
6 # - header reneterability
8 tmpcmake=`mktemp`
9 start='# Auto generated include tests begin'
10 end='# Auto generated include tests end'
12 cecho() {
13 echo "$@" >> $tmpcmake
16 cecho "$start"
17 cecho "# Do not modify this section, change gen-include-test.sh instead"
19 for x in `ls ../include/ | grep -v gammu.h | grep -v CMake` ; do
20 noext=${x%.h}
21 base=${noext#gammu-}
22 filename=include-$base.c
23 executable=include-$base
25 echo "/* Automatically generated test for validating header file $x */"
26 echo "/* See gen-include-test.sh for details */"
27 echo
28 echo "#include <$x>"
29 echo "#include <$x>"
30 echo
31 echo "/* We do not want to push another header, so we need to copy definiton of UNUSED */"
32 echo "#ifndef UNUSED"
33 echo "# if __GNUC__"
34 echo "# define UNUSED __attribute__ ((unused))"
35 echo "# else"
36 echo "# define UNUSED"
37 echo "# endif"
38 echo "#endif"
39 echo
40 echo "int main(int argc UNUSED, char **argv UNUSED)"
41 echo "{"
42 echo " return 0;"
43 echo "}"
44 ) > $filename
47 cecho
48 cecho "# Test for header $x"
49 cecho "add_executable($executable $filename)"
50 cecho "target_link_libraries($executable libGammu \${LIBINTL_LIBRARIES})"
51 cecho "add_test($executable \"\${GAMMU_TEST_PATH}/$executable\${GAMMU_TEST_SUFFIX}\")"
53 done
55 cecho
56 cecho "$end"
58 umask 077
59 sed -e "/^$start/,/^$end/{
60 /^$start/r $tmpcmake
63 " CMakeLists.txt > CMakeLists.txt.new
64 cat CMakeLists.txt.new > CMakeLists.txt
65 rm -f $tmpcmake CMakeLists.txt.new