Add shell cmd tests

This commit is contained in:
Jianfeng Jiang 2023-03-16 11:00:09 +08:00 committed by Tate, Hongliang Tian
parent 6a90603200
commit ee01113761
3 changed files with 45 additions and 2 deletions

4
src/Cargo.lock generated
View File

@ -596,9 +596,9 @@ dependencies = [
[[package]]
name = "trapframe"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f287ee70169f5bfddba441baf901b620e3655f16fa7815f48a7e100ec6d86a8f"
source = "git+https://github.com/sdww0/trapframe-rs?rev=13e1065#13e106595d3cde9988e101e6b51e8fb9da38053d"
dependencies = [
"log",
"raw-cpuid",
"x86_64",
]

36
src/apps/scripts/test_cmd.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
set -e
set -x
cd scripts
touch hello.txt
mv hello.txt hello_world.txt
rm hello_world.txt
awk '{print $2}' test_cmd.sh
cp test_cmd.sh test_cmd_backup.sh
cat test_cmd_backup.sh
rm test_cmd_backup.sh
ln -s test_cmd.sh tesk_cmd_soft_link
readlink -f tesk_cmd_soft_link
tail -n 1 tesk_cmd_soft_link
rm tesk_cmd_soft_link
ln test_cmd.sh tesk_cmd_hard_link
tail -n 1 tesk_cmd_hard_link
unlink tesk_cmd_hard_link
sed 3q test_cmd.sh
find . -name "*test_cmd*"
mkdir foo
rmdir foo
echo "Hello world from jinux" > hello.txt
rm hello.txt
cd ..

View File

@ -26,6 +26,13 @@ pub fn load_program_to_root_vmar(
fs_resolver: &FsResolver,
recursion_limit: usize,
) -> Result<ElfLoadInfo> {
// Temporary use because fs_resolver cannot deal with procfs now.
// FIXME: removes this when procfs is ready.
let executable_path = if &executable_path == "/proc/self/exe" {
current!().executable_path().unwrap().clone()
} else {
executable_path
};
let fs_path = FsPath::new(AT_FDCWD, &executable_path)?;
let file = fs_resolver.open(&fs_path, AccessMode::O_RDONLY as u32, 0)?;
let file_header = {