Skip to content

Commit

Permalink
assigments/parallel-firewall: Add resilience to compilation failures
Browse files Browse the repository at this point in the history
Make checker look out for the binary to run because if the compiation
failed, there won't be any.

Also, use `$(MAKE)` instead of plain `make` from inside the
`tests/Makefile` as that is the intended way to do it.

Also 2, removing `-i` from the makefile invocation make the inner
makefile fail after the first error, and adding `-` makes it not stop
the outter makefile rule (i.e. also run the checker)

Signed-off-by: Anton-Fabian Patras <[email protected]>
  • Loading branch information
fabianpatras committed Nov 4, 2024
1 parent de8a8e1 commit 0ee7ed7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions content/assignments/parallel-firewall/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ UTILS_PATH = $(realpath ../utils)
all: src

src:
make -C $(SRC_PATH) UTILS_PATH=$(UTILS_PATH)
$(MAKE) -C $(SRC_PATH) UTILS_PATH=$(UTILS_PATH)

check: clean
make -i SRC_PATH=$(SRC_PATH)
-$(MAKE) SRC_PATH=$(SRC_PATH)
SRC_PATH=$(SRC_PATH) python3 checker.py

lint:
Expand All @@ -20,7 +20,7 @@ lint:
# -cd $(SRC_PATH)/.. && pylint tests/*.py

clean:
make -C $(SRC_PATH) clean
$(MAKE) -C $(SRC_PATH) clean
-rm -f *~
-rm -rf __pycache__
-rm -rf out
Expand Down
4 changes: 4 additions & 0 deletions content/assignments/parallel-firewall/tests/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ def run_once_and_check_output(
except FileNotFoundError:
pass

if not os.path.exists(binary):
print("No program to run, maybe compilation failed?")
return False

with subprocess.Popen(
[binary, in_file_path, out_file_path, f"{threads}"],
stdout=subprocess.PIPE,
Expand Down

0 comments on commit 0ee7ed7

Please sign in to comment.