Skip to content

Commit 1c4d0c7

Browse files
committed
test: runs example during github ci
Signed-off-by: YdrMaster <[email protected]>
1 parent b28985b commit 1c4d0c7

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

.github/workflows/workflow.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ jobs:
2323
uses: actions-rs/cargo@v1
2424
with:
2525
command: clippy
26+
- name: Run example
27+
uses: actions-rs/cargo@v1
28+
with:
29+
command: run
30+
args: --release --example qemu-virt

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
1414

1515
## Unreleased
1616

17-
### Changed
17+
## [0.2.0-alpha.1](https://github.com/YdrMaster/dtb-walker/releases/tag/0.2.0-alpha.1) - 2022-07-12
1818

1919
- 规范化更新日志格式
2020
- 字符串统一使用一个封装的 `Str` 类型(包括节点名、属性名、`<string>` 类型的属性值、路径),类似于 `str` 但未检查是否符合 utf-8 编码
2121
- 格式化 `Str` 不再自带引号
2222
- 补全文档并禁止不写文档
23+
- github ci 自动运行一次示例
2324

2425
---
2526

26-
- standardize the change log
27+
- standardizes the change log
2728
- uses an encapsulated `Str` type uniformly for strings (including node name, property name, property value of `<string>`, path), similar to `str` but not checked for utf-8 encoding
2829
- will not add quotes when formating `Str`
2930
- completes documentation and missing documentation is denied from now on
31+
- runs example during github ci
3032

3133
## [0.1.3](https://github.com/YdrMaster/dtb-walker/releases/tag/v0.1.3) - 2022-06-30
3234

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dtb-walker"
33
description = "A simple package for DTB depth-first walking."
4-
version = "0.2.0"
4+
version = "0.2.0-alpha.1"
55
edition = "2021"
66
authors = ["YdrMaster <[email protected]>"]
77
repository = "https://github.com/YdrMaster/dtb-walker.git"

examples/qemu-virt.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use dtb_walker::{utils::indent, Dtb, DtbObj, HeaderError, WalkOperation};
2-
3-
const DEVICE_TREE: &[u8] = include_bytes!("qemu-virt.dtb");
1+
const DEVICE_TREE: &[u8] = include_bytes!("qemu-virt.dtb");
42
const INDENT_WIDTH: usize = 4;
53

6-
fn main() {
4+
fn main() -> Result<(), String> {
5+
use dtb_walker::{utils::indent, Dtb, DtbObj, HeaderError as E, WalkOperation as Op};
6+
77
let mut aligned = vec![0usize; DEVICE_TREE.len() / core::mem::size_of::<usize>()];
88
unsafe {
99
aligned
@@ -13,23 +13,20 @@ fn main() {
1313

1414
let dtb = unsafe {
1515
Dtb::from_raw_parts_filtered(aligned.as_ptr() as _, |e| {
16-
matches!(
17-
e,
18-
HeaderError::Misaligned(4) | HeaderError::LastCompVersion(16)
19-
)
16+
matches!(e, E::Misaligned(4) | E::LastCompVersion(16))
2017
})
2118
}
22-
.unwrap();
19+
.map_err(|e| format!("verify header failed: {e:?}"))?;
2320
dtb.walk(|path, obj| match obj {
2421
DtbObj::SubNode { name } => {
2522
println!("{}{path}/{name}", indent(path.level(), INDENT_WIDTH));
26-
WalkOperation::StepInto
23+
Op::StepInto
2724
}
2825
DtbObj::Property(prop) => {
2926
let indent = indent(path.level(), INDENT_WIDTH);
3027
println!("{indent}{prop:?}");
31-
WalkOperation::StepOver
28+
Op::StepOver
3229
}
3330
});
34-
println!("ok");
31+
Ok(())
3532
}

src/header.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::ops::Range;
2-
3-
use crate::{is_aligned, U32BigEndian};
1+
use crate::{is_aligned, U32BigEndian};
2+
use core::ops::Range;
43

54
pub(crate) struct FdtHeader {
65
magic: U32BigEndian,

0 commit comments

Comments
 (0)