Merge pull request #4 from eternalNight/master
Make ucore_lab autotest compatible
This commit is contained in:
		
						commit
						2aecf2fe29
					
				@ -1,10 +1,23 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
BASE_COMMIT=95a80f598fc57c60aed3737c60ee437d94eb8540
 | 
			
		||||
# 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=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
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										44
									
								
								labcodes/formatter.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								labcodes/formatter.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
#!/usr/bin/env python
 | 
			
		||||
 | 
			
		||||
import os, sys
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
if len(sys.argv) < 5:
 | 
			
		||||
    print 'Usage: formatter.py <section name> <result-dir> <repo> <tid>'
 | 
			
		||||
    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 = '<a href="/repo/' + '/'.join([repo, commit, lab, test_entry]) + '">' + m.group(1) + '</a>' + rest
 | 
			
		||||
    m = lab_title.match(line)
 | 
			
		||||
    if m:
 | 
			
		||||
        lab = m.group(1)
 | 
			
		||||
 | 
			
		||||
    sys.stdout.write(output + '<br>')
 | 
			
		||||
 | 
			
		||||
sys.stdout.flush()
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
	run_qemu
 | 
			
		||||
 | 
			
		||||
	show_time
 | 
			
		||||
 | 
			
		||||
	cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -345,4 +351,3 @@ quick_check 'check ticks'										\
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -337,4 +343,3 @@ quick_check 'check ticks'                                       \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -361,4 +367,3 @@ quick_check 'check ticks'                                       \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -365,4 +371,3 @@ quick_check 'check initproc'                                    \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -552,4 +558,3 @@ run_test -prog 'forktree'    -check default_check               \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -578,4 +584,3 @@ run_test -prog 'priority'      -check default_check             \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -632,4 +638,3 @@ run_test -prog 'matrix'     -check default_check                \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -179,6 +183,8 @@ build_run() {
 | 
			
		||||
    run_qemu
 | 
			
		||||
 | 
			
		||||
    show_time
 | 
			
		||||
 | 
			
		||||
    cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_result() {
 | 
			
		||||
@ -636,4 +642,3 @@ run_test -prog 'matrix'     -check default_check                \
 | 
			
		||||
 | 
			
		||||
## print final-score
 | 
			
		||||
show_final
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										29
									
								
								labcodes/tools/split_score_log.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								labcodes/tools/split_score_log.py
									
									
									
									
									
										Normal file
									
								
							@ -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 <raw log file> <lab>'
 | 
			
		||||
    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
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user