Skip to content

Commit

Permalink
test: runs example during github ci
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <ydrml@hotmail.com>
  • Loading branch information
YdrMaster committed Jul 12, 2022
1 parent b28985b commit 1c4d0c7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
- name: Run example
uses: actions-rs/cargo@v1
with:
command: run
args: --release --example qemu-virt
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## Unreleased

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

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

---

- standardize the change log
- standardizes the change log
- 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
- will not add quotes when formating `Str`
- completes documentation and missing documentation is denied from now on
- runs example during github ci

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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dtb-walker"
description = "A simple package for DTB depth-first walking."
version = "0.2.0"
version = "0.2.0-alpha.1"
edition = "2021"
authors = ["YdrMaster <ydrml@hotmail.com>"]
repository = "https://github.com/YdrMaster/dtb-walker.git"
Expand Down
21 changes: 9 additions & 12 deletions examples/qemu-virt.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use dtb_walker::{utils::indent, Dtb, DtbObj, HeaderError, WalkOperation};

const DEVICE_TREE: &[u8] = include_bytes!("qemu-virt.dtb");
const DEVICE_TREE: &[u8] = include_bytes!("qemu-virt.dtb");
const INDENT_WIDTH: usize = 4;

fn main() {
fn main() -> Result<(), String> {
use dtb_walker::{utils::indent, Dtb, DtbObj, HeaderError as E, WalkOperation as Op};

let mut aligned = vec![0usize; DEVICE_TREE.len() / core::mem::size_of::<usize>()];
unsafe {
aligned
Expand All @@ -13,23 +13,20 @@ fn main() {

let dtb = unsafe {
Dtb::from_raw_parts_filtered(aligned.as_ptr() as _, |e| {
matches!(
e,
HeaderError::Misaligned(4) | HeaderError::LastCompVersion(16)
)
matches!(e, E::Misaligned(4) | E::LastCompVersion(16))
})
}
.unwrap();
.map_err(|e| format!("verify header failed: {e:?}"))?;
dtb.walk(|path, obj| match obj {
DtbObj::SubNode { name } => {
println!("{}{path}/{name}", indent(path.level(), INDENT_WIDTH));
WalkOperation::StepInto
Op::StepInto
}
DtbObj::Property(prop) => {
let indent = indent(path.level(), INDENT_WIDTH);
println!("{indent}{prop:?}");
WalkOperation::StepOver
Op::StepOver
}
});
println!("ok");
Ok(())
}
5 changes: 2 additions & 3 deletions src/header.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::ops::Range;

use crate::{is_aligned, U32BigEndian};
use crate::{is_aligned, U32BigEndian};
use core::ops::Range;

pub(crate) struct FdtHeader {
magic: U32BigEndian,
Expand Down

0 comments on commit 1c4d0c7

Please sign in to comment.