Ver a proveniência

Save intermediate logs

Signed-off-by: Junjie Mao <eternal.n08@gmail.com>
main
Junjie Mao há 9 anos
ascendente
cometimento
1d8c85670d
12 ficheiros alterados com 116 adições e 3 eliminações
  1. +1
    -1
      .gitignore
  2. +26
    -2
      labcodes/autotest.sh
  3. +44
    -0
      labcodes/formatter.py
  4. +2
    -0
      labcodes/lab1/tools/grade.sh
  5. +2
    -0
      labcodes/lab2/tools/grade.sh
  6. +2
    -0
      labcodes/lab3/tools/grade.sh
  7. +2
    -0
      labcodes/lab4/tools/grade.sh
  8. +2
    -0
      labcodes/lab5/tools/grade.sh
  9. +2
    -0
      labcodes/lab6/tools/grade.sh
  10. +2
    -0
      labcodes/lab7/tools/grade.sh
  11. +2
    -0
      labcodes/lab8/tools/grade.sh
  12. +29
    -0
      labcodes/tools/split_score_log.py

+ 1
- 1
.gitignore Ver ficheiro

@ -15,5 +15,5 @@ tags
*.project
*.workspace
a.out
make.log
*.log
*.exe

+ 26
- 2
labcodes/autotest.sh Ver ficheiro

@ -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

+ 44
- 0
labcodes/formatter.py Ver ficheiro

@ -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()

+ 2
- 0
labcodes/lab1/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab2/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab3/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab4/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab5/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab6/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab7/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 2
- 0
labcodes/lab8/tools/grade.sh Ver ficheiro

@ -183,6 +183,8 @@ build_run() {
run_qemu
show_time
cp $qemu_out .`echo $tag | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`.log
}
check_result() {

+ 29
- 0
labcodes/tools/split_score_log.py Ver ficheiro

@ -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

Carregando…
Cancelar
Guardar