mirror of
https://github.com/AmbiML/sparrow-kata-full.git
synced 2025-04-28 02:40:40 +00:00
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
// Copyright 2022 Google LLC
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! SDK Runtime shell test commands
|
|
|
|
use crate::CmdFn;
|
|
use crate::CommandError;
|
|
use crate::HashMap;
|
|
use core::fmt::Write;
|
|
|
|
use kata_io as io;
|
|
|
|
use kata_sdk_interface::kata_sdk_ping;
|
|
|
|
pub fn add_cmds(cmds: &mut HashMap<&str, CmdFn>) {
|
|
cmds.extend([("test_sdkping", sdk_ping_command as CmdFn)]);
|
|
}
|
|
|
|
fn sdk_ping_command(
|
|
_args: &mut dyn Iterator<Item = &str>,
|
|
_input: &mut dyn io::BufRead,
|
|
output: &mut dyn io::Write,
|
|
_builtin_cpio: &[u8],
|
|
) -> Result<(), CommandError> {
|
|
match kata_sdk_ping() {
|
|
Ok(()) => {
|
|
writeln!(output, "pong received")?;
|
|
}
|
|
Err(sdkerror) => {
|
|
writeln!(output, "ping failed: {:?}", sdkerror)?;
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|