-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve run-image's boot.sh. (#2378)
- Loading branch information
Showing
8 changed files
with
97 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2024 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import host.file | ||
import host.os | ||
import system.firmware | ||
import system.storage | ||
import .exit-codes | ||
|
||
main: | ||
test-dir := os.env["BOOT_TEST_DIR"] | ||
if file.is-file "$test-dir/mark": | ||
second-call | ||
else: | ||
first-call test-dir | ||
|
||
with-region [block]: | ||
region := storage.Region.open --flash "toitlang.org/envelope-test-region" --capacity=100 | ||
block.call region | ||
region.close | ||
|
||
HELLO ::= "hello world" | ||
|
||
first-call test-dir/string: | ||
print "first call" | ||
file.write-content --path="$test-dir/mark" "first" | ||
|
||
with-region: | region/storage.Region | | ||
region.write --at=0 HELLO | ||
|
||
// Exit with a crash. | ||
exit 1 | ||
|
||
second-call: | ||
with-region: | region/storage.Region | | ||
existing := region.read --from=0 --to=HELLO.size | ||
if existing == HELLO: | ||
print "Test failed" | ||
else: | ||
// The flash was correctly cleared after the crash. | ||
print "Test succeeded" | ||
exit EXIT-CODE-STOP |
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,16 @@ | ||
// Copyright (C) 2024 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import expect show * | ||
import .exit-codes | ||
import .util show EnvelopeTest with-test | ||
|
||
main args: | ||
with-test args: | test/EnvelopeTest | | ||
test.install --name="crash" --source-path="./boot-crash-source.toit" | ||
test.extract-to-dir --dir-path=test.tmp-dir | ||
output := test.boot-backticks test.tmp-dir --env={ | ||
"BOOT_TEST_DIR": test.tmp-dir, | ||
} | ||
expect (output.contains "Test succeeded") |
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,15 @@ | ||
// Copyright (C) 2024 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import host.file | ||
import host.os | ||
import .exit-codes | ||
|
||
main: | ||
test-dir := os.env["BOOT_TEST_DIR"] | ||
if file.is-file "$test-dir/mark": | ||
print "Test succeeded" | ||
exit EXIT-CODE_STOP | ||
file.write-content --path="$test-dir/mark" "first" | ||
__deep_sleep__ 20 // Sleep 20 ms. |
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,16 @@ | ||
// Copyright (C) 2024 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import expect show * | ||
import .exit-codes | ||
import .util show EnvelopeTest with-test | ||
|
||
main args: | ||
with-test args: | test/EnvelopeTest | | ||
test.install --name="deep-sleep" --source-path="./boot-deep-sleep-source.toit" | ||
test.extract-to-dir --dir-path=test.tmp-dir | ||
output := test.boot-backticks test.tmp-dir --env={ | ||
"BOOT_TEST_DIR": test.tmp-dir, | ||
} | ||
expect (output.contains "Test succeeded") |
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