test-reexec 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/bash
  2. # Test Script for task re-execution
  3. #
  4. # Copyright 2012 Intel Corporation
  5. # All rights reserved.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # DESCRIPTION
  22. # This script is intended to address issues for re-execution of
  23. # tasks. The test results are saved in ./reexeclogs. Force build
  24. # logs are saved with prefix "force". Build failure logs are saved with
  25. # prefix "failed". Log files with prefix "initial" are used to save
  26. # initial build logs for each recipe. Log files with prefix "clean" are
  27. # used to save logs of clean task after testing for a recipe is finished.
  28. #
  29. targets=`bitbake -s | cut -d " " -f 1`
  30. LOGS=./reexeclogs
  31. mkdir -p $LOGS
  32. # Clear sstate files for specified recipe
  33. function clearsstate {
  34. target=$1
  35. sstate_dir=`bitbake $target -e | grep "^SSTATE_DIR" | cut -d "\"" -f 2`
  36. sstate_pkgspec=`bitbake $target -e | grep "^SSTATE_PKGSPEC" | cut -d "\"" -f 2`
  37. sstasks=`bitbake $target -e | grep "^SSTATETASKS" | cut -d "\"" -f 2`
  38. for sstask in $sstasks
  39. do
  40. sstask=${sstask:3}
  41. case $sstask in
  42. populate_sysroot) sstask="populate-sysroot"
  43. ;;
  44. populate_lic) sstask="populate-lic"
  45. ;;
  46. package_write_ipk) sstask="deploy-ipk"
  47. ;;
  48. package_write_deb) sstask="deploy-deb"
  49. ;;
  50. package_write_rpm) sstask="deploy-rpm"
  51. ;;
  52. package) sstask="package"
  53. ;;
  54. deploy) sstask="deploy"
  55. ;;
  56. *)
  57. ;;
  58. esac
  59. echo "Removing ${sstate_dir}/${sstate_pkgspec}*_${sstask}.tgz* for $target"
  60. rm -rf ${sstate_dir}/${sstate_pkgspec}*_${sstask}.tgz*
  61. done
  62. }
  63. # Function to re-execute specified task of recipe
  64. function testit {
  65. target=$1
  66. task=$2
  67. task=`echo $task | sed 's/_setscene//'`
  68. if [ -f $LOGS/force.$target.$task ]; then
  69. return
  70. fi
  71. case $task in
  72. clean|build|cleansstate|cleanall|package|cleansstate2|package_write|package_write_ipk|package_write_rpm|package_write_deb|fetch|populate_lic) return;;
  73. fetchall|devshell|buildall|listtasks|checkuri|checkuriall) return;;
  74. esac
  75. echo "Attempting target $target, task $task"
  76. echo "Initial build"
  77. bitbake $target -c cleansstate > $LOGS/initial.$target.$task
  78. bitbake $target >> $LOGS/initial.$target.$task
  79. clearsstate $target >> $LOGS/initial.$target.$task
  80. echo "Re-execution build"
  81. bitbake $target -c $task -f > $LOGS/force.$target.$task
  82. if [ "$?" != 0 ]; then
  83. echo "FAILURE for $target $task"
  84. cp $LOGS/force.$target.$task $LOGS/failed.$target.$task
  85. bitbake $target -c clean > $LOGS/clean.$target.$task
  86. else
  87. bitbake $target >> $LOGS/force.$target.$task
  88. if [ "$?" != 0 ]; then
  89. echo "FAILURE2 for $target $task"
  90. cp $LOGS/force.$target.$task $LOGS/failed.$target.$task
  91. bitbake $target -c clean > $LOGS/clean.$target.$task
  92. fi
  93. fi
  94. echo "Done"
  95. }
  96. # Go through the recipe list and these recipes' task list
  97. # Then re-execute them
  98. for target in $targets; do
  99. # Remove log messages from bitbake output
  100. case $target in
  101. Summary*|WARNING*|Loading*|Loaded*|Package*|=====*) continue;;
  102. esac
  103. tasks=`bitbake $target -c listtasks | grep ^do_ | sed s/do_//`
  104. for task in $tasks; do
  105. testit $target $task
  106. done
  107. done