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