Skip to content

Commit

Permalink
new tc: tc_uboot_check_kconfig.py
Browse files Browse the repository at this point in the history
check for all boards in U-Boot, if patch(es) change(s) the
resulting u-Boot binary.

If a boards U-Boot binary changed by the patch this testcase
fails. Currently checks u-boot.bin and spl/u-boot-spl.bin
(If more needed easy to add)

Use this testcase, if you for example move a config option
into Kconfig, and want to test, if you do not break boards.

Log (with tb.debugstatus = True set, and only one board / arch):
$ python2.7 src/common/tbot.py -c config/tbot_uboot_kconfig_check.cfg -t tc_uboot_check_kconfig.py -l log/tbot.log
**** option cfg: config/tbot_uboot_kconfig_check.cfg log: log/tbot.log tc: tc_uboot_check_kconfig.py v 0
('CUR WORK PATH: ', '/home/hs/data/Entwicklung/tbot')
('CFGFILE ', 'config/tbot_uboot_kconfig_check.cfg')
('LOGFILE ', '/home/hs/data/Entwicklung/tbot/log/tbot.log')
get u-boot source
testing board adp-ag101p 1 / 13
testing board amcore 2 / 13
testing board ap_sh4a_4a 3 / 13
testing board vct_premium 4 / 13
testing board bf527-ezkit 5 / 13
testing board axs103 6 / 13
testing board axs103 first compile failed
testing board atngw100 7 / 13
testing board microblaze-generic 8 / 13
testing board 10m50 9 / 13
testing board openrisc-generic 10 / 13
testing board openrisc-generic first compile failed
testing board sandbox 11 / 13
sandbox u-boot bin diff da4496233033935d13e599de0b6c72e7 != 290b8d52b847b0d01b0c48d7b77b9aef
testing board gr_ep2s60 12 / 13
testing board chromebook_link 13 / 13
Boards      : 13
compile err : 2
not checked : 0
U-Boot good : 10 bad 1
SPL good    : 1 bad 0
('compile err :', ['axs103', 'openrisc-generic'])
('bad         :', ['sandbox'])
End of TBOT: failure

Use for this testcase the tbot config file:
config/tbot_uboot_kconfig_check.cfg

and adapt it to your local settings

Signed-off-by: Heiko Schocher <hs@denx.de>
  • Loading branch information
hsdenx committed Jun 15, 2016
1 parent f40761c commit bd20fca
Show file tree
Hide file tree
Showing 3 changed files with 356 additions and 0 deletions.
102 changes: 102 additions & 0 deletions config/tbot_uboot_kconfig_check.cfg
@@ -0,0 +1,102 @@
# tbot configuration for testing U-Boot patches found in
# tc_workfd_apply_local_patches_dir
# if they do not change the resulting binaries with the
# testcase tc_uboot_check_kconfig.py

# some default settings, not really needed, as we
# do not connect to a boards console
self.boardname = 'none'
self.labprompt='ttbott'
# disable debug output
self.debug=False
self.debugstatus=False
# change ip and user here to your setup
# do not forget to add password.py in tbot rootdir
# test if connect to your lab PC works with "ssh user@ip"
# if you do not have a lab PC use your PC, where you start
# tbot ...
self.ip='pollux.denx.org'
self.user='hs'
self.accept_all=True
self.keepalivetimeout=1
self.channel_timeout=0.5
# may you set here another loglevel for the logfile
self.loglevel='INFO'
# may tc_uboot_check_kconfig.py takes long...
# depends on your machine where you compile
# so adapt this value here
self.wdt_timeout = '5000'
# we do not need to connect to a board, so disable this step
self.do_connect_to_board=False

self.uboot_prompt = 'U-Boot#'
self.linux_prompt = 'ttbott'

# disable event backends
#self.create_dot = 'yes'
#self.create_statistic = 'yes'
#self.create_dashboard = 'yes'
#self.create_html_log = 'yes'

# variables used in testcases, adapt to your local settings
self.tc_workfd_work_dir = '/work/hs/tbot'
self.tc_lab_source_dir = '/work/hs/tbot'
self.tc_lab_get_uboot_source_git_repo = "/home/git/u-boot.git"
self.tc_lab_get_uboot_source_git_branch = "master"
self.tc_lab_compile_uboot_export_path = '/home/hs/dtc'
# adapt here to your local setting, where you have the patch(es)
# on your lab PC you want to test
self.tc_lab_apply_patches_dir = '/work/hs/tbot/patches/dxr2_kconfig_move'
self.tc_workfd_apply_local_patches_checkpatch_cmd_strict = "no"
self.tc_workfd_apply_local_patches_checkpatch_cmd = 'scripts/checkpatch.pl'
self.tc_lab_compile_uboot_makeoptions = '-s -j8'

# to get a fix U-Boot version string, we need a patch ...
# may we import in U-Boot from linux the "scripts/config" script
# so we can edit a .config with tbot (we need to disable
# CONFIG_LOCALVERSION_AUTO to get a constant version string)
# ToDo
# ... you find this patch in tbot:/src/patches/check_kconfig
# move it to your lab PC and say tbot here, where it will find it
self.tc_uboot_check_kconfig_preparepatch = '/work/hs/tbot/patches/check_kconfig'

# setup here, where you have your toolchains
# if you do not have a toolchain for an architecture
# remove the line for it, but the boards from this arch get
# then not tested ... the name of the not tested boards are
# printed at the end of tbot on stdout
self.tc_workfd_set_toolchain_t_p = {
'arc' : '/home/hs/toolchain/arc_gnu_2015.12_prebuilt_uclibc_le_archs_linux_install/bin',
'arm' : '/opt/eldk-5.4/armv5te/sysroots/i686-eldk-linux/usr/bin/armv5te-linux-gnueabi',
'avr32' : '/home/hs/.buildman-toolchains/gcc-4.2.4-nolibc/avr32-linux/bin',
'blackfin' : '/home/hs/toolchain/opt/uClinux/bfin-elf/bin',
'm68k' : '/home/hs/.buildman-toolchains/gcc-4.6.3-nolibc/m68k-linux/bin',
'mips' : '/opt/eldk-5.4/mips/sysroots/i686-eldk-linux/usr/bin/mips32-linux',
'microblaze' : '/home/hs/.buildman-toolchains/gcc-4.9.0-nolibc/microblaze-linux/bin',
'nds32' : '/home/hs/toolchain/nds32le-linux-glibc-v1/bin',
'nios2' : '/home/hs/toolchain/sourceryg++-2015.11/bin',
'openrisc' : '/home/hs/.buildman-toolchains/gcc-4.5.1-nolibc/or32-linux/bin',
'powerpc' : '/opt/eldk-5.4/powerpc/sysroots/i686-eldk-linux/usr/bin/powerpc-linux',
'sandbox' : '/bin',
'sh' : '/home/hs/toolchain/renesas-4.4/bin',
'sparc' : '/home/hs/.buildman-toolchains/gcc-4.9.0-nolibc/sparc-linux/bin',
'x86' : '/home/hs/.buildman-toolchains/gcc-4.6.3-nolibc/i386-linux/bin',
}

self.tc_workfd_set_toolchain_cr_co = {
'arc' : 'arc-linux-uclibc-',
'arm' : 'arm-linux-gnueabi-',
'avr32' : 'avr32-linux-',
'blackfin' : 'bfin-elf-',
'm68k' : 'm68k-linux-',
'mips' : 'mips-linux-',
'microblaze' : 'microblaze-linux-',
'nds32' : 'nds32le-linux-',
'nios2' : 'nios2-linux-gnu-',
'openrisc' : 'or32-linux-',
'powerpc' : 'powerpc-linux-',
'sandbox' : '',
'sh' : 'sh-linux-gnu-',
'sparc' : 'sparc-linux-',
'x86' : 'i386-linux-',
}
29 changes: 29 additions & 0 deletions src/patches/check_kconfig/0001-U-Boot-version-fix.patch
@@ -0,0 +1,29 @@
From 256162f1f2f81993729a42e7ddff449d2b8765dd Mon Sep 17 00:00:00 2001
From: Heiko Schocher <hs@denx.de>
Date: Mon, 13 Jun 2016 19:02:34 +0200
Subject: [PATCH] U-Boot version fix

set a fix U-Boot version number.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
scripts/setlocalversion | 3 +++
1 file changed, 3 insertions(+)

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 63d91e2..688e42a 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -147,6 +147,9 @@ else
exit 1
fi

+echo "-fix"
+exit 0
+
# localversion* files in the build and source directory
res="$(collect_files localversion*)"
if test ! "$srctree" -ef .; then
--
2.5.5

225 changes: 225 additions & 0 deletions src/tc/uboot/tc_uboot_check_kconfig.py
@@ -0,0 +1,225 @@
# This file is part of tbot. tbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# start with
# python2.7 src/common/tbot.py -c config/tbot_dxr2_uboot_kconfig_check.cfg -t tc_uboot_check_kconfig.py
# check for all boards, if a patch changes the u-boot binary
# If U-boot binary changed by the patch this testcase fails.
# use this testcase, if you for example move a config option
# into Kconfig.
import os
from tbotlib import tbot

logging.info("args: %s", tb.tc_uboot_check_kconfig_preparepatch)

#set board state for which the tc is valid
tb.set_board_state("lab")

#delete old u-boot source tree
tb.workfd = tb.c_ctrl
tb.eof_call_tc("tc_workfd_rm_uboot_code.py")

result = True

tmp = tb.tc_lab_apply_patches_dir
tb.tc_lab_apply_patches_dir = 'none'

# call get u-boot source
tb.statusprint("get u-boot source")
tb.eof_call_tc("tc_lab_get_uboot_source.py")

tb.tc_lab_apply_patches_dir = tmp

tb.eof_call_tc("tc_workfd_goto_uboot_code.py")
tb.tc_workfd_get_list_of_files_dir = 'configs'
tb.tc_workfd_get_list_of_files_mask = '*_defconfig'
tb.eof_call_tc("tc_workfd_get_list_of_files_in_dir.py")

# create a list of boards
tb.tc_lab_compile_uboot_list_boardlist = []
for name in tb.list_of_files:
tmp = name.split('_defconfig')
tmp = tmp[0]
tmp = tmp.split(tb.tc_workfd_get_list_of_files_dir + '/')
tmp = tmp[1]
tb.tc_lab_compile_uboot_list_boardlist.append(tmp)

# overwrite board list, if you want to do a
# short test for all supported archs
# nds32 m68k sh mips blackfin arc avr32 microblaze nios2 openrisc sandbox sparc x86
# tb.tc_lab_compile_uboot_list_boardlist = ['adp-ag101p', 'amcore', 'ap_sh4a_4a', 'vct_premium', 'bf527-ezkit', 'axs103', 'atngw100', 'microblaze-generic', '10m50', 'openrisc-generic', 'sandbox', 'gr_ep2s60', 'chromebook_link']

count = 0
good = []
bad = []
good_spl = []
bad_spl = []
not_checked = []
compile_bad = []
for board in tb.tc_lab_compile_uboot_list_boardlist:
count += 1
tb.statusprint("testing board %s %d / %d" % (board, count, len(tb.tc_lab_compile_uboot_list_boardlist)))
ctrl = Connection(self, "tb_ctrl2")
tb.check_open_fd(ctrl)

tb.workfd = ctrl
tb.tc_lab_compile_uboot_boardname = board
tb.eof_call_tc("tc_workfd_goto_uboot_code.py")

# get architecture
tb.tc_workfd_grep_file = tb.tc_workfd_get_list_of_files_dir + '/' + board + '_defconfig'
ret = tb.call_tc("tc_uboot_get_arch.py")
if ret == False:
not_checked.append(board)
tb.statusprint("testing board %s no architecture found" % (board))
del ctrl
continue

# call set toolchain
tb.tc_workfd_set_toolchain_arch = tb.cur_uboot_arch
ret = tb.call_tc("tc_workfd_set_toolchain.py")
if ret == False:
not_checked.append(board)
tb.statusprint("testing board %s setting toolchain failed" % (board))
del ctrl
continue

# set SOURCE_DATE_EPOCH to get reproducable builds
tb.eof_write(ctrl, "export SOURCE_DATE_EPOCH=0")
tb.tbot_expect_prompt(ctrl)

# get rid of differences in U-Boot version string
# Best would be to disable CONFIG_LOCALVERSION_AUTO
# we just patch setlocalverion yet ...
save = tb.tc_lab_apply_patches_dir
tb.tc_lab_apply_patches_dir = tb.tc_uboot_check_kconfig_preparepatch
ret = tb.call_tc("tc_workfd_apply_patches.py")
if ret == False:
tb.statusprint("testing board %s apply preparepatch failed" % (board))
tb.end_tc(False)
tb.tc_lab_apply_patches_dir = save

# call compile u-boot
ret = tb.call_tc("tc_workfd_compile_uboot.py")
if ret == False:
compile_bad.append(board)
tb.statusprint("testing board %s first compile failed" % (board))
tmp = "make mrproper"
tb.eof_write_lx_cmd_check(tb.workfd, tmp)
tb.eof_write_cmd(tb.workfd, 'git reset --hard HEAD')
tb.eof_write_cmd(tb.workfd, 'git clean -f')
del ctrl
continue

uboot_md5sum = 'notread'
uboot_spl_md5sum = 'notread'
# check if u-boot-bin
tb.tc_workfd_check_if_file_exists_name = 'u-boot.bin'
ret = tb.call_tc("tc_workfd_check_if_file_exist.py")
if ret == True:
# calc md5sum
tb.tc_workfd_md5sum_name = tb.tc_workfd_check_if_file_exists_name
tb.call_tc("tc_workfd_md5sum.py")
uboot_md5sum = tb.tc_workfd_md5sum_sum
# check if spl/u-boot-spl.bin
tb.tc_workfd_check_if_file_exists_name = 'spl/u-boot-spl.bin'
ret = tb.call_tc("tc_workfd_check_if_file_exist.py")
if ret == True:
# calc md5sum
tb.tc_workfd_md5sum_name = tb.tc_workfd_check_if_file_exists_name
tb.call_tc("tc_workfd_md5sum.py")
uboot_spl_md5sum = tb.tc_workfd_md5sum_sum

# apply patch
if tb.tc_lab_apply_patches_dir != 'none':
tb.eof_call_tc("tc_workfd_apply_patches.py")

# call compile u-boot
ret = tb.call_tc("tc_workfd_compile_uboot.py")
if ret == False:
compile_bad.append(board)
tb.statusprint("testing board %s second compile failed" % (board))
tmp = "make mrproper"
tb.eof_write_lx_cmd_check(tb.workfd, tmp)
tb.eof_write_cmd(tb.workfd, 'git reset --hard HEAD')
tb.eof_write_cmd(tb.workfd, 'git clean -f')
del ctrl
continue

uboot_patched_md5sum = 'notread'
uboot_spl_patched_md5sum = 'notread'
# check if u-boot-bin
tb.tc_workfd_check_if_file_exists_name = 'u-boot.bin'
ret = tb.call_tc("tc_workfd_check_if_file_exist.py")
if ret == True:
# calc md5sum
tb.tc_workfd_md5sum_name = tb.tc_workfd_check_if_file_exists_name
tb.call_tc("tc_workfd_md5sum.py")
uboot_patched_md5sum = tb.tc_workfd_md5sum_sum
# check if spl/u-boot-spl.bin
tb.tc_workfd_check_if_file_exists_name = 'spl/u-boot-spl.bin'
ret = tb.call_tc("tc_workfd_check_if_file_exist.py")
if ret == True:
# calc md5sum
tb.tc_workfd_md5sum_name = tb.tc_workfd_check_if_file_exists_name
tb.call_tc("tc_workfd_md5sum.py")
uboot_spl_patched_md5sum = tb.tc_workfd_md5sum_sum

# check md5sums
if uboot_md5sum != uboot_patched_md5sum:
logging.error("%s u-boot bin diff %s != %s", board, uboot_md5sum, uboot_patched_md5sum)
tb.statusprint("%s u-boot bin diff %s != %s" % (board, uboot_md5sum, uboot_patched_md5sum))
result = False
bad.append(board)
else:
logging.info("%s u-boot bin same %s == %s", board, uboot_md5sum, uboot_patched_md5sum)
if uboot_md5sum != 'notread':
good.append(board)

if uboot_spl_md5sum != uboot_spl_patched_md5sum:
logging.error("%s u-boot spl bin diff %s != %s", board, uboot_spl_md5sum, uboot_spl_patched_md5sum)
tb.statusprint("%s u-boot bin diff %s != %s" % (board, uboot_md5sum, uboot_patched_md5sum))
result = False
bad_spl.append(board)
else:
logging.info("%s u-boot spl bin same %s == %s", board, uboot_spl_md5sum, uboot_spl_patched_md5sum)
if uboot_spl_md5sum != 'notread':
good_spl.append(board)

# reset base tree
tmp = "make mrproper"
tb.eof_write_lx_cmd_check(tb.workfd, tmp)

if tb.tc_lab_apply_patches_dir != 'none':
tb.eof_write_cmd(tb.workfd, 'git reset --hard HEAD')
tb.eof_write_cmd(tb.workfd, 'git clean -f')

# close connection
del ctrl

# print some statistics
print("Boards : %d" % (count))
print("compile err : %d" % len(compile_bad))
print("not checked : %d" % len(not_checked))
print("U-Boot good : %d bad %d" % (len(good), len(bad)))
print("SPL good : %d bad %d" % (len(good_spl), len(bad_spl)))
if len(compile_bad):
print("compile err :", compile_bad)
if len(not_checked):
print("not checked :", not_checked)
if len(bad):
print("bad :", bad)
if len(bad_spl):
print("bad spl :", bad_spl)

tb.end_tc(result)

0 comments on commit bd20fca

Please sign in to comment.