test-hime 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. # Copyright and license see bottom of this file
  3. GTK_QUERY_IMMODULES_2==`whereis gtk-query-immodules-2.0 | cut -d ' ' -f 2`
  4. if [ ! -x "$GTK_QUERY_IMMODULES_2" ]; then
  5. GTK_QUERY_IMMODULES_2=/usr/lib/`ls /usr/lib | grep linux | grep $(uname -m)`/libgtk2.0-0/gtk-query-immodules-2.0
  6. fi
  7. GTK_QUERY_IMMODULES_3=/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0
  8. if [ ! -x "$GTK_QUERY_IMMODULES_3" ]; then
  9. GTK_QUERY_IMMODULES_3=/usr/lib/`ls /usr/lib | grep linux | grep $(uname -m)`/libgtk-2-0/gtk-query-immodules-3.0
  10. fi
  11. echo \#!/bin/sh > hime-test-shell-env
  12. export HIME_OUTPUT_FILTER=$PWD/filter/nobopomofo
  13. echo "export HIME_OUTPUT_FILTER=$PWD/filter/nobopomofo" >> hime-test-shell-env
  14. UTF8_LOCALE=`locale -a | grep utf8 | tail -n 1`
  15. XIM_NAME=`date +%N | tr -d 0`
  16. GTK_2_TEMP_FILE=$PWD/gtk2
  17. GTK_3_TEMP_FILE=$PWD/gtk3
  18. [ ! -e distro/debian ] && exec echo Please execute '"distro/dev-tools/scripts/test-hime"' under hime directory, thanks.
  19. export PATH=$PWD/src:$PATH
  20. echo "export PATH=$PWD/src:$PATH" >> hime-test-shell-env
  21. export HIME_TABLE_DIR=$PWD/data
  22. echo "export HIME_TABLE_DIR=$PWD/data" >> hime-test-shell-env
  23. export HIME_MODULE_DIR=$PWD/src/modules
  24. echo "export HIME_MODULE_DIR=$PWD/src/modules" >> hime-test-shell-env
  25. export XMODIFIERS=@im=$XIM_NAME
  26. echo "export XMODIFIERS=@im=$XIM_NAME" >> hime-test-shell-env
  27. unset LC_ALL
  28. echo "unset LC_ALL" >> hime-test-shell-env
  29. export LC_CTYPE=$UTF8_LOCALE
  30. echo "export LC_CTYPE=$UTF8_LOCALE" >> hime-test-shell-env
  31. $GTK_QUERY_IMMODULES_2 | grep -v hime > $GTK_2_TEMP_FILE
  32. $GTK_QUERY_IMMODULES_3 | grep -v hime > $GTK_3_TEMP_FILE
  33. LD_LIBRARY_PATH=$PWD/src/im-client/ $GTK_QUERY_IMMODULES_2 $PWD/src/gtk-im/im-hime.so >> $GTK_2_TEMP_FILE
  34. LD_LIBRARY_PATH=$PWD/src/im-client/ $GTK_QUERY_IMMODULES_3 $PWD/src/gtk3-im/im-hime.so >> $GTK_3_TEMP_FILE
  35. export LD_PRELOAD=$PWD/src/im-client/libhime-im-client.so
  36. echo "export LD_PRELOAD=$PWD/src/im-client/libhime-im-client.so" >> hime-test-shell-env
  37. export GTK_IM_MODULE=hime
  38. echo "export GTK_IM_MODULE=hime" >> hime-test-shell-env
  39. echo "PS1=\"\[\e]0;\u@\h: \w\a\]\u@\h:\w (hime-test-env)$ \"" >> hime-test-shell-env
  40. if [ ! -x "$HIME_OUTPUT_FILTER" ]; then
  41. echo Warning! Your filter is not executable. Filter has been turned off automatically.
  42. unset HIME_OUTPUT_FILTER
  43. fi
  44. echo To activate the testing envronment, execute \". hime-test-shell-env\" under this directory
  45. sh $PWD/scripts/hime-user-setup $PWD/data $PWD/src
  46. echo
  47. echo ">>>"
  48. echo
  49. echo "Depending on whether the application is using gtk2 or gtk3, set up the corresponding environmental variable before running target application in the testing environment"
  50. echo
  51. echo "gtk2: export GTK_IM_MODULE_FILE=$GTK_2_TEMP_FILE"
  52. echo "gtk3: export GTK_IM_MODULE_FILE=$GTK_3_TEMP_FILE"
  53. echo
  54. echo ">>>"
  55. echo
  56. ##start hime
  57. HIME_MODULE_DIR=$PWD/src/modules HIME_TABLE_DIR=data LD_LIBRARY_PATH=$PWD/src/im-client/:$PWD/src XMODIFIERS=@im=$XIM_NAME gdb src/hime
  58. # TODO: get tempdir from TMPDIR, TMP, and TEMP
  59. rm $GTK_2_TEMP_FILE $GTK_3_TEMP_FILE /tmp/.hime-$USER/socket-*-$XIM_NAME
  60. rm hime-test-shell-env
  61. # Copyright (C) 2007-2012 Wen-Yen Chuang <caleb AT calno DOT com>
  62. #
  63. # This library is free software; you can redistribute it and/or
  64. # modify it under the terms of the GNU Lesser General Public
  65. # License as published by the Free Software Foundation; either
  66. # version 2.1 of the License, or (at your option) any later version.
  67. #
  68. # This library is distributed in the hope that it will be useful,
  69. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  70. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  71. # Lesser General Public License for more details.
  72. #
  73. # You should have received a copy of the GNU Lesser General Public
  74. # License along with this library; if not, write to the Free Software
  75. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA