diff --git a/4-ShellP2/bats/student_tests.sh b/4-ShellP2/bats/student_tests.sh index 73b17557a4796a54428956bd693c15f828c1f9d9..81029e9cc03fa5a7e4552be2be5607ad99509972 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 +}