1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Tests for caps display labeling.
//!
//! These tests verify that `filament devices` and `filament addr` show
//! "granted" instead of "caps" to make clear it's the local grant record.
use std::process::Command;
/// Get the path to the filament binary built with test-hooks feature.
fn filament_bin() -> std::path::PathBuf {
let mut path = std::env::current_exe().unwrap();
path.pop(); // remove test binary name
path.pop(); // remove deps/
path.push("filament");
path
}
/// Test that `filament devices` shows "granted" instead of "caps".
#[test]
fn devices_shows_granted_label() {
let bin = filament_bin();
let output = Command::new(&bin)
.arg("devices")
.output()
.expect("failed to execute filament");
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
// Should NOT contain "caps:" in the output (old label)
// Note: may contain "caps" in other contexts (like "capabilities")
// so we check for the specific label format
assert!(
!stdout.contains("caps:"),
"Expected no 'caps:' label in devices output, got: {}",
stdout
);
// Should contain "granted:" if there are any devices
// (empty devices list is also valid - just check the label format)
if !stdout.contains("no known devices") {
assert!(
stdout.contains("granted:"),
"Expected 'granted:' label in devices output, got: {}",
stdout
);
}
}
/// Test that `filament addr` shows "granted" instead of "caps".
#[test]
fn addr_shows_granted_label() {
let bin = filament_bin();
let output = Command::new(&bin)
.arg("addr")
.arg("--json")
.output()
.expect("failed to execute filament");
let stdout = String::from_utf8_lossy(&output.stdout);
// JSON output should still use "caps" key for backward compatibility
// (we only changed the human-readable display)
// This test just verifies the command runs without error
assert!(
output.status.success() || stdout.contains("{"),
"Expected valid JSON output from addr --json, got: {}",
&stdout[..stdout.len().min(200)]
);
}