Skip to content

Commit 3f49b5a

Browse files
authored
Merge: synchronized up to mcu-tools/mcuboot@ce50334
Synch up to: mcu-tools/mcuboot@ce50334 merged by GitHub GUI #43 Signed-off-by: Andrzej Puzdrowski <[email protected]>
2 parents 6f48e0a + 52ff566 commit 3f49b5a

File tree

8 files changed

+121
-60
lines changed

8 files changed

+121
-60
lines changed

.github/workflows/imgtool.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
push:
33
branches:
44
- master
5+
- v*-branch
56

67
name: imgtool
78

boot/bootutil/include/bootutil/boot_record.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2020 Arm Limited
2+
* Copyright (c) 2018-2021 Arm Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,6 +24,22 @@
2424
extern "C" {
2525
#endif
2626

27+
/**
28+
* @brief Add a data item to the shared data area between bootloader and
29+
* runtime SW
30+
*
31+
* @param[in] major_type TLV major type, identify consumer
32+
* @param[in] minor_type TLV minor type, identify TLV type
33+
* @param[in] size length of added data
34+
* @param[in] data pointer to data
35+
*
36+
* @return 0 on success; nonzero on failure.
37+
*/
38+
int boot_add_data_to_shared_area(uint8_t major_type,
39+
uint16_t minor_type,
40+
size_t size,
41+
const uint8_t *data);
42+
2743
/**
2844
* Add an image's all boot status information to the shared memory area
2945
* between the bootloader and runtime SW.

boot/bootutil/src/boot_record.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2020 Arm Limited
2+
* Copyright (c) 2018-2021 Arm Limited
33
* Copyright (c) 2020 Linaro Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,18 +44,8 @@
4444
*/
4545
static bool shared_memory_init_done;
4646

47-
/**
48-
* @brief Add a data item to the shared data area between bootloader and
49-
* runtime SW
50-
*
51-
* @param[in] major_type TLV major type, identify consumer
52-
* @param[in] minor_type TLV minor type, identify TLV type
53-
* @param[in] size length of added data
54-
* @param[in] data pointer to data
55-
*
56-
* @return 0 on success; nonzero on failure.
57-
*/
58-
static int
47+
/* See in boot_record.h */
48+
int
5949
boot_add_data_to_shared_area(uint8_t major_type,
6050
uint16_t minor_type,
6151
size_t size,
@@ -66,6 +56,10 @@ boot_add_data_to_shared_area(uint8_t major_type,
6656
uint16_t boot_data_size;
6757
uintptr_t tlv_end, offset;
6858

59+
if (data == NULL) {
60+
return SHARED_MEMORY_GEN_ERROR;
61+
}
62+
6963
boot_data = (struct shared_boot_data *)MCUBOOT_SHARED_DATA_BASE;
7064

7165
/* Check whether first time to call this function. If does then initialise

ci/check-signed-off-by.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ for sha in $commits; do
3232
lines="$(git show -s --format=%B ${sha})"
3333

3434
found_author=false
35-
found_committer=false
35+
# Don't enforce committer email on forks; this primarily avoids issues
36+
# running workflows on the zephyr fork, because rebases done in the GH UX
37+
# use the primary email of the committer, which might not match the one
38+
# used in git CLI.
39+
if [[ $GITHUB_REPOSITORY == mcu-tools/* ]]; then
40+
found_committer=false
41+
else
42+
found_committer=true
43+
fi
44+
3645
IFS=$'\n'
3746
for line in ${lines}; do
3847
stripped=$(echo $line | sed -e 's/^\s*//' | sed -e 's/\s*$//')

ci/fih-tests_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -e
1919
pushd .. &&\
2020
git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git &&\
2121
pushd trusted-firmware-m &&\
22-
git checkout 8501b37db8e038ce39eb7f1039a514edea92c96e &&\
22+
git checkout 7ad5c5f23f4619add4aa6c88f4b25fc6fd84ec6e &&\
2323
popd
2424

2525
if test -z "$FIH_LEVEL"; then

ci/sim_run.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ EXIT_CODE=0
2525
if [[ ! -z $SINGLE_FEATURES ]]; then
2626
if [[ $SINGLE_FEATURES =~ "none" ]]; then
2727
echo "Running cargo with no features"
28-
cargo test
28+
time cargo test --no-run
29+
time cargo test
2930
rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
3031
fi
3132

3233
for feature in $all_features; do
3334
if [[ $SINGLE_FEATURES =~ $feature ]]; then
3435
echo "Running cargo for feature=\"${feature}\""
35-
cargo test --features $feature
36+
time cargo test --no-run --features $feature
37+
time cargo test --features $feature
3638
rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
3739
fi
3840
done
@@ -43,7 +45,8 @@ if [[ ! -z $MULTI_FEATURES ]]; then
4345
read -ra multi_features <<< "$MULTI_FEATURES"
4446
for features in "${multi_features[@]}"; do
4547
echo "Running cargo for features=\"${features}\""
46-
cargo test --features "$features"
48+
time cargo test --no-run --features "$features"
49+
time cargo test --features "$features"
4750
rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
4851
done
4952
fi

docs/release.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ imgtool is released through pypi.org (The Python package index) and
4141
requires that its version to be updated by editing
4242
`scripts/imgtool/__init__.py` and modifying the exported version:
4343

44-
`imgtool_version = "X.Y.ZrcN"`
44+
`imgtool_version = "A.B.CrcN"`
4545

46-
where `rcX`, `aX` and `bX` are accepted pre-release versions (just
47-
numbers for final releases). For more info see:
46+
This version should match the current release number of MCUboot; `rcN`
47+
(with no dash!) is accepted for pre-release version under test, and
48+
numbers only for final releases. For more info see:
4849

4950
https://www.python.org/dev/peps/pep-0440/#pre-releases
5051

@@ -84,6 +85,20 @@ git push origin HEAD:refs/heads/master
8485
git push origin va.b.c-rcn
8586
```
8687

88+
## Branching after a Release
89+
90+
After the final (non-`rc`) a.b.0 release is made, a new branch must
91+
be created and pushed:
92+
93+
``` bash
94+
git checkout va.b.c
95+
git checkout -b va.b-branch
96+
git push origin va.b-branch
97+
```
98+
99+
This branch will be used to generate new incremental `PATCH` releases
100+
for bug fixes or required minor updates (eg, new `imgtool` features).
101+
87102
## Post release actions
88103

89104
Mark the MCUBoot version as a development version. The version number used

ptest/src/main.rs

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ use chrono::Local;
1414
use log::{debug, error, warn};
1515
use std::{
1616
collections::HashSet,
17+
env,
1718
fs::{self, OpenOptions},
1819
io::{ErrorKind, stdout, Write},
19-
process::{Command, Output},
20+
process::Command,
2021
result,
2122
sync::{
2223
Arc,
@@ -82,6 +83,15 @@ struct State {
8283
total: usize,
8384
}
8485

86+
/// Result of a test run.
87+
struct TestResult {
88+
/// Was this run successful.
89+
success: bool,
90+
91+
/// The captured output.
92+
output: Vec<u8>,
93+
}
94+
8595
impl State {
8696
fn new(total: usize) -> Arc<Mutex<State>> {
8797
Arc::new(Mutex::new(State {
@@ -101,46 +111,41 @@ impl State {
101111
self.status();
102112
}
103113

104-
fn done(&mut self, fs: &FeatureSet, output: Result<Option<Output>>) {
114+
fn done(&mut self, fs: &FeatureSet, output: Result<TestResult>) {
105115
let key = fs.textual();
106116
self.running.remove(&key);
107117
self.done.insert(key.clone());
108118
match output {
109-
Ok(None) => {
110-
// println!("Success {} ({} running)", key, self.running.len());
111-
}
112-
Ok(Some(output)) => {
113-
// Write the output into a file.
114-
let mut count = 1;
115-
let (mut fd, logname) = loop {
116-
let name = format!("./failure-{:04}.log", count);
117-
count += 1;
118-
match OpenOptions::new()
119-
.create_new(true)
120-
.write(true)
121-
.open(&name)
122-
{
123-
Ok(file) => break (file, name),
124-
Err(ref err) if err.kind() == ErrorKind::AlreadyExists => continue,
125-
Err(err) => {
126-
error!("Unable to write log file to current directory: {:?}", err);
127-
return;
119+
Ok(output) => {
120+
if !output.success || log_all() {
121+
// Write the output into a file.
122+
let mut count = 1;
123+
let (mut fd, logname) = loop {
124+
let base = if output.success { "success" } else { "failure" };
125+
let name = format!("./{}-{:04}.log", base, count);
126+
count += 1;
127+
match OpenOptions::new()
128+
.create_new(true)
129+
.write(true)
130+
.open(&name)
131+
{
132+
Ok(file) => break (file, name),
133+
Err(ref err) if err.kind() == ErrorKind::AlreadyExists => continue,
134+
Err(err) => {
135+
error!("Unable to write log file to current directory: {:?}", err);
136+
return;
137+
}
128138
}
139+
};
140+
fd.write_all(&output.output).unwrap();
141+
if !output.success {
142+
error!("Failure {} log:{:?} ({} running)", key, logname,
143+
self.running.len());
129144
}
130-
};
131-
writeln!(&mut fd, "Test failure {}", key).unwrap();
132-
writeln!(&mut fd, "time: {}", Local::now().to_rfc3339()).unwrap();
133-
writeln!(&mut fd, "----------------------------------------").unwrap();
134-
writeln!(&mut fd, "stdout:").unwrap();
135-
fd.write_all(&output.stdout).unwrap();
136-
writeln!(&mut fd, "----------------------------------------").unwrap();
137-
writeln!(&mut fd, "\nstderr:").unwrap();
138-
fd.write_all(&output.stderr).unwrap();
139-
error!("Failure {} log:{:?} ({} running)", key, logname,
140-
self.running.len());
145+
}
141146
}
142147
Err(err) => {
143-
error!("Unable to run test {:?} ({:?})", key, err);
148+
error!("Unable to run test {:?} ({:?}", key, err);
144149
}
145150
}
146151
self.status();
@@ -239,18 +244,31 @@ impl FeatureSet {
239244
/// Run a test for this given feature set. Output is captured and will be returned if there is
240245
/// an error. Each will be run successively, and the first failure will be returned.
241246
/// Otherwise, it returns None, which means everything worked.
242-
fn run(&self) -> Result<Option<Output>> {
247+
fn run(&self) -> Result<TestResult> {
248+
let mut output = vec![];
249+
let mut success = true;
243250
for v in &self.values {
244-
let output = Command::new("bash")
251+
let cmdout = Command::new("bash")
245252
.arg("./ci/sim_run.sh")
246253
.current_dir("..")
247254
.env(&self.env, v)
248255
.output()?;
249-
if !output.status.success() {
250-
return Ok(Some(output));
256+
// Grab the output for logging, etc.
257+
writeln!(&mut output, "Test {} {}",
258+
if cmdout.status.success() { "success" } else { "FAILURE" },
259+
self.textual())?;
260+
writeln!(&mut output, "time: {}", Local::now().to_rfc3339())?;
261+
writeln!(&mut output, "----------------------------------------")?;
262+
writeln!(&mut output, "stdout:")?;
263+
output.extend(&cmdout.stdout);
264+
writeln!(&mut output, "----------------------------------------")?;
265+
writeln!(&mut output, "stderr:")?;
266+
output.extend(&cmdout.stderr);
267+
if !cmdout.status.success() {
268+
success = false;
251269
}
252270
}
253-
return Ok(None);
271+
Ok(TestResult { success, output })
254272
}
255273

256274
/// Convert this feature set into a textual representation
@@ -282,3 +300,8 @@ fn lookup_matrix(y: &Yaml) -> Option<&Vec<Yaml>> {
282300
.as_hash()?.get(&features)?
283301
.as_vec()
284302
}
303+
304+
/// Query if we should be logging all tests and not only failures.
305+
fn log_all() -> bool {
306+
env::var("PTEST_LOG_ALL").is_ok()
307+
}

0 commit comments

Comments
 (0)