From a6d1ec37090152afd9eff7d264335d21e00355fe Mon Sep 17 00:00:00 2001 From: vht24 <vht24@tux1.cci.drexel.edu> Date: Thu, 20 Feb 2025 23:53:09 -0500 Subject: [PATCH] update --- 4-ShellP2/bats/student_tests.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/4-ShellP2/bats/student_tests.sh b/4-ShellP2/bats/student_tests.sh index 73b1755..81029e9 100755 --- a/4-ShellP2/bats/student_tests.sh +++ b/4-ShellP2/bats/student_tests.sh @@ -95,4 +95,30 @@ EOF stripped_output=$(echo "$output" | tr -d '[:space:]') expected_output="Errorexecutingnocommand:Nosuchfileordirectorydsh2>dsh2>dsh2>2dsh2>cmdloopreturned0" [ "$stripped_output" = "$expected_output" ] -} \ No newline at end of file +} + +# Test: Check 'dragon' built-in command prints dragon +@test "Check dragon command prints dragon" { + run ./dsh <<EOF +dragon +EOF + [ "$status" -eq 0 ] +} + +# Test: Check handling of permission denied error +@test "Check handling of permission denied" { + touch testfile + chmod -r testfile + run ./dsh <<EOF +./testfile +rc +EOF + stripped_output=$(echo "$output" | tr -d '[:space:]') + expected_output="Errorexecuting./testfile:Permissiondenieddsh2>dsh2>dsh2>13dsh2>cmdloopreturned0" + echo "Captured stdout:" + echo "Output: $output" + echo "Exit Status: $status" + echo "${stripped_output} -> ${expected_output}" + [ "$stripped_output" = "$expected_output" ] + rm testfile +} -- GitLab