Skip to content

Instantly share code, notes, and snippets.

@victoredwardocallaghan
Created November 15, 2014 11:14
Show Gist options
  • Save victoredwardocallaghan/1c3fff27e7dd2d267480 to your computer and use it in GitHub Desktop.
Save victoredwardocallaghan/1c3fff27e7dd2d267480 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# vim: ai ts=4 sts=4 et sw=4
import xml.dom.minidom
import os
# abuild.xml testcase format:
#
# <testcase classname='board' name='vendor/boardname' time='123' >
# <system-out>
# <![CDATA[
# ...
# ]]>
# </system-out>
# </testcase>
def buildlog_element(doc, buildoutput, ret):
if not ret:
cnode = doc.createElement('system-out')
else:
cnode = doc.createElement('failure')
cnode.setAttribute('type', 'BuildFailed')
cdata = doc.createCDATASection('\n'+buildoutput+'\n')
cnode.appendChild(cdata)
return cnode
def create_testcase(doc, vendor, board, ret, sysout, time):
root = doc.createElement('testcase')
root.setAttribute('classname', 'board')
root.setAttribute('name', vendor+'/'+board)
root.setAttribute('time', time)
cnode = buildlog_element(doc, sysout, ret)
root.appendChild(cnode)
return root
# abuild.xml testsuite format:
#
# <testsuite>
# <testcase classname='board' name='vendor/boardname' time='123' >
# ...1...
# </testcase>
# <testcase classname='board' name='vendor/boardname' time='123' >
# ...2...
# </testcase>
# </testsuite>
def create_abuildfile():
doc = xml.dom.minidom.Document()
root = doc.createElement('testsuite')
for x in range(0, 3):
case = create_testcase(doc, 'jetway', 'nf86-t56n-lf', 0, 'wow', '123')
root.appendChild(case)
doc.appendChild(root)
return doc
def write_to_file(doc, name='abuild.xml'):
fd = open(name, 'w')
doc.writexml(fd, encoding='utf-8', indent=' ', addindent=' ', newl='\n')
fd.close()
# make into a class
class TestSuite_Elaboration:
# Where shall we place all the build trees?
target = []
def __init__(self):
self.target = os.environ.get('COREBOOT_BUILD_DIR','')+'coreboot-builds'
self.create_config('foo', 'board', '') # look around all of tree looking..
def create_config(self, vendor, mainboard, config):
build_dir = self.target+'/'+vendor+'_'+mainboard
if not os.path.exists(build_dir):
os.makedirs(build_dir)
if not os.path.exists(self.target+'/'+'sharedutils'):
os.makedirs(self.target+'/'+'sharedutils')
if not config == '':
print(" Using existing configuration %s ... " % config)
# cp src/mainboard/$VENDOR/$MAINBOARD/$CONFIG ${build_dir}/config.build
else:
print(" Creating config file... ")
# grep "if[\t ]*VENDOR" src/mainboard/$VENDOR/$MAINBOARD/../Kconfig | \
# sed "s,^.*\(VENDOR_.*\)[^A-Z0-9_]*,CONFIG_\1=y," > ${build_dir}/config.build
# grep "if[\t ]*BOARD" src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
# sed "s,^.*\(BOARD_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> ${build_dir}/config.build
# grep "select[\t ]*ARCH" src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
# sed "s,^.*\(ARCH_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> ${build_dir}/config.build
# echo "CONFIG_MAINBOARD_DIR=\"$VENDOR/$MAINBOARD\"" >> ${build_dir}/config.build
# XXX: fix payload to none
# echo "CONFIG_PAYLOAD_NONE=y" >> ${build_dir}/config.build
print("($customizing) ")
#print ("$configoptions" >> ${build_dir}/config.build
#..
write_to_file(create_abuildfile())
runTestSuite = TestSuite_Elaboration()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment