Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cs283
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joey Le
Cs283
Commits
0262dc9a
Commit
0262dc9a
authored
2 months ago
by
Joey Le
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
https://gitlab.cci.drexel.edu/jl4589/cs283
parents
11c1a99c
6ddb516a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Assignment-06/starter/dsh
+0
-0
0 additions, 0 deletions
Assignment-06/starter/dsh
Assignment-06/starter/student_tests.sh
+75
-0
75 additions, 0 deletions
Assignment-06/starter/student_tests.sh
with
75 additions
and
0 deletions
Assignment-06/starter/dsh
0 → 100755
+
0
−
0
View file @
0262dc9a
File added
This diff is collapsed.
Click to expand it.
Assignment-06/starter/student_tests.sh
+
75
−
0
View file @
0262dc9a
...
...
@@ -4,6 +4,18 @@
#
# Create your unit tests suit in this file
start_server
()
{
./dsh
-s
-i
127.0.0.1
-p
5678
>
/dev/null 2>&1 &
SERVER_PID
=
$!
sleep
1
# Give the server time to start
}
# Helper function to stop the server
stop_server
()
{
kill
$SERVER_PID
2>/dev/null
||
true
wait
$SERVER_PID
2>/dev/null
||
true
}
@test
"Example: check ls runs without errors"
{
run ./dsh
<<
EOF
ls
...
...
@@ -12,3 +24,66 @@ EOF
# Assertions
[
"
$status
"
-eq
0
]
}
@test
"Start server and client without errors"
{
# Start the server
start_server
# Check if the server is running
run ps
-p
$SERVER_PID
[
"
$status
"
-eq
0
]
# Start the client and send a simple command
run ./dsh
-c
-i
127.0.0.1
-p
5678
<<
EOF
echo Hello, World!
exit
EOF
# Assertions
[
"
$status
"
-eq
0
]
[[
"
$output
"
==
*
"Hello, World!"
*
]]
stop_server
}
@test
"Server handles pipes"
{
start_server
echo
"testfile1"
>
testfile1.txt
echo
"testfile2"
>>
testfile1.txt
run ./dsh
-c
-i
127.0.0.1
-p
5678
<<
EOF
ls -1 | wc -l
exit
EOF
[
"
$status
"
-eq
0
]
[[
"
$output
"
==
*
"2"
*
]]
rm
-f
testfile1.txt
stop_server
}
@test
"Stop server with stop-server command"
{
start_server
run ps
-p
$SERVER_PID
[
"
$status
"
-eq
0
]
run ./dsh
-c
-i
127.0.0.1
-p
5678
<<
EOF
stop-server
EOF
[
"
$status
"
-eq
0
]
sleep
1
run ps
-p
$SERVER_PID
[
"
$status
"
-ne
0
]
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment