Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix CI with sanitycheck exceptions #9456

Merged
merged 2 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ compiler: gcc
env:
global:
- SDK=0.9.3
- SANITYCHECK_OPTIONS=" --inline-logs --enable-coverage"
- SANITYCHECK_OPTIONS=" --inline-logs --enable-coverage "
- SANITYCHECK_OPTIONS_RETRY="${SANITYCHECK_OPTIONS} --only-failed --outdir=out-2nd-pass"
- ZEPHYR_SDK_INSTALL_DIR=/opt/sdk/zephyr-sdk-0.9.3
- ZEPHYR_TOOLCHAIN_VARIANT=zephyr
Expand Down Expand Up @@ -60,14 +60,14 @@ build:
./scripts/ci/get_modified_boards.py --commits origin/${PULL_REQUEST_BASE_BRANCH}..HEAD > modified_boards.args;

if [ -s modified_boards.args ]; then
./scripts/sanitycheck ${SANITYCHECK_OPTIONS} +modified_boards.args --save-tests test_file.txt;
./scripts/sanitycheck ${SANITYCHECK_OPTIONS} +modified_boards.args --save-tests test_file.txt || exit 1;
fi;
if [ -s modified_tests.args ]; then
./scripts/sanitycheck ${SANITYCHECK_OPTIONS} +modified_tests.args --save-tests test_file.txt;
./scripts/sanitycheck ${SANITYCHECK_OPTIONS} +modified_tests.args --save-tests test_file.txt || exit 1;
fi;
rm -f modified_tests.args modified_boards.args;
fi;
- ./scripts/sanitycheck ${SANITYCHECK_OPTIONS} --save-tests test_file.txt
- ./scripts/sanitycheck ${SANITYCHECK_OPTIONS} --save-tests test_file.txt || exit 1
- ./scripts/sanitycheck ${SANITYCHECK_OPTIONS} --load-tests test_file.txt --subset ${MATRIX_BUILD}/${MATRIX_BUILDS} || ./scripts/sanitycheck ${SANITYCHECK_OPTIONS_RETRY} || ./scripts/sanitycheck ${SANITYCHECK_OPTIONS_RETRY}
- rm test_file.txt
- ccache -s
Expand All @@ -84,7 +84,7 @@ build:
rm lcov.pre.info;
rm -rf sanity-out out-2nd-pass;
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
rm lcov.info;
rm -f lcov.info;
else
rm -rf sanity-out out-2nd-pass;
fi;
Expand All @@ -109,7 +109,7 @@ build:
rm lcov.pre.info;
rm -rf sanity-out out-2nd-pass;
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
rm lcov.info;
rm -f lcov.info;
else
rm -rf sanity-out out-2nd-pass;
fi;
Expand Down
90 changes: 69 additions & 21 deletions scripts/sanitycheck
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,12 @@ class SizeCalculator:
with open(filename, "rb") as f:
magic = f.read(4)

if (magic != b'\x7fELF'):
raise SanityRuntimeError("%s is not an ELF binary" % filename)
try:
if (magic != b'\x7fELF'):
raise SanityRuntimeError("%s is not an ELF binary" % filename)
except Exception as e:
print(str(e))
sys.exit(2)

# Search for CONFIG_XIP in the ELF's list of symbols using NM and AWK.
# GREP can not be used as it returns an error if the symbol is not
Expand All @@ -667,8 +671,13 @@ class SizeCalculator:
is_xip_output = subprocess.check_output(
is_xip_command, shell=True, stderr=subprocess.STDOUT).decode(
"utf-8").strip()
if is_xip_output.endswith("no symbols"):
raise SanityRuntimeError("%s has no symbol information" % filename)
try:
if is_xip_output.endswith("no symbols"):
raise SanityRuntimeError("%s has no symbol information" % filename)
except Exception as e:
print(str(e))
sys.exit(2)

self.is_xip = (len(is_xip_output) != 0)

self.filename = filename
Expand Down Expand Up @@ -1643,8 +1652,14 @@ class TestSuite:
self.instances = {}

def get_last_failed(self):
if not os.path.exists(LAST_SANITY):
raise SanityRuntimeError("Couldn't find last sanity run.")

try:
if not os.path.exists(LAST_SANITY):
raise SanityRuntimeError("Couldn't find last sanity run.")
except Exception as e:
print(str(e))
sys.exit(2)

result = []
with open(LAST_SANITY, "r") as fp:
cr = csv.DictReader(fp)
Expand All @@ -1657,9 +1672,14 @@ class TestSuite:
return result

def load_from_file(self, file):
if not os.path.exists(file):
raise SanityRuntimeError(
"Couldn't find input file with list of tests.")
try:
if not os.path.exists(file):
raise SanityRuntimeError(
"Couldn't find input file with list of tests.")
except Exception as e:
print(str(e))
sys.exit(2)

with open(file, "r") as fp:
cr = csv.reader(fp)
instance_list = []
Expand All @@ -1680,8 +1700,14 @@ class TestSuite:

toolchain = os.environ.get("ZEPHYR_TOOLCHAIN_VARIANT", None) or \
os.environ.get("ZEPHYR_GCC_VARIANT", None)
if not toolchain:
raise SanityRuntimeError("E: Variable ZEPHYR_TOOLCHAIN_VARIANT is not defined")


try:
if not toolchain:
raise SanityRuntimeError("E: Variable ZEPHYR_TOOLCHAIN_VARIANT is not defined")
except Exception as e:
print(str(e))
sys.exit(2)


instances = []
Expand Down Expand Up @@ -1807,8 +1833,13 @@ class TestSuite:
results = mg.execute(defconfig_cb)

for name, goal in results.items():
if goal.failed:
raise SanityRuntimeError("Couldn't build some defconfigs")
try:
if goal.failed:
raise SanityRuntimeError("Couldn't build some defconfigs")
except Exception as e:
error(str(e))
sys.exit(2)


for k, out_config in dlist.items():
test, plat, name = k
Expand Down Expand Up @@ -2009,8 +2040,13 @@ class TestSuite:
cw.writerow(rowdict)

def discard_report(self, filename):
if self.discards is None:
raise SanityRuntimeError("apply_filters() hasn't been run!")

try:
if self.discards is None:
raise SanityRuntimeError("apply_filters() hasn't been run!")
except Exception as e:
error(str(e))
sys.exit(2)

with open(filename, "wt") as csvfile:
fieldnames = ["test", "arch", "platform", "reason"]
Expand All @@ -2028,8 +2064,12 @@ class TestSuite:
interesting_metrics = [("ram_size", int, True),
("rom_size", int, True)]

if self.goals is None:
raise SanityRuntimeError("execute() hasn't been run!")
try:
if self.goals is None:
raise SanityRuntimeError("execute() hasn't been run!")
except Exception as e:
print(str(e))
sys.exit(2)

if not os.path.exists(filename):
info("Cannot compare metrics, %s not found" % filename)
Expand Down Expand Up @@ -2143,8 +2183,12 @@ class TestSuite:


def testcase_xunit_report(self, filename, duration):
if self.goals is None:
raise SanityRuntimeError("execute() hasn't been run!")
try:
if self.goals is None:
raise SanityRuntimeError("execute() hasn't been run!")
except Exception as e:
print(str(e))
sys.exit(2)

fails = 0
passes = 0
Expand Down Expand Up @@ -2214,8 +2258,12 @@ class TestSuite:
f.close()

def testcase_report(self, filename):
if self.goals is None:
raise SanityRuntimeError("execute() hasn't been run!")
try:
if self.goals is None:
raise SanityRuntimeError("execute() hasn't been run!")
except Exception as e:
print(str(e))
sys.exit(2)

with open(filename, "wt") as csvfile:
fieldnames = ["test", "arch", "platform", "passed", "status",
Expand Down