|
| 1 | +// Copyright 2025 The Servo Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution. |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 | +// option. This file may not be copied, modified, or distributed |
| 8 | +// except according to those terms. |
| 9 | + |
| 10 | +use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; |
| 11 | +use std::{env, process}; |
| 12 | + |
| 13 | +/// Test executable which connects to the one-shot server with name |
| 14 | +/// passed in as an argument and then sends a receiver which it has |
| 15 | +/// already used to the server and then sends a test message to the |
| 16 | +/// receiver. |
| 17 | +fn main() { |
| 18 | + let args: Vec<String> = env::args().collect(); |
| 19 | + let token = args.get(1).expect("missing argument"); |
| 20 | + |
| 21 | + let (sub_tx, sub_rx) = ipc::channel().unwrap(); |
| 22 | + sub_tx.send("test message".to_string()).expect("send failed"); |
| 23 | + let msg = sub_rx.recv().unwrap(); |
| 24 | + assert_eq!("test message", msg); |
| 25 | + |
| 26 | + let tx: IpcSender<IpcReceiver<String>> = IpcSender::connect(token.to_string()).expect("connect failed"); |
| 27 | + tx.send(sub_rx).expect("send failed"); |
| 28 | + sub_tx.send("test message".to_string()).expect("send failed"); |
| 29 | + |
| 30 | + process::exit(0); |
| 31 | +} |
0 commit comments