From 6bee8387846199d8f50c26a1fe66bf357f4b65ab Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Thu, 12 Mar 2015 16:01:32 +0800 Subject: [PATCH 1/4] Messages may have escaped characters Signed-off-by: Junjie Mao --- labcodes/lab1/tools/grade.sh | 2 +- labcodes/lab2/tools/grade.sh | 2 +- labcodes/lab3/tools/grade.sh | 2 +- labcodes/lab4/tools/grade.sh | 2 +- labcodes/lab5/tools/grade.sh | 2 +- labcodes/lab6/tools/grade.sh | 2 +- labcodes/lab7/tools/grade.sh | 2 +- labcodes/lab8/tools/grade.sh | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes/lab1/tools/grade.sh b/labcodes/lab1/tools/grade.sh index f90d1a1..1a1ca26 100644 --- a/labcodes/lab1/tools/grade.sh +++ b/labcodes/lab1/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab2/tools/grade.sh b/labcodes/lab2/tools/grade.sh index 483b385..ba0e162 100644 --- a/labcodes/lab2/tools/grade.sh +++ b/labcodes/lab2/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab3/tools/grade.sh b/labcodes/lab3/tools/grade.sh index a6f2425..c4c6cab 100644 --- a/labcodes/lab3/tools/grade.sh +++ b/labcodes/lab3/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab4/tools/grade.sh b/labcodes/lab4/tools/grade.sh index 8d2b2bd..5ad73b0 100644 --- a/labcodes/lab4/tools/grade.sh +++ b/labcodes/lab4/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab5/tools/grade.sh b/labcodes/lab5/tools/grade.sh index 29db669..29e7f14 100644 --- a/labcodes/lab5/tools/grade.sh +++ b/labcodes/lab5/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab6/tools/grade.sh b/labcodes/lab6/tools/grade.sh index a3a52d0..bf48013 100644 --- a/labcodes/lab6/tools/grade.sh +++ b/labcodes/lab6/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab7/tools/grade.sh b/labcodes/lab7/tools/grade.sh index e8c68bd..7cd37cd 100644 --- a/labcodes/lab7/tools/grade.sh +++ b/labcodes/lab7/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } diff --git a/labcodes/lab8/tools/grade.sh b/labcodes/lab8/tools/grade.sh index 920a344..0010361 100644 --- a/labcodes/lab8/tools/grade.sh +++ b/labcodes/lab8/tools/grade.sh @@ -105,7 +105,7 @@ show_msg() { echo $1 shift if [ $# -gt 0 ]; then - echo "$@" | awk '{printf " %s\n", $0}' + echo -e "$@" | awk '{printf " %s\n", $0}' echo fi } From 67f05c0ce0cd1ee900313b1b2ffbe678f7502fd5 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Thu, 12 Mar 2015 16:02:32 +0800 Subject: [PATCH 2/4] break on the physical address of brkfunc The kernel may panic early when paging is not yet configured. Breaking only on the virtual address of brkfunc does not work in this case and leads to timeouts during 'make grade'. Signed-off-by: Junjie Mao --- labcodes/lab1/tools/grade.sh | 5 ++++- labcodes/lab2/tools/grade.sh | 5 ++++- labcodes/lab3/tools/grade.sh | 5 ++++- labcodes/lab4/tools/grade.sh | 5 ++++- labcodes/lab5/tools/grade.sh | 5 ++++- labcodes/lab6/tools/grade.sh | 5 ++++- labcodes/lab7/tools/grade.sh | 5 ++++- labcodes/lab8/tools/grade.sh | 5 ++++- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/labcodes/lab1/tools/grade.sh b/labcodes/lab1/tools/grade.sh index 1a1ca26..8ea2a23 100644 --- a/labcodes/lab1/tools/grade.sh +++ b/labcodes/lab1/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -345,4 +349,3 @@ quick_check 'check ticks' \ ## print final-score show_final - diff --git a/labcodes/lab2/tools/grade.sh b/labcodes/lab2/tools/grade.sh index ba0e162..5ab3e0e 100644 --- a/labcodes/lab2/tools/grade.sh +++ b/labcodes/lab2/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -337,4 +341,3 @@ quick_check 'check ticks' \ ## print final-score show_final - diff --git a/labcodes/lab3/tools/grade.sh b/labcodes/lab3/tools/grade.sh index c4c6cab..02fc22d 100644 --- a/labcodes/lab3/tools/grade.sh +++ b/labcodes/lab3/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -361,4 +365,3 @@ quick_check 'check ticks' \ ## print final-score show_final - diff --git a/labcodes/lab4/tools/grade.sh b/labcodes/lab4/tools/grade.sh index 5ad73b0..502ca6b 100644 --- a/labcodes/lab4/tools/grade.sh +++ b/labcodes/lab4/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -365,4 +369,3 @@ quick_check 'check initproc' \ ## print final-score show_final - diff --git a/labcodes/lab5/tools/grade.sh b/labcodes/lab5/tools/grade.sh index 29e7f14..382603e 100644 --- a/labcodes/lab5/tools/grade.sh +++ b/labcodes/lab5/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -552,4 +556,3 @@ run_test -prog 'forktree' -check default_check \ ## print final-score show_final - diff --git a/labcodes/lab6/tools/grade.sh b/labcodes/lab6/tools/grade.sh index bf48013..a30feee 100644 --- a/labcodes/lab6/tools/grade.sh +++ b/labcodes/lab6/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -578,4 +582,3 @@ run_test -prog 'priority' -check default_check \ ## print final-score show_final - diff --git a/labcodes/lab7/tools/grade.sh b/labcodes/lab7/tools/grade.sh index 7cd37cd..9fae5ad 100644 --- a/labcodes/lab7/tools/grade.sh +++ b/labcodes/lab7/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -632,4 +636,3 @@ run_test -prog 'matrix' -check default_check \ ## print final-score show_final - diff --git a/labcodes/lab8/tools/grade.sh b/labcodes/lab8/tools/grade.sh index 0010361..345effd 100644 --- a/labcodes/lab8/tools/grade.sh +++ b/labcodes/lab8/tools/grade.sh @@ -146,9 +146,13 @@ run_qemu() { if [ -n "$brkfun" ]; then # find the address of the kernel $brkfun function brkaddr=`$grep " $brkfun\$" $sym_table | $sed -e's/ .*$//g'` + brkaddr_phys=`echo $brkaddr | sed "s/^c0/00/g"` ( echo "target remote localhost:$gdbport" echo "break *0x$brkaddr" + if [ "$brkaddr" != "$brkaddr_phys" ]; then + echo "break *0x$brkaddr_phys" + fi echo "continue" ) > $gdb_in @@ -636,4 +640,3 @@ run_test -prog 'matrix' -check default_check \ ## print final-score show_final - From 1d8c85670d03ce745e32bbc57147835b210fe560 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Thu, 12 Mar 2015 16:05:28 +0800 Subject: [PATCH 3/4] Save intermediate logs Signed-off-by: Junjie Mao --- .gitignore | 2 +- labcodes/autotest.sh | 28 ++++++++++++++++++-- labcodes/formatter.py | 44 +++++++++++++++++++++++++++++++ labcodes/lab1/tools/grade.sh | 2 ++ labcodes/lab2/tools/grade.sh | 2 ++ labcodes/lab3/tools/grade.sh | 2 ++ labcodes/lab4/tools/grade.sh | 2 ++ labcodes/lab5/tools/grade.sh | 2 ++ labcodes/lab6/tools/grade.sh | 2 ++ labcodes/lab7/tools/grade.sh | 2 ++ labcodes/lab8/tools/grade.sh | 2 ++ labcodes/tools/split_score_log.py | 29 ++++++++++++++++++++ 12 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 labcodes/formatter.py create mode 100644 labcodes/tools/split_score_log.py diff --git a/.gitignore b/.gitignore index 2332926..062b38f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,5 @@ tags *.project *.workspace a.out -make.log +*.log *.exe diff --git a/labcodes/autotest.sh b/labcodes/autotest.sh index 1ce5b53..cb74eab 100755 --- a/labcodes/autotest.sh +++ b/labcodes/autotest.sh @@ -1,10 +1,23 @@ #!/bin/bash +# change working dir to where this script resides in +pushd `dirname "$0"` > /dev/null + +if [ -n "$1" ]; then + RESULT_SAVETO=`realpath $1` +fi BASE_COMMIT=95a80f598fc57c60aed3737c60ee437d94eb8540 +if [ -n "$2" ] && git log $2 > /dev/null 2>&1; then + BASE_COMMIT=$2 +elif ! git log $BASE_COMMIT > /dev/null 2>&1; then + echo "No valid base commit found." + exit 0 +fi LABS=`git diff $BASE_COMMIT --stat | grep -o "lab[0-9]" | uniq` +COMMIT=`git rev-parse HEAD` if [ "$LABS" = "" ]; then - echo "No solutions provided. Skip this time." + echo "No updated lab found. Skip." exit 0 fi @@ -19,6 +32,14 @@ for lab in $LABS; do if ! make grade > .score 2>&1; then failed=`echo $lab | grep -o [0-9]` fi + if [ -n "$RESULT_SAVETO" ]; then + mkdir -p $RESULT_SAVETO/$COMMIT/$lab + mv .score .score_orig + ../tools/split_score_log.py .score_orig > .score + for i in .*.log .*.error; do + cp $i $RESULT_SAVETO/$COMMIT/$lab/${i#.} + done + fi score=`egrep -o "Score: [0-9]+/[0-9]+" .score` echo "$lab $score" >> $summary make clean > /dev/null @@ -35,7 +56,10 @@ echo for lab in $LABS; do echo "================================ $lab ===============================" cat $lab/.score - rm $lab/.score done +find . -name '.*' -delete + +popd > /dev/null + exit $failed diff --git a/labcodes/formatter.py b/labcodes/formatter.py new file mode 100644 index 0000000..f4071ad --- /dev/null +++ b/labcodes/formatter.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import os, sys +import re + +if len(sys.argv) < 5: + print 'Usage: formatter.py
' + sys.exit() + +tid_regex = re.compile('([a-z0-9]+)-.*') +lab_title = re.compile('=* (lab[0-9]) =*') +test_entry_title = re.compile('^([\w][\w -]+)(:.*)') + +section = sys.argv[1] +result_dir = sys.argv[2] +repo = sys.argv[3] +tid = sys.argv[4] +m = tid_regex.match(tid) +if not m: + print 'Invalid tid' + sys.exit() +commit = m.group(1) + +lab = '' +while True: + l = sys.stdin.readline() + if not l: + break + line = l.rstrip('\n') + output = line + m = test_entry_title.match(line) + if m and lab: + test_entry = m.group(1).lower().replace(' ', '_') + test_log = os.path.join(result_dir, repo, commit, lab, test_entry + ".error") + if os.path.exists(test_log): + rest = m.group(2) + output = '' + m.group(1) + '' + rest + m = lab_title.match(line) + if m: + lab = m.group(1) + + sys.stdout.write(output + '
') + +sys.stdout.flush() diff --git a/labcodes/lab1/tools/grade.sh b/labcodes/lab1/tools/grade.sh index 8ea2a23..ccf4078 100644 --- a/labcodes/lab1/tools/grade.sh +++ b/labcodes/lab1/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab2/tools/grade.sh b/labcodes/lab2/tools/grade.sh index 5ab3e0e..b239dc6 100644 --- a/labcodes/lab2/tools/grade.sh +++ b/labcodes/lab2/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab3/tools/grade.sh b/labcodes/lab3/tools/grade.sh index 02fc22d..7e4f150 100644 --- a/labcodes/lab3/tools/grade.sh +++ b/labcodes/lab3/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab4/tools/grade.sh b/labcodes/lab4/tools/grade.sh index 502ca6b..3aab81a 100644 --- a/labcodes/lab4/tools/grade.sh +++ b/labcodes/lab4/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab5/tools/grade.sh b/labcodes/lab5/tools/grade.sh index 382603e..4b46529 100644 --- a/labcodes/lab5/tools/grade.sh +++ b/labcodes/lab5/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab6/tools/grade.sh b/labcodes/lab6/tools/grade.sh index a30feee..f8bbdaa 100644 --- a/labcodes/lab6/tools/grade.sh +++ b/labcodes/lab6/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab7/tools/grade.sh b/labcodes/lab7/tools/grade.sh index 9fae5ad..58dc875 100644 --- a/labcodes/lab7/tools/grade.sh +++ b/labcodes/lab7/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/lab8/tools/grade.sh b/labcodes/lab8/tools/grade.sh index 345effd..62987e3 100644 --- a/labcodes/lab8/tools/grade.sh +++ b/labcodes/lab8/tools/grade.sh @@ -183,6 +183,8 @@ build_run() { run_qemu show_time + + cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log } check_result() { diff --git a/labcodes/tools/split_score_log.py b/labcodes/tools/split_score_log.py new file mode 100644 index 0000000..fc90eff --- /dev/null +++ b/labcodes/tools/split_score_log.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# +# Note: This script is intended to be executed at labcodes/labX + +import sys, os +import re + +if len(sys.argv) < 2: + print 'Usage: split_score_log.py ' + sys.exit() + +raw_log_f = sys.argv[1] +test_entry_title = re.compile('^([\w][\w -]+): *\([0-9.]*s\)') + +raw_log = open(raw_log_f, 'r') +current_test = '' +for line in raw_log.readlines(): + line = line.strip('\n') + m = test_entry_title.match(line) + if m: + print line + current_test = m.group(1) + error_log = open('.' + current_test.lower().replace(' ', '_') + '.error', 'w+') + print >> error_log, line + continue + if (not line or line[0] == ' ') and current_test != '': + print >> error_log, line + if (line and line[0] != ' ') or line.find('-check') >= 0: + print line From 642e3f88ae1b5900425a422327bb4839484c10ae Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Thu, 12 Mar 2015 16:06:07 +0800 Subject: [PATCH 4/4] Update base commit Signed-off-by: Junjie Mao --- labcodes/autotest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labcodes/autotest.sh b/labcodes/autotest.sh index cb74eab..5c6e443 100755 --- a/labcodes/autotest.sh +++ b/labcodes/autotest.sh @@ -6,7 +6,7 @@ pushd `dirname "$0"` > /dev/null if [ -n "$1" ]; then RESULT_SAVETO=`realpath $1` fi -BASE_COMMIT=95a80f598fc57c60aed3737c60ee437d94eb8540 +BASE_COMMIT=1d8c85670d03ce745e32bbc57147835b210fe560 if [ -n "$2" ] && git log $2 > /dev/null 2>&1; then BASE_COMMIT=$2 elif ! git log $BASE_COMMIT > /dev/null 2>&1; then