blob: fccdac4da637ac990771f0c54735de3063120135 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006#
Brad Bishopc342db32019-05-15 21:57:59 -04007# SPDX-License-Identifier: GPL-2.0-or-later
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008#
9# DESCRIPTION
10# This script is intended to address issues for re-execution of
11# tasks. The test results are saved in ./reexeclogs. Force build
12# logs are saved with prefix "force". Build failure logs are saved with
13# prefix "failed". Log files with prefix "initial" are used to save
14# initial build logs for each recipe. Log files with prefix "clean" are
15# used to save logs of clean task after testing for a recipe is finished.
16#
17
18targets=`bitbake -s | cut -d " " -f 1`
19
20LOGS=./reexeclogs
21
22mkdir -p $LOGS
23
24# Clear sstate files for specified recipe
25function clearsstate {
26 target=$1
27
Brad Bishopd7bf8c12018-02-25 22:55:05 -050028 sstate_dir=`bitbake $target -e | grep "^SSTATE_DIR=" | cut -d "\"" -f 2`
29 sstate_pkgspec=`bitbake $target -e | grep "^SSTATE_PKGSPEC=" | cut -d "\"" -f 2`
30 sstasks=`bitbake $target -e | grep "^SSTATETASKS=" | cut -d "\"" -f 2`
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
32 for sstask in $sstasks
33 do
34 sstask=${sstask:3}
35 case $sstask in
36 populate_sysroot) sstask="populate-sysroot"
37 ;;
38 populate_lic) sstask="populate-lic"
39 ;;
40 package_write_ipk) sstask="deploy-ipk"
41 ;;
42 package_write_deb) sstask="deploy-deb"
43 ;;
44 package_write_rpm) sstask="deploy-rpm"
45 ;;
46 package) sstask="package"
47 ;;
48 deploy) sstask="deploy"
49 ;;
50 *)
51 ;;
52 esac
53
54 echo "Removing ${sstate_dir}/${sstate_pkgspec}*_${sstask}.tgz* for $target"
55 rm -rf ${sstate_dir}/${sstate_pkgspec}*_${sstask}.tgz*
56 done
57}
58
59# Function to re-execute specified task of recipe
60function testit {
61 target=$1
62 task=$2
63
64 task=`echo $task | sed 's/_setscene//'`
65
66 if [ -f $LOGS/force.$target.$task ]; then
67 return
68 fi
69
70 case $task in
71 clean|build|cleansstate|cleanall|package|cleansstate2|package_write|package_write_ipk|package_write_rpm|package_write_deb|fetch|populate_lic) return;;
72 fetchall|devshell|buildall|listtasks|checkuri|checkuriall) return;;
73 esac
74
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
97# Go through the recipe list and these recipes' task list
98# Then re-execute them
99for target in $targets; do
100 # Remove log messages from bitbake output
101 case $target in
102 Summary*|WARNING*|Loading*|Loaded*|Package*|=====*) continue;;
103 esac
104 tasks=`bitbake $target -c listtasks | grep ^do_ | sed s/do_//`
105 for task in $tasks; do
106 testit $target $task
107 done
108done
109
110