Skip to content

Added checker for Lab 11 #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions labs/lab-11/tasks/entry-fix-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,25 @@
**Bonus**: In the subdirectories `c-extra-nolibc/` and `d-extra-libc/`, find solutions that do not modify the source code of `hello.c`.
These solutions instead modify the build system to use a different function, other than `main()`, as the program's entry point.

**Checker**: To test the implementation, enter the tests/ directory and run:

```
./run_all_tests.sh
```

In case of a correct solution, you will get this output:

```
./run_all_tests.sh

Check failure on line 29 in labs/lab-11/tasks/entry-fix-1/README.md

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace

Check failure on line 29 in labs/lab-11/tasks/entry-fix-1/README.md

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace

test_a-c ........................ passed ... 25
test_b-asm ........................ passed ... 25
test_c-extra-nolibc ........................ passed ... 25
test_d-extra-libc ........................ passed ... 25

========================================================================

Total: 100/100
```

If you're having difficulties solving this exercise, go through [this](../../reading/linking.md) reading material.
40 changes: 40 additions & 0 deletions labs/lab-11/tasks/entry-fix-1/tests/graded_test.inc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

#
# Print test result. Printed message should fit in 72 characters.
#
# Print format is:
#
# description ...................... passed ... NNN
# description ...................... failed ... NNN
# 32 chars 24 chars 6 3 3
#

print_test()
{
func="$1"
result="$2"
points="$3"

if test "$points" -gt 999; then
points=999
fi

printf "%-32s " "${func:0:31}"
printf "........................"
if test "$result" -eq 0; then
printf " passed ... %3d\n" "$points"
else
printf " failed ... 0\n"
fi
}

run_test()
{
func="$1"
points="$2"
# Run in subshell.
(eval "$func")
print_test "$func" "$?" "$points"
}

Check failure on line 40 in labs/lab-11/tasks/entry-fix-1/tests/graded_test.inc.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 40 in labs/lab-11/tasks/entry-fix-1/tests/graded_test.inc.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
21 changes: 21 additions & 0 deletions labs/lab-11/tasks/entry-fix-1/tests/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

if test -z "$SRC_PATH"; then
SRC_PATH=../support/
fi

export SRC_PATH
echo ""
(
bash test.sh
) | tee results.txt
echo ""
echo "========================================================================"
total=$(grep '\( passed \| failed \)' results.txt | rev | cut -d ' ' -f 1 | rev | paste -s -d'+' | bc)
echo ""
echo -n "Total: "
echo -n " "
LC_ALL=C printf "%3d/100\n" "$total"

rm results.txt

Check failure on line 21 in labs/lab-11/tasks/entry-fix-1/tests/run_all_tests.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 21 in labs/lab-11/tasks/entry-fix-1/tests/run_all_tests.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
79 changes: 79 additions & 0 deletions labs/lab-11/tasks/entry-fix-1/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

source graded_test.inc.sh


if test -z "$SRC_PATH"; then
SRC_PATH=./../support
fi

if test -z "$TEST_PATH"; then
TEST_PATH="${PWD}"
fi


test_a-c()
{
cd "$SRC_PATH"
cd a-c
make clean > /dev/null 2>&1
if make -S > /dev/null 2>/dev/null; then
make clean > /dev/null 2>&1
exit 0
else
make clean > /dev/null 2>&1
exit 1
fi
cd "$TEST_PATH"
}

test_b-asm()
{
cd "$SRC_PATH"
cd b-asm
make clean > /dev/null 2>&1
if make -S > /dev/null 2>/dev/null; then
make clean > /dev/null 2>&1
exit 0
else
make clean > /dev/null 2>&1
exit 1
fi
cd "$TEST_PATH"
}

test_c-extra-nolibc()
{
cd "$SRC_PATH"
cd c-extra-nolibc
make clean > /dev/null 2>&1
if make -S > /dev/null 2>/dev/null; then
make clean > /dev/null 2>&1
exit 0
else
make clean > /dev/null 2>&1
exit 1
fi
cd "$TEST_PATH"
}

test_d-extra-libc()
{
cd "$SRC_PATH"
cd d-extra-libc
make clean > /dev/null 2>&1
if make -S > /dev/null 2>/dev/null; then
make clean > /dev/null 2>&1
exit 0
else
make clean > /dev/null 2>&1
exit 1
fi
cd "$TEST_PATH"
}

run_test test_a-c 25
run_test test_b-asm 25
run_test test_c-extra-nolibc 25
run_test test_d-extra-libc 25

Check failure on line 79 in labs/lab-11/tasks/entry-fix-1/tests/test.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 79 in labs/lab-11/tasks/entry-fix-1/tests/test.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
19 changes: 19 additions & 0 deletions labs/lab-11/tasks/entry-fix-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,23 @@
Access the directory `tasks/entry-fix-2/support/`.
Run the `make` command, interpret the encountered error, and resolve it by editing the `hello.c` file.

**Checker**: To test the implementation, enter the tests/ directory and run:

```
./run_all_tests.sh
```

In case of a correct solution, you will get this output:

```
./run_all_tests.sh

Check failure on line 20 in labs/lab-11/tasks/entry-fix-2/README.md

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace

Check failure on line 20 in labs/lab-11/tasks/entry-fix-2/README.md

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace

test_EntryFix2 ........................ passed ... 100

========================================================================

Total: 100/100
```


If you're having difficulties solving this exercise, go through [this](../../reading/linking.md) reading material.
40 changes: 40 additions & 0 deletions labs/lab-11/tasks/entry-fix-2/tests/graded_test.inc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

#
# Print test result. Printed message should fit in 72 characters.
#
# Print format is:
#
# description ...................... passed ... NNN
# description ...................... failed ... NNN
# 32 chars 24 chars 6 3 3
#

print_test()
{
func="$1"
result="$2"
points="$3"

if test "$points" -gt 999; then
points=999
fi

printf "%-32s " "${func:0:31}"
printf "........................"
if test "$result" -eq 0; then
printf " passed ... %3d\n" "$points"
else
printf " failed ... 0\n"
fi
}

run_test()
{
func="$1"
points="$2"
# Run in subshell.
(eval "$func")
print_test "$func" "$?" "$points"
}

Check failure on line 40 in labs/lab-11/tasks/entry-fix-2/tests/graded_test.inc.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 40 in labs/lab-11/tasks/entry-fix-2/tests/graded_test.inc.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
21 changes: 21 additions & 0 deletions labs/lab-11/tasks/entry-fix-2/tests/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

if test -z "$SRC_PATH"; then
SRC_PATH=../support/
fi

export SRC_PATH
echo ""
(
bash test.sh
) | tee results.txt
echo ""
echo "========================================================================"
total=$(grep '\( passed \| failed \)' results.txt | rev | cut -d ' ' -f 1 | rev | paste -s -d'+' | bc)
echo ""
echo -n "Total: "
echo -n " "
LC_ALL=C printf "%3d/100\n" "$total"

rm results.txt

Check failure on line 21 in labs/lab-11/tasks/entry-fix-2/tests/run_all_tests.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 21 in labs/lab-11/tasks/entry-fix-2/tests/run_all_tests.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
32 changes: 32 additions & 0 deletions labs/lab-11/tasks/entry-fix-2/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

source graded_test.inc.sh


if test -z "$SRC_PATH"; then
SRC_PATH=./../support
fi

if test -z "$TEST_PATH"; then
TEST_PATH="${PWD}"
fi


test_EntryFix2()
{
cd "$SRC_PATH"
make clean > /dev/null 2>&1
if make -S > /dev/null 2>/dev/null; then
make clean > /dev/null 2>&1
exit 0
else
make clean > /dev/null 2>&1
exit 1
fi
cd "$TEST_PATH"
}



run_test test_EntryFix2 100

Check failure on line 32 in labs/lab-11/tasks/entry-fix-2/tests/test.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 32 in labs/lab-11/tasks/entry-fix-2/tests/test.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
22 changes: 22 additions & 0 deletions labs/lab-11/tasks/export-fix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,26 @@
Each subdirectory (`a-func/`, `b-var/`, `c-var-2/`) contains a problem related to the export of symbols (functions or variables).
In each subdirectory, run the `make` command, identify the issue, and edit the necessary files to resolve it.

**Checker**: To test the implementation, enter the tests/ directory and run:

```
./run_all_tests.sh
```

In case of a correct solution, you will get this output:

```
./run_all_tests.sh

Check failure on line 21 in labs/lab-11/tasks/export-fix/README.md

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace

Check failure on line 21 in labs/lab-11/tasks/export-fix/README.md

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace

test_a-func ........................ passed ... 30
test_b-var ........................ passed ... 30
test_c-var-2 ........................ passed ... 40

========================================================================

Total: 100/100
```



If you're having difficulties solving this exercise, go through [this](../../reading/linking.md) reading material.
40 changes: 40 additions & 0 deletions labs/lab-11/tasks/export-fix/tests/graded_test.inc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

#
# Print test result. Printed message should fit in 72 characters.
#
# Print format is:
#
# description ...................... passed ... NNN
# description ...................... failed ... NNN
# 32 chars 24 chars 6 3 3
#

print_test()
{
func="$1"
result="$2"
points="$3"

if test "$points" -gt 999; then
points=999
fi

printf "%-32s " "${func:0:31}"
printf "........................"
if test "$result" -eq 0; then
printf " passed ... %3d\n" "$points"
else
printf " failed ... 0\n"
fi
}

run_test()
{
func="$1"
points="$2"
# Run in subshell.
(eval "$func")
print_test "$func" "$?" "$points"
}

Check failure on line 40 in labs/lab-11/tasks/export-fix/tests/graded_test.inc.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file

Check failure on line 40 in labs/lab-11/tasks/export-fix/tests/graded_test.inc.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
21 changes: 21 additions & 0 deletions labs/lab-11/tasks/export-fix/tests/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause

if test -z "$SRC_PATH"; then
SRC_PATH=../support/
fi

export SRC_PATH
echo ""
(
bash test.sh
) | tee results.txt
echo ""
echo "========================================================================"
total=$(grep '\( passed \| failed \)' results.txt | rev | cut -d ' ' -f 1 | rev | paste -s -d'+' | bc)
echo ""
echo -n "Total: "
echo -n " "
LC_ALL=C printf "%3d/100\n" "$total"

rm results.txt
Loading