forked from fwup-home/fwup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In very specific cases, it might be desirable to fallback to another task when the target task fails. Most commonly this will be falling back to the `complete` task when the `upgrade` fails due to the firmware not having a previous firmware. The fallback will only occur if the failure is withing the tasks functions so checks before and after the task do not trigger a fallback (i.e. issues with archive or config file) This is inspired by nerves-project/nerves#682
- Loading branch information
1 parent
3dde4b2
commit afe5645
Showing
5 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Test the fallback task ability when initial task fails | ||
# | ||
|
||
. "$(cd "$(dirname "$0")" && pwd)/common.sh" | ||
|
||
cat >$CONFIG <<EOF | ||
file-resource TEST { | ||
host-path = "${TESTFILE_1K}" | ||
} | ||
task complete { | ||
on-resource TEST { raw_write(0) } | ||
} | ||
EOF | ||
|
||
cat >$EXPECTED_META_CONF <<EOF | ||
file-resource "TEST" { | ||
length=1024 | ||
blake2b-256="b25c2dfe31707f5572d9a3670d0dcfe5d59ccb010e6aba3b81aad133eb5e378b" | ||
} | ||
task "complete" { | ||
on-resource "TEST" { | ||
funlist = {"2", "raw_write", "0"} | ||
} | ||
} | ||
EOF | ||
|
||
$FWUP_CREATE -c -f $CONFIG -o $FWFILE | ||
|
||
# Check that the zip file was created as expected | ||
check_meta_conf | ||
cmp $TESTFILE_1K $UNZIPDIR/data/TEST | ||
|
||
# Check that applying the firmware does the expected thing | ||
$FWUP_APPLY -a -d $IMGFILE -i $FWFILE -t upgrade -T complete --verify-writes | ||
cmp_bytes 1024 $IMGFILE $TESTFILE_1K | ||
|
||
# Check that the verify logic works on this file | ||
$FWUP_VERIFY -V -i $FWFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters