Add mock target for testing greeter
This commit is contained in:
parent
adb691704e
commit
ef69fe83bf
2 changed files with 19 additions and 8 deletions
|
|
@ -1,11 +1,21 @@
|
||||||
use greetd_ipc::{codec::SyncCodec, AuthMessageType, ErrorType, Request, Response};
|
use greetd_ipc::{codec::SyncCodec, AuthMessageType, ErrorType, Request, Response};
|
||||||
use std::io;
|
use std::{env, fs, io, thread};
|
||||||
use tokio::net::UnixListener;
|
use tokio::net::UnixListener;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let listener = UnixListener::bind("socket").unwrap();
|
let greetd_sock = env::current_dir().unwrap().join("socket");
|
||||||
println!("listening");
|
if greetd_sock.exists() {
|
||||||
|
fs::remove_file(&greetd_sock).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
let listener = UnixListener::bind(&greetd_sock).unwrap();
|
||||||
|
println!("listening at {:?}", greetd_sock);
|
||||||
|
|
||||||
|
env::set_var("GREETD_SOCK", &greetd_sock);
|
||||||
|
thread::spawn(|| {
|
||||||
|
cosmic_greeter::greeter::main();
|
||||||
|
});
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (socket, _addr) = listener.accept().await.unwrap();
|
let (socket, _addr) = listener.accept().await.unwrap();
|
||||||
|
|
@ -38,7 +48,7 @@ async fn main() {
|
||||||
let response = match request {
|
let response = match request {
|
||||||
Request::CreateSession { .. } => Response::AuthMessage {
|
Request::CreateSession { .. } => Response::AuthMessage {
|
||||||
auth_message_type: AuthMessageType::Secret,
|
auth_message_type: AuthMessageType::Secret,
|
||||||
auth_message: "Password:".to_string(),
|
auth_message: "MOCKING:".to_string(),
|
||||||
},
|
},
|
||||||
Request::PostAuthMessageResponse { response } => {
|
Request::PostAuthMessageResponse { response } => {
|
||||||
match response.as_ref().map(|x| x.as_str()) {
|
match response.as_ref().map(|x| x.as_str()) {
|
||||||
|
|
@ -50,10 +60,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Request::StartSession { .. } => Response::Success,
|
Request::StartSession { .. } => Response::Success,
|
||||||
_ => {
|
Request::CancelSession => Response::Success,
|
||||||
println!("unhandled request");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut bytes = Vec::with_capacity(4096);
|
let mut bytes = Vec::with_capacity(4096);
|
||||||
|
|
|
||||||
4
justfile
4
justfile
|
|
@ -55,6 +55,10 @@ check *args:
|
||||||
# Runs a clippy check with JSON message format
|
# Runs a clippy check with JSON message format
|
||||||
check-json: (check '--message-format=json')
|
check-json: (check '--message-format=json')
|
||||||
|
|
||||||
|
mock:
|
||||||
|
cargo build --release --example server
|
||||||
|
cosmic-comp target/release/examples/server
|
||||||
|
|
||||||
# Run with debug logs
|
# Run with debug logs
|
||||||
run *args:
|
run *args:
|
||||||
env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}}
|
env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue