forked from open-education-hub/operating-systems
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chapters/io: Add checker infrastructure for lab 10
Pending to get a response Signed-off-by: Viktor09 <[email protected]>
- Loading branch information
Showing
42 changed files
with
232 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions
54
chapters/io/ipc/drills/tasks/named-pipes/solution/tests/checker.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
FIFO="my-fifo" | ||
EXEC="../src/named_pipe" | ||
INPUT="test_input.txt" | ||
OUTPUT="test_output.txt" | ||
|
||
cd ../src || exit | ||
make | ||
cd ../tests || exit | ||
echo | ||
|
||
rm -f $FIFO $INPUT $OUTPUT | ||
|
||
test_create_fifo() { | ||
|
||
$EXEC > /dev/null 2>&1 & | ||
sleep 1 | ||
|
||
if [[ -p $FIFO ]]; then | ||
echo "Test for FIFO creation: PASSED" | ||
else | ||
echo "Test for FIFO creation: FAILED" | ||
fi | ||
|
||
pkill -f $EXEC 2>/dev/null | ||
} | ||
|
||
test_send_receive() { | ||
STRING="OS{We make the rullz!!}" | ||
echo "$STRING" > $INPUT | ||
|
||
$EXEC > $OUTPUT & | ||
sleep 1 | ||
|
||
$EXEC -s < $INPUT | ||
sleep 1 | ||
|
||
if grep -q "$STRING" $OUTPUT; then | ||
echo "Test for send and receive: PASSED" | ||
else | ||
echo "Test for send and receive: FAILED" | ||
fi | ||
|
||
pkill -f $EXEC 2>/dev/null | ||
rm -f $INPUT $OUTPUT | ||
} | ||
|
||
|
||
test_create_fifo | ||
test_send_receive | ||
|
||
rm -f $FIFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
80 changes: 80 additions & 0 deletions
80
chapters/io/ipc/drills/tasks/network-socket/solution/tests/checker.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
TCP="../src/tcp_socket" | ||
UDP="../src/udp_socket" | ||
|
||
TCP_LOG="tcp_server.log" | ||
UDP_LOG="udp_server.log" | ||
|
||
cd ../src || exit | ||
make | ||
cd ../tests || exit | ||
echo | ||
|
||
test_tcp_all() { | ||
|
||
$TCP > "$TCP_LOG" 2>&1 & | ||
TCP_PID=$! | ||
sleep 1 | ||
|
||
IP="127.0.0.1" | ||
PORT="5000" | ||
|
||
if netstat -tuln | grep -q "$IP:$PORT"; then | ||
echo "Test for TCP state: PASSED" | ||
else | ||
echo "Test for TCP state: FAILED" | ||
fi | ||
|
||
STRING="OS{Hello OS enjoyers!!}" | ||
echo "$STRING" | $TCP -s | ||
sleep 1 | ||
|
||
if grep -q "\[Receiver\]: $STRING" "$TCP_LOG"; then | ||
echo "Test for TCP receiving the message: PASSED" | ||
else | ||
echo "Test for TCP receiving the message: FAILED" | ||
fi | ||
|
||
kill "$TCP_PID" 2>/dev/null | ||
wait "$TCP_PID" 2>/dev/null | ||
rm -f "$TCP_LOG" | ||
echo | ||
} | ||
|
||
test_udp_all() { | ||
|
||
$UDP > "$UDP_LOG" 2>&1 & | ||
UDP_PID=$! | ||
sleep 1 | ||
|
||
IP="127.0.0.1" | ||
PORT="5000" | ||
|
||
if netstat -tuln | grep -q "$IP:$PORT"; then | ||
echo "Test for UDP state: PASSED" | ||
else | ||
echo "Test for UDP state: FAILED" | ||
fi | ||
|
||
STRING="OS{Are you enjoying this lab?!}" | ||
echo "$STRING" | $UDP -s | ||
sleep 1 | ||
|
||
if grep -q "\[Receiver\]: $STRING" "$UDP_LOG"; then | ||
echo "Test for UDP receiving the message: PASSED" | ||
else | ||
echo "Test for UDP receiving the message: FAILED" | ||
fi | ||
|
||
kill "$UDP_PID" 2>/dev/null | ||
wait "$UDP_PID" 2>/dev/null | ||
rm -f "$UDP_LOG" | ||
echo | ||
} | ||
|
||
test_tcp_all | ||
test_udp_all | ||
|
||
rm -f "$INPUT" "$OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
chapters/io/ipc/drills/tasks/unix-socket/solution/tests/checker.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
SOCKET="my-socket" | ||
EXEC="../src/unix_socket" | ||
INPUT="test_input.txt" | ||
OUTPUT="test_output.txt" | ||
|
||
cd ../src || exit | ||
make | ||
cd ../tests || exit | ||
echo | ||
|
||
rm -f $SOCKET $INPUT $OUTPUT | ||
|
||
test_create_socket() { | ||
|
||
$EXEC > /dev/null 2>&1 & | ||
sleep 1 | ||
|
||
if [[ -e $SOCKET ]]; then | ||
echo "Test for socket creation: PASSED" | ||
else | ||
echo "Test for socket creation: FAILED" | ||
fi | ||
|
||
pkill -f $EXEC 2>/dev/null | ||
} | ||
|
||
test_send_receive() { | ||
STRING="OS{Welcome to the hood!}" | ||
echo "$STRING" > $INPUT | ||
|
||
$EXEC > $OUTPUT 2>&1 & | ||
sleep 1 | ||
|
||
$EXEC -s < $INPUT > /dev/null 2>&1 | ||
sleep 1 | ||
|
||
if grep -q "$STRING" $OUTPUT; then | ||
echo "Test for send and receive: PASSED" | ||
else | ||
echo "Test for send and receive: FAILED" | ||
fi | ||
|
||
pkill -f $EXEC 2>/dev/null | ||
rm -f $INPUT $OUTPUT | ||
} | ||
|
||
test_create_socket | ||
test_send_receive | ||
|
||
rm -f $SOCKET |