Skip to content

Commit

Permalink
Pass keyboard name to test replay entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
samvel1024 committed Jun 24, 2021
1 parent 0510fb2 commit 8139382
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ enum SubCommand {
struct CliTestReplay {
#[clap(short, long)]
testcase: String,
#[clap(short, long, default_value="DummyDevice")]
device_name: String
}

#[derive(Clap)]
Expand Down Expand Up @@ -359,7 +361,7 @@ fn main() -> Result<()> {
use SubCommand::*;
match root_opts.subcmd {
TestReplay(args) => {
util::integration_test::replay(args.testcase)?;
util::integration_test::replay(args.testcase, args.device_name)?;
}
Remap(args) => {
start_mapper_from_file_conf(args.config)?;
Expand Down
5 changes: 2 additions & 3 deletions src/util/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,16 @@ fn read_keyboard_output(
Ok(())
}

pub fn replay(test_file: String) -> Result<()> {
pub fn replay(test_file: String, device_name: String) -> Result<()> {
use ReplayMessage::*;

let device_name = "DummyDevice".to_string();
let mut device = create_writable_uinput_device(&device_name)?;

// Allow some time for the kbct process to capture the new device
thread::sleep(time::Duration::from_millis(800));

let all_devices = get_all_uinput_device_names_to_paths()?;
let mapped_device_path = all_devices.get("Kbct-DummyDevice").expect(
let mapped_device_path = all_devices.get(&*format!("Kbct-{}", device_name)).expect(
"The mapped device is not mounted yet, make sure you run kbct in parallel before replay",
);
let mapped_device_file = open_readable_uinput_device(mapped_device_path, true)?;
Expand Down

0 comments on commit 8139382

Please sign in to comment.