Skip to content

Commit

Permalink
Merge pull request SJTU-IPADS#68 from ToolmanP/main
Browse files Browse the repository at this point in the history
feat(grader): add grader verbose option
  • Loading branch information
ToolmanP authored Dec 5, 2024
2 parents 6d1a210 + 8a5f5a8 commit bc988c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 17 additions & 1 deletion Scripts/capturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
try:
import psutil
except ImportError:
print("This script requires PsUtil as main dependencies. Please install this module first.")
print(
"This script requires PsUtil as main dependencies. Please install this module first."
)
sys.exit(255)


@dataclass
class LineCapture:
"""Line capture definition. Used for parsing scores.json in lab folders."""
Expand Down Expand Up @@ -86,7 +89,12 @@ async def main(args: argparse.Namespace):
break
if len(line) == 0 and process.returncode is not None:
break

decoded_line = line.decode()

if args.verbose:
print(decoded_line, end="")

for line_capture in captures:
if (
args.serial
Expand Down Expand Up @@ -137,6 +145,14 @@ async def main(args: argparse.Namespace):
required=False,
help="Serial Number to proceed.",
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
required=False,
default=False,
help="Verbose mode.",
)
parser.add_argument("command", nargs=argparse.REMAINDER, help="Command to grade.")
args = parser.parse_args()
try:
Expand Down
9 changes: 7 additions & 2 deletions Scripts/kernel.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
V ?= 0
Q := @

GRADER_V :=
ifeq ($(V), 1)
Q :=
endif

ifeq ($(V), 2)
Q :=
GRADER_V := -v
endif

BUILDDIR := $(LABDIR)/build
KERNEL_IMG := $(BUILDDIR)/kernel.img
_QEMU := $(SCRIPTS)/qemu_wrapper.sh $(QEMU)
Expand Down Expand Up @@ -50,6 +55,6 @@ gdb:

grade:
$(MAKE) distclean
$(Q)$(DOCKER_RUN) $(GRADER) -t $(TIMEOUT) -f $(LABDIR)/scores.json -s $(SERIAL) make SERIAL=$(SERIAL) qemu-grade
$(Q)$(DOCKER_RUN) $(GRADER) -t $(TIMEOUT) -f $(LABDIR)/scores.json $(GRADER_V) -s $(SERIAL) make SERIAL=$(SERIAL) qemu-grade

.PHONY: qemu qemu-gdb gdb defconfig build clean distclean grade all

0 comments on commit bc988c9

Please sign in to comment.