# Makefile for MO-P contest environment
-# (c) 2008 Martin Mares <mj@ucw.cz>
+# (c) 2008--2015 Martin Mares <mj@ucw.cz>
DIRS+=mop
include $(s)/mop/admin/Makefile
-include $(s)/mop/eval/Makefile
-include $(s)/mop/public/Makefile
-include $(s)/mop/score/Makefile
-include $(s)/mop/calibrate/Makefile
CONFIGS+=mop userlist
run/cf/mop: $(o)/mop/mop.cf
# Makefile for MO-P contest environment
-# (c) 2008 Martin Mares <mj@ucw.cz>
+# (c) 2008--2015 Martin Mares <mj@ucw.cz>
DIRS+=mop/admin
PROGS+=$(addprefix $(o)/mop/admin/,\
md5crypt \
- mo-backup mo-back-status \
- mo-install mo-create-contestants mo-create-eval mo-create-logins \
- mo-create-public mo-create-submit mo-create-testusers \
- mo-grab mo-back-grab mo-grab-remote \
- mo-push-certs mo-push-feedback mo-cms-users)
+ mo-backup \
+ mo-cms-users \
+ mo-create-contestants mo-create-logins mo-create-public \
+ mo-get-users)
$(o)/mop/admin/md5crypt: $(o)/mop/admin/md5crypt.o $(LIBUCW)
-$(o)/mop/admin/mo-back-grab: $(s)/mop/admin/mo-back-grab.sh
-$(o)/mop/admin/mo-back-status: $(s)/mop/admin/mo-back-status.sh
$(o)/mop/admin/mo-backup: $(s)/mop/admin/mo-backup.sh
+$(o)/mop/admin/mo-cms-users: $(s)/mop/admin/mo-cms-users.pl
+$(o)/mop/admin/mo-get-users: $(s)/mop/admin/mo-get-users.sh
$(o)/mop/admin/mo-create-contestants: $(s)/mop/admin/mo-create-contestants.sh
-$(o)/mop/admin/mo-create-eval: $(s)/mop/admin/mo-create-eval.sh
$(o)/mop/admin/mo-create-logins: $(s)/mop/admin/mo-create-logins.sh
$(o)/mop/admin/mo-create-public: $(s)/mop/admin/mo-create-public.sh
-$(o)/mop/admin/mo-create-submit: $(s)/mop/admin/mo-create-submit.sh
-$(o)/mop/admin/mo-create-testusers: $(s)/mop/admin/mo-create-testusers.sh
-$(o)/mop/admin/mo-grab-remote: $(s)/mop/admin/mo-grab-remote.sh
-$(o)/mop/admin/mo-grab: $(s)/mop/admin/mo-grab.sh
-$(o)/mop/admin/mo-install: $(s)/mop/admin/mo-install.sh
-$(o)/mop/admin/mo-push-certs: $(s)/mop/admin/mo-push-certs.sh
-$(o)/mop/admin/mo-push-feedback: $(s)/mop/admin/mo-push-feedback.sh
-$(o)/mop/admin/mo-cms-users: $(s)/mop/admin/mo-cms-users.pl
+++ /dev/null
-#!/bin/bash
-# Find all submits in the local copy of contestants' home directories
-# (as created by mo-backup) and copy them to solutions/.
-
-if [ -z "$1" ] ; then
- echo "Directory name expected"
- exit 1
-fi
-rm -rf solutions/mo*
-for m in `cd $1 ; echo *` ; do
- echo -n "$m:"
- for d in $1/$m/mo??/mo?? ; do
- u=`basename $d`
- if [ $u != mo00 -a -d $d/.submit ] ; then
- echo -n " $u"
- if [ -d solutions/$u ] ; then
- echo -n "<DUP!!!>"
- else
- cp -a $d/.submit solutions/$u
- fi
- fi
- done
- echo
-done
+++ /dev/null
-#!/bin/bash
-# Find all submits in the local copy of contestants' home directories
-# (as created by mo-backup) and print their status.
-
-if [ -z "$1" ] ; then
- echo "Directory name expected"
- exit 1
-fi
-for m in `cd $1 ; echo *` ; do
- echo -n "$m:"
- for d in $1/$m/mo??/mo?? ; do
- u=`basename $d`
- if [ $u != mo00 -a `ls $d | wc -l` -gt 0 ] ; then
- echo -n " $u"
- if [ -d $d/.submit ] ; then
- echo -n '('
- ( cd $d/.submit ; echo -n * )
- echo -n ')'
- fi
- fi
- done
- echo
-done
+++ /dev/null
-#!/bin/bash
-# Create home directory of the user who runs the evaluator.
-
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-H=`pwd`
-cd $MO_ROOT/eval
-
-echo "Creating $EVAL_USER"
-rm -rf eval
-mkdir eval
-cd eval
-cp -aL $H/* .
-if [ -d ~/.ssh ] ; then echo "Copying SSH configuration from ~/.ssh" ; cp -a ~/.ssh . ; fi
-cd ..
-chown -R $EVAL_USER.$EVAL_GROUP eval
-chmod 750 eval
+++ /dev/null
-#!/bin/bash
-# Create home directory of the submit server.
-
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-[ -n "$REMOTE_SUBMIT" ] || { echo "Remote submit not enabled." ; exit 1 ; }
-
-echo "Creating submit directory"
-
-H=`pwd`
-cd $MO_ROOT/eval/submit
-mkdir -p certs
-cp $H/certs/server* certs/
-cp $H/certs/ca-cert.pem certs/
-
-rm -rf bin cf lib
-mkdir bin cf
-cp $H/bin/{submitd,show-submits} bin/
-cp $H/cf/{submitd,libucw} cf/
-cp -aL $H/lib .
-
-mkdir -p solutions
-for a in `cd $H && bin/mo-get-users` ; do
- mkdir -p solutions/$a
-done
-
-rm -rf tmp
-mkdir -p tmp
-
-mkdir -p log history
-
-chown -R $REMOTE_SUBMIT_USER.$REMOTE_SUBMIT_GROUP $MO_ROOT/eval/submit
+++ /dev/null
-#!/bin/bash
-# Create accounts used by the sandbox.
-
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-H=`pwd`
-cd $MO_ROOT/eval
-
-# mo-test home
-for u in $TEST_USERS ; do
- echo "Creating $u"
- rm -rf ./$u
- mkdir $u
- chown $u.$TEST_GROUP $u
- chmod 770 $u
- cp $H/bin/box eval/bin/box-$u
- chown $u.$EVAL_GROUP eval/bin/box-$u
- chmod 4550 eval/bin/box-$u
-done
--- /dev/null
+#!/bin/bash
+# List all contestants according to $CT_USER_LIST
+
+if [ "$1" = --help ] ; then
+ echo "Usage: mo-get-users [--full]"
+fi
+[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
+set -e
+. cf/mop
+
+if [ "$1" = --full ] ; then
+ cut -d ' ' -f 1,2 <$CT_USER_LIST
+else
+ cut -d ' ' -f 1 <$CT_USER_LIST
+fi
+++ /dev/null
-#!/bin/bash
-# Grab all submits from the submit server and copy them to solutions/.
-
-[ -n "$1" ] || { echo "Usage: mo-grab-remote <tasks>" ; exit 1 ; }
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-rsync -a --delete mo-submit@mo100:solutions/ submits
-for user in `bin/mo-get-users` ; do
- echo -n "$user:"
- mkdir -p solutions/$user
- for t in $@ ; do
- rm -rf solutions/$user/$t
- D=submits/$user/$t
- if [ -d $D ] ; then
- echo -n " $t"
- cp -a $D solutions/$user/$t
- fi
- done
- echo
-done
+++ /dev/null
-#!/bin/bash
-# Grab all submits from contestants' home directories located on the
-# local machine and copy them to solutions/.
-
-[ -n "$1" ] || { echo "Usage: mo-grab <tasks>" ; exit 1 ; }
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-for user in `bin/mo-get-users` ; do
- echo -n "$user:"
- H=`eval echo ~$user`/.submit
- if [ -d $H ] ; then
- [ -d solutions/$user ] || mkdir -p solutions/$user
- for t in $@ ; do
- rm -rf solutions/$user/$t
- if [ -d $H/$t ] ; then
- echo -n " $t"
- cp -dr $H/$t solutions/$user/$t
- fi
- done
- echo
- else
- echo " ---"
- fi
-done
-chown -R $EVAL_USER solutions
-chmod -R a+r solutions
+++ /dev/null
-#!/bin/bash
-
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-H=`pwd`
-
-# The eval directory
-cd $MO_ROOT
-rm -rf eval
-mkdir eval
-chgrp $EVAL_GROUP eval
-chmod 755 eval
-cd eval
-
-# mo-eval home
-( cd $H && bin/mo-create-eval )
-
-# testusers
-( cd eval && bin/mo-create-testusers )
-
-# mo-submit home
-if [ -n "$REMOTE_SUBMIT" ] ; then
- mkdir submit
- chmod 750 submit
- if [ -d ~/.ssh ] ; then echo "Copying SSH configuration from ~/.ssh" ; cp -a ~/.ssh submit/ ; fi
- ( cd $H && bin/mo-create-submit )
-fi
-
-# create public
-cd $MO_ROOT
-echo "Creating public"
-rm -rf public
-mkdir public
-
-# populate public
-( cd eval/eval ; bin/mo-create-public )
+++ /dev/null
-#!/bin/bash
-# Copy submit certificates to contestants' machines. Each machine gets
-# only the certs of the contestants who should use it.
-
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-while IFS=" " read LOGIN FULL MACH ; do
- if [ -z "$1" -o "$1" == "$LOGIN" ] ; then
- echo "$LOGIN -> $MACH"
- D=$MO_ROOT/users/$LOGIN/$LOGIN/
- rsync -av $D/.mo root@$MACH:$D/
- fi </dev/null
-done <$CT_USER_LIST
+++ /dev/null
-#!/bin/bash
-# Distribute testing results (testing/$USER) to contestants' machines.
-
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-while IFS=" " read LOGIN FULL MACH ; do
- if [ -z "$1" -o "$1" == "$LOGIN" ] ; then
- echo "$LOGIN -> $MACH"
- D=$MO_ROOT/users/$LOGIN/$LOGIN/
- rsync -av ~mo-eval/testing/$LOGIN root@$MACH:$D/results
- ssh root@$MACH "cd $D && chown -R $LOGIN.$LOGIN results"
- fi </dev/null
-done <$CT_USER_LIST
+++ /dev/null
-# Makefile for MO-P contest environment
-# (c) 2010 Martin Mares <mj@ucw.cz>
-
-DIRS+=mop/calibrate
-PROGS+=$(addprefix $(o)/mop/calibrate/,cal-prepare cal-try)
-
-$(o)/mop/calibrate/cal-prepare: $(s)/mop/calibrate/cal-prepare.sh
-$(o)/mop/calibrate/cal-try: $(s)/mop/calibrate/cal-try.sh
+++ /dev/null
-#!/bin/sh
-# Time limit calibrator: Gathering of timing data
-# (c) 2010 Martin Mares <mj@ucw.cz>
-
-set -e
-[ -n "$1" ]
-t="$1"
-mkdir -p cal/$t
-for a in `cd solutions/authors/$t && echo * | sed 's/\.[^ ]*//g'` ; do
- bin/ev authors $t $a
- cp testing/authors/$t/points cal/$t/$a.points
- grep syscalls testing/authors/$t/*.log >cal/$t/$a.log
-done
+++ /dev/null
-#!/usr/bin/perl
-# Time limit calibrator: Simulation
-# (c) 2010 Martin Mares <mj@ucw.cz>
-
-use strict;
-use warnings;
-use List::Util qw(max);
-
-my $t = $ARGV[0] or die;
-my $thresh = $ARGV[1] || 999;
-my $debug = 0;
-
-my %want = ();
-my %points = ();
-my %times = ();
-
-for my $a (<cal/$t/*.points>) {
- my $sol = $a;
- $sol =~ s/^.*\///;
- $sol =~ s/\.points$//;
- my ($want) = ($sol =~ m{(\d+)}) or die "Cannot parse $sol\n";
- print "$sol (want $want):" if $debug;
- $want{$sol} = $want;
-
- open PTS, $a or die;
- while (<PTS>) {
- chomp;
- my ($test, $pts, $comment) = split /\s+/;
- $points{$sol}{$test} = $pts;
- }
- close PTS;
-
- open LOG, "cal/$t/$sol.log" or die;
- while (<LOG>) {
- chomp;
- my ($test, $time) = m{/(\d+[a-z]*)\.log:.*\(([0-9.]+) } or die "Log parse error: $_";
- $times{$sol}{$test} = $time;
- }
- close LOG;
-
- for my $t (sort keys %{$points{$sol}}) {
- defined $times{$sol}{$t} or $times{$sol}{$t}=0;
- print " $t:", $points{$sol}{$t}, "/", $times{$sol}{$t} if $debug;
- }
-
- print "\n" if $debug;
-}
-
-print "\n## Threshold=$thresh\n\n";
-
-for my $s (sort keys %want) {
- my %groups = ();
- my %oks = ();
- my %pts = ();
- my $maxtime = 0;
- my @acc;
- my $lastg = '';
- for my $t (sort keys %{$points{$s}}) {
- my $g = $t;
- $g =~ s{\D+}{};
- if ($g ne $lastg && $lastg ne '') {
- push @acc, "|";
- }
- $lastg = $g;
- $groups{$g}++;
- $oks{$g} += 0;
- if ($times{$s}{$t} <= $thresh) {
- push @acc, ($points{$s}{$t} ? "+" : 0);
- $pts{$g} = $points{$s}{$t};
- $oks{$g}++ if $points{$s}{$t};
- $maxtime = max($maxtime, $times{$s}{$t});
- } else {
- push @acc, "T";
- }
- }
-
- my $sum = 0;
- for my $g (keys %groups) {
- if ($groups{$g} == $oks{$g}) {
- $sum += $pts{$g};
- }
- }
- printf "%-40s %2d/%2d %2.3f %s\n", $s, $sum, $want{$s}, $maxtime, join("", @acc);
-}
+++ /dev/null
-# Makefile for MO-P contest environment
-# (c) 2008 Martin Mares <mj@ucw.cz>
-
-DIRS+=mop/eval
-PROGS+=$(addprefix $(o)/mop/eval/,\
- mo-ev-all mo-ev-inc mo-get-users \
- mo-score mo-report)
-
-$(o)/mop/eval/mo-ev-all: $(s)/mop/eval/mo-ev-all.sh
-$(o)/mop/eval/mo-ev-inc: $(s)/mop/eval/mo-ev-inc.sh
-$(o)/mop/eval/mo-get-users: $(s)/mop/eval/mo-get-users.sh
-$(o)/mop/eval/mo-report: $(s)/mop/eval/mo-report.sh
-$(o)/mop/eval/mo-score: $(s)/mop/eval/mo-score.sh
+++ /dev/null
-#!/bin/bash
-# Run `ev' on all solutions of given tasks
-
-[ -n "$1" ] || { echo "Usage: mo-ev-all <tasks>" ; exit 1 ; }
-
-while [ -n "$1" ] ; do
- for user in `bin/mo-get-users` ; do
- echo -e "\n### USER $user TASK $1 ###\n"
- bin/ev $user $1
- done
- shift
-done
+++ /dev/null
-#!/bin/bash
-# An incremental evaluator: detect which solutions were changed since
-# last run and run `ev' on them.
-
-[ -n "$1" ] || { echo "Usage: mo-ev-inc [--force] <tasks>" ; exit 1 ; }
-
-force=0
-if [ "$1" == --force ] ; then
- force=1
- shift
-fi
-for user in `bin/mo-get-users` ; do
- for task in "$@" ; do
- echo -n "$user/$task: "
- if [ -d solutions/$user/$task ] ; then
- N=`cd solutions/$user/$task && cat * | md5sum | head -c16`
- else
- N=none
- fi
- if [ -f testing/$user/$task/sum ] ; then
- O=`cat testing/$user/$task/sum`
- else
- O=none
- fi
- if [ $force == 1 -a $N != none ] ; then
- O=forced
- fi
- echo -n "($O $N) "
- if [ $O == $N ] ; then
- echo OK
- elif [ $N == none ] ; then
- rm -rf testing/$user/$task
- echo DELETED
- else
- echo CHANGED
- bin/ev $user $task
- echo $N >testing/$user/$task/sum
- fi
- done
-done
+++ /dev/null
-#!/bin/bash
-# List all contestants according to $CT_USER_LIST
-
-if [ "$1" = --help ] ; then
- echo "Usage: mo-get-users [--full]"
-fi
-[ -f cf/mop ] || { echo "Missing config file, check cwd." ; exit 1 ; }
-set -e
-. cf/mop
-
-if [ "$1" = --full ] ; then
- cut -d ' ' -f 1,2 <$CT_USER_LIST
-else
- cut -d ' ' -f 1 <$CT_USER_LIST
-fi
+++ /dev/null
-#!/usr/bin/perl
-# A simple generator of evaluation reports
-# (c) 2007 Martin Mares <mj@ucw.cz>
-
-use strict;
-use warnings;
-use POSIX;
-
-foreach my $user (`cd testing && ls`) {
- chomp $user;
- print "$user:";
- open REP, ">testing/$user/REPORT" or die;
- print REP "Evaluation report for CEOI 2007 Day 2\n\n";
- my $total = 0;
- foreach my $task (@ARGV) {
- print REP "### Task $task ###\n\n";
- if (open PTS, "testing/$user/$task/points") {
- my %merged_pts = ();
- my %split_comm = ();
- while (<PTS>) {
- chomp;
- my ($test, $pts, $comm) = /(\S+)\s+(\S+)\s+(.*)/;
- my $merged = $test;
- $merged =~ s/[^0-9]//;
- if (!defined($merged_pts{$merged}) || $merged_pts{$merged} > $pts) {
- $merged_pts{$merged} = $pts;
- }
- $split_comm{$merged}{$test} = $comm;
- }
- close PTS;
- my $tt = 0;
- foreach my $merged (sort { $a <=> $b } keys %merged_pts) {
- printf REP "Test %2s: %2d points", $merged, $merged_pts{$merged};
- $tt += $merged_pts{$merged};
- my @k = sort keys %{$split_comm{$merged}};
- if (@k == 1) {
- print REP " -- ", $split_comm{$merged}{$k[0]}, "\n";
- } else {
- print REP " -- ";
- my $cc = 0;
- foreach my $t (@k) {
- $cc++ and print REP ", ";
- print REP "$t: $split_comm{$merged}{$t}";
- }
- print REP "\n";
- }
- }
- print REP "\nTOTAL: $tt points\n\n";
- $total += $tt;
- print " $tt";
- } else {
- print REP "No solution submitted.\n\n";
- print " -";
- }
- }
- print REP "### TOTAL FOR DAY 2 ###\n\n";
- print REP "$total points\n";
- print REP "\n\n(generated on ", strftime("%Y-%m-%d %H:%M:%S", localtime), ")\n";
- close REP;
- print " -> $total\n";
-}
+++ /dev/null
-#!/usr/bin/perl
-# A generator of score sheets. More ugly than it deserves.
-
-$debug = 0;
-$detail = 0;
-$html = 0;
-$tex = 0;
-$extras = 0;
-$alt = 0;
-$merged = 0;
-$table = 0;
-$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--table] [--merged] [<directory>/]<task> ...";
-while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
- shift @ARGV;
- $var = "\$$1";
- if (!eval "defined $var") { die $usage; }
- eval "$var = 1;";
-}
-@ARGV || die $usage;
-
-$print_key = 1;
-if ($table) {
- open STDOUT, "|column -t -s'\t'" or die;
- $print_key = 0;
-}
-
-print STDERR "Scanning contestants... ";
-open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
-while (<CT>) {
- chomp;
- ($u,$f) = split /\t/;
- ($u eq "somebody") && next;
- $users{$u}=$f;
-}
-close CT;
-print STDERR 0+keys %users, "\n";
-
-print STDERR "Scanning exceptions... ";
-if ($extras && open (EX, "exceptions")) {
- while (<EX>) {
- chomp;
- (/^$/ || /^#/) && next;
- @a = split /\s+/;
- $u = shift @a;
- defined $users{$u} || die "Unknown user $u";
- while (@a) { $extra{$u} += shift @a; }
- }
- close EX;
- print STDERR "OK\n";
-} else { print STDERR "none\n"; }
-
-print STDERR "Scanning task results... ";
-%messages = ();
-%error_codes = ();
-foreach $u (keys %users) {
- foreach $task (@ARGV) {
- my ($dir, $t) = ("testing", $task);
- if ($task =~ m@^(.*)/([^/]*)$@) {
- $dir = $1;
- $t = $2;
- }
- $known_tasks{$t} = 1;
- $tt = "$dir/$u/$t/points" . ($alt ? ".alt" : "");
- -f $tt || next;
- print STDERR "$u/$t ";
- open (X, $tt) || die "Unable to open $tt";
- while (<X>) {
- chomp;
- /^(\S+) (-?\d+)\s*(.*)/ || die "Parse error: $_";
- $ttest = $1;
- $tpts = $2;
- $trem = $3;
- $trem =~ s/\[.*//;
- ($ttest_merged = $ttest) =~ s/[^0-9]//g;
- $ttest = $ttest_merged if $merged;
- $known_tests{$t}{$ttest} = 1;
- $cmt = $tpts;
- if ($tpts == 0 && $trem ne "OK") {
- if ($trem =~ /^Compile /) { $cmt = "CE"; }
- elsif ($trem =~ /^Time limit exceeded/) { $cmt = "TO"; }
- elsif ($trem =~ /^Exited with error /) { $cmt = "RE"; }
- elsif ($trem =~ /^Caught fatal signal /) { $cmt = "SG"; }
- elsif ($trem =~ /^([A-Za-z])\S*\s+([A-Za-z])/) {
- ($cmt = "$1$2") =~ tr/a-z/A-Z/;
- } elsif ($trem =~ /^([A-Za-z]{2})/) {
- ($cmt = $1) =~ tr/a-z/A-Z/;
- }
- if (!defined $messages{$trem}) {
- $messages{$trem} = $cmt;
- if (!defined $error_codes{$cmt}) {
- $error_codes{$cmt} = $trem;
- } else {
- $error_codes{$cmt} .= ", $trem";
- }
- }
- }
- if (!defined($results{$u}{$t}{$ttest}) || $results{$u}{$t}{$ttest} > $tpts) {
- $results{$u}{$t}{$ttest} = $tpts;
- $comment{$u}{$t}{$ttest} = $cmt;
- }
- if (!defined($results_merged{$u}{$t}{$ttest_merged}) || $results_merged{$u}{$t}{$ttest_merged} > $tpts) {
- $results_merged{$u}{$t}{$ttest_merged} = $tpts;
- }
- }
- close X;
- }
- foreach my $t (keys %known_tasks) {
- $total{$u}{$t} = 0;
- foreach my $pts (values %{$results_merged{$u}{$t}}) { $total{$u}{$t} += $pts; }
- }
-}
-print STDERR "OK\n";
-
-print STDERR "Creating table template... ";
-@header = ("Rank","User","Name");
-@body = ('','$u','$users{$u}');
-@bodysums = ();
-@footer = ('"Total"','','');
-if (keys %extra) {
- push @header, "Extra";
- push @body, '$extra{$u}';
- $col = 0+@footer;
- push @bodysums, $col;
- push @footer, "sum($col)";
-}
-@tasks = ();
-foreach $task (@ARGV) {
- my $t = ($task =~ m@/([^/]*)$@) ? $1 : $task;
- defined $known_tasks{$t} || die "Unknown task $t";
- push @tasks, $t;
- push @header, substr($t, 0, 4);
- push @body, "(\$xx = \$total{\$u}{'$t'}) > 0 ? \$xx : 0";
- $col = 0+@footer;
- push @footer, "sum($col)";
- push @bodysums, $col;
- if ($detail) {
- foreach $s (sort { $a <=> $b } keys %{$known_tests{$t}}) {
- push @header, "$s";
- push @body, "\$comment{\$u}{'$t'}{'$s'}";
- $col = 0+@footer;
- push @footer, "sum($col)";
- }
- }
-}
-push @header, "Total";
-push @body, join('+', map { $_ = "\$$_" } @bodysums);
-$col = 0+@footer;
-push @footer, "sum($col)";
-print STDERR "OK\n";
-
-print STDERR "h: ", join(':',@header), "\n" if $debug;
-print STDERR "b: ", join(':',@body), "\n" if $debug;
-print STDERR "f: ", join(':',@footer), "\n" if $debug;
-
-print STDERR "Filling in results... ";
-@table = ();
-foreach $u (keys %users) {
- $row = [];
- foreach my $c (@body) {
- $c =~ s/\$(\d+)/\$\$row[$1]/g;
- $x = eval $c;
- push @$row, (defined $x ? $x : '-');
- }
- print STDERR "row: ", join(':',@$row), "\n" if $debug;
- push @table, $row;
-}
-print STDERR "OK\n";
-
-print STDERR "Sorting... ";
-$sortcol = @{$table[0]} - 1;
-$namecol = 2;
-@table = sort {
- my $p, $an, $bn;
- $p = $$b[$sortcol] <=> $$a[$sortcol];
- ($an = $$a[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
- ($bn = $$b[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
- $p ? $p : ($an cmp $bn);
-} @table;
-$i=0;
-while ($i < @table) {
- $j = $i;
- while ($i < @table && ${$table[$i]}[$sortcol] == ${$table[$j]}[$sortcol]) {
- $i++;
- }
- if ($i == $j+1) {
- ${table[$j]}[0] = "$i.";
- } else {
- ${table[$j]}[0] = $j+1 . ".-" . $i . ".";
- $j++;
- while ($j < $i) { ${table[$j++]}[0] = " "; };
- }
-}
-print STDERR "OK\n";
-
-print STDERR "Attaching headers and footers... ";
-sub sum { my $col=shift @_; my $t=0; foreach my $z (0..@table-1) { $t += ${$table[$z]}[$col]; } $t; }
-map { $_ = eval $_; } @footer;
-push @table, \@footer;
-unshift @table, \@header;
-print STDERR "OK\n";
-
-if ($debug) {
- foreach $r (@table) { print join(':',@$r), "\n"; }
-} elsif ($html) {
- print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html40/strict.dtd">', "\n";
- print "<HTML><HEAD><TITLE>Rank list</TITLE></HEAD><BODY>\n";
- print "<H1>Rank list</H1>\n";
-
- my @perm;
- &printHtmlHeader(\@perm);
- print "<tbody>";
-
- foreach $r (@table[1..($#table - 1)]) {
- &printHtmlRow(@{$r}[@perm]);
- }
-
- print "<tbody>";
- &printHtmlRow(@{$table[$#table]}[@perm]);
-
- print "</TABLE>\n";
- if ($detail) {
- print "<H2>Error codes</H2><UL>\n";
- foreach $r (sort keys %error_codes) { print "<LI>$r: $error_codes{$r}\n"; }
- print "</UL>\n";
- }
- print "</BODY></HTML>\n";
-} elsif ($tex) {
- print "\\error{TeX output not supported yet!}\n";
-} else {
- foreach $r (@table) { print join("\t",@$r), "\n"; }
- if ($print_key) {
- print "\n";
- foreach $r (sort keys %error_codes) { print "$r: $error_codes{$r}\n"; }
- }
-}
-
-sub printHtmlRow {
- print "<TR>", join('',map {
- if ($hdr) { $_ = "<TH>$_"; }
- else { $_ = "<TD align=" . (/^[0-9A-Z-]+$/ ? "right" : "left") . (length($_) > 14 ? " width=150" : "") . ">$_"; }
- } @_), "\n";
-}
-
-sub printHtmlHeader {
-
- my ($perm) = @_;
-
- my $colspec = "<colgroup span=3>";
- my $hdr1;
- my $hdr2;
-
- @$perm = (0, 1, 2);
- my $p = 3;
-
- if ($detail) {
- $hdr1 = "<th rowspan=2>Rank<th rowspan=2>User<th rowspan=2>Name";
- $extras and $p++ and push @$perm, 3 and $hdr1.="<th rowspan=2>Extra" and $colspec.="<colgroup span=1>"; ##Extra hack
- for my $task (@tasks) {
-
- my $nSub = scalar(keys %{$known_tests{$task}});
-
- $p++;
- map { push @$perm, $p++ } (1..$nSub);
- push @$perm, $p - $nSub - 1;
-
- $colspec .= "<colgroup span='" . $nSub . "'>\n";
- $colspec .= "<colgroup span='1'>\n";
- $hdr1 .= "<th colspan='" . ($nSub + 1) . "' style='border-bottom:1px solid black;'>$task";
- $hdr2 .= join("", map { "<th>$_" } sort {$a <=> $b} keys %{$known_tests{$task}});
- $hdr2 .= "<th>Total";
- }
-
- $hdr1 .= "<th rowspan='2'>Total";
-
- } else { ## no detail
-
- $hdr1 = "<th>Rank<th>User<th>Name";
- $extras and $p++ and push @$perm, 3 and $hdr1.="<th>Extra" and $colspec.="<colgroup span=1>"; ##Extra hack
-
- for my $task (@tasks) {
- push @$perm, $p++;
- $hdr1 .= "<th>$task";
- }
- $hdr1 .= "<th>Total";
- $colspec .= "<colgroup span='" . scalar (@tasks) . "'>";
- }
-
- push @$perm, $p++;
-
- print "<TABLE rules=groups frame=all border='1' cellpadding='2'>\n";
- print "$colspec<colgroup span='1'>\n";
- print "<tr>$hdr1</tr>\n";
- print "<tr>$hdr2</tr>\n" if $detail;
-
-}
-
-close STDOUT;
+++ /dev/null
-This patch against debian fpc-2.2.2-8 does the following:
-When a pascal program is compiled with -gl, then any runtime
-error (either internal, caused by caught signal, or runerror())
-dumps the stack and then kills itself by SIGABRT.
-
-This is to allow catching runtime errors in gdb.
-
-Details: We want the stack to be as small as possible when sending
-SIGABRT. That is why DumpStackAndAbort is a macro and not a function
-and why we call syscall using assembly. Another trick we do is
-to place abort calls not only in HandleErrorAddrFrame, but in
-fpc_rangecheck, fpc_iocheck, fpc_... too. If a rangecheck fails,
-the resulting stack trace is:
-(gdb) bt
-#0 0x08058409 in fpc_rangeerror ()
-#1 0x08048115 in F (I=0) at testp.pas:13
-
-Beware, gdb is not able to decode stack if the abort is called
-in HandleErrorAddrFrame. That was another reason why fpc_*chech
-methods calls abort themselves, not relying on HandleErrorAddrFrame.
+++ /dev/null
---- fpc-2.2.2/fpcsrc/rtl/inc/system.inc.ori 2009-03-16 16:28:29.000000000 +0100
-+++ fpc-2.2.2/fpcsrc/rtl/inc/system.inc 2009-03-16 18:29:45.000000000 +0100
-@@ -585,27 +585,65 @@
- Miscellaneous
- *****************************************************************************}
-
-+{ MOP 2009 patch: call sigabort when -gl was used in compilation }
-+const
-+ DontHaltInHandleError : boolean = false;
-+
-+function IsCompiledWithGl : boolean;
-+begin
-+ { -gl modifies BackTraceStrFunc to point to lineinfo unit }
-+ IsCompiledWithGl := BackTraceStrFunc <> @SysBackTraceStr;
-+end;
-+
-+procedure InternalExit; forward;
-+{ We define next method as a macro, because we do not want to
-+ show it when a stack is dumped. Because of the same reason
-+ we call SYSCALL_KILL ourselves in assembler code. }
-+{$MACRO ON}
-+{$define DumpStackAndAbort:=
-+ begin
-+ InternalExit;
-+ asm
-+ movl $20, %eax; { SYSCALL_GETPID as first argument }
-+ int $0x80; { GETPID -> eax }
-+ movl %eax, %ebx; { PID as second argument }
-+ movl $37, %eax; { SYSCALL_KILL as first argument }
-+ movl $6, %ecx; { SIGABRT as third argument }
-+ int $0x80; { KILL }
-+ end;
-+ end
-+}
-+{ MOP 2009 patch ends }
-+
- procedure fpc_rangeerror;[public,alias:'FPC_RANGEERROR']; compilerproc;
- begin
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(201,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
-
-
- procedure fpc_divbyzero;[public,alias:'FPC_DIVBYZERO']; compilerproc;
- begin
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(200,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
-
-
- procedure fpc_overflow;[public,alias:'FPC_OVERFLOW']; compilerproc;
- begin
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(215,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
-
-
- procedure fpc_threaderror; [public,alias:'FPC_THREADERROR'];
- begin
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(6,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
-
-
-@@ -619,7 +657,9 @@
- begin
- l:=HInOutRes^;
- HInOutRes^:=0;
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(l,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
- end;
-
-@@ -648,7 +688,9 @@
- begin
- if assigned(SafeCallErrorProc) then
- SafeCallErrorProc(res,get_frame);
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(229,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
- result:=res;
- end;
-@@ -680,7 +722,9 @@
- if (c <= StackBottom) then
- begin
- StackError:=true;
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleError(202);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
- end;
- {$IFDEF STACKCHECK}
-@@ -862,6 +906,8 @@
- errorcode:=word(Errno);
- erroraddr:=addr;
- errorbase:=frame;
-+ if DontHaltInHandleError then exit; { MOP 2009 patch }
-+ if IsCompiledWithGl then DumpStackAndAbort; { MOP 2009 patch }
- {$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
- if ExceptAddrStack <> nil then
- raise TObject(nil) at addr,frame;
-@@ -903,6 +949,7 @@
- errorcode:=w;
- erroraddr:=get_caller_addr(get_frame);
- errorbase:=get_caller_frame(get_frame);
-+ if IsCompiledWithGl then DumpStackAndAbort; { MOP 2009 patch }
- {$ifdef FPC_HAS_FEATURE_EXITCODE}
- if errorcode <= maxExitCode then
- halt(errorcode)
-@@ -1148,7 +1195,9 @@
- begin
- If pointer(AbstractErrorProc)<>nil then
- AbstractErrorProc();
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(211,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
- end;
-
-
-@@ -1156,8 +1205,11 @@
- begin
- if pointer(AssertErrorProc)<>nil then
- AssertErrorProc(Msg,FName,LineNo,ErrorAddr)
-- else
-+ else begin
-+ if IsCompiledWithGl then DontHaltInHandleError := true; { MOP 2009 patch }
- HandleErrorFrame(227,get_frame);
-+ DumpStackAndAbort; { MOP 2009 patch }
-+ end
- end;
-
-
+++ /dev/null
-# Makefile for MO-P contest environment
-# (c) 2008 Martin Mares <mj@ucw.cz>
-
-DIRS+=mop/public
-PROGS+=$(addprefix $(o)/mop/public/,check compile status submit)
-
-$(o)/mop/public/check: $(s)/mop/public/check.sh
-$(o)/mop/public/compile: $(s)/mop/public/compile.sh
-$(o)/mop/public/status: $(s)/mop/public/status.sh
-$(o)/mop/public/submit: $(s)/mop/public/submit.sh
+++ /dev/null
-#!/bin/bash
-# The Evaluator -- Public Checking Script
-# (c) 2001--2008 Martin Mares <mj@ucw.cz>
-
-set -e
-[ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
-pushd $MO_ROOT >/dev/null
-. lib/libeval.sh
-. cf/mop
-popd >/dev/null
-
-function usage
-{
- die "Usage: check [-s <source-file>] <problem> [<test-number>]"
-}
-
-SRCFILE=
-while getopts "s:" opt ; do
- case $opt in
- s) SRCFILE="$OPTARG"
- ;;
- *) usage
- ;;
- esac
-done
-shift $(($OPTIND-1))
-[ -n "$1" ] || usage
-PROBLEM=$1
-TEST=
-shift
-if [ -n "$1" ] ; then
- TEST="$1"
- shift
-fi
-[ -z "$1" ] || usage
-
-public-setup
-. $PDIR/config
-
-function test-verdict
-{
- pend "$2"
- if [ $1 == 0 ] ; then
- exit 1
- else
- exit 0
- fi
-}
-
-if [ $TASK_TYPE == open-data ] ; then
- [ -n "$TEST" ] || die "You need to specify test number for open data problems."
- pstart "Checking $TEST: "
- test-config
- open-locate "$SRCFILE"
- try-ln "$SDIR/$SRCN" $TDIR/$TEST.out
- syntax-check
- test-result $POINTS_PER_TEST OK
-else
- [ -z "$TEST" ] || die "Test number should be given only for open data problems."
- locate-source "$SRCFILE"
- compile
- RC=0
- for TEST in $SAMPLE_TESTS ; do
- (
- pstart "Checking on sample input $TEST: "
- test-config
- test-run
- syntax-check
- output-check
- ) || RC=1
- done
- exit $RC
-fi
+++ /dev/null
-# The Evaluator -- Public Compilation Script
-# (c) 2001 Martin Mares <mj@ucw.cz>
-
-set -e
-[ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
-pushd $MO_ROOT >/dev/null
-. lib/libeval.sh
-. cf/eval
-. cf/mop
-popd >/dev/null
-
-[ -n "$1" ] || die "Usage: compile (<problem> | <file> [<options>])"
-if [ "${1%%.*}" == "$1" ] ; then
- # Compiling problem
- PROBLEM=$1
- public-setup
- . $PDIR/config
- locate-source
- if compile ; then
- mv $TDIR/$PROBLEM .
- else
- echo >&2
- sed <check-log >&2 '1,/^Compiler output:/d;/^Compiler output files:/,$d;/^Exited /d'
- fi
-else
- SRC=$1
- [ -f $SRC ] || die "$SRC doesn't exist"
- EXE=${1%%.*}
- SRCEXT=${1/*./}
- shift
- EXTRA_CFLAGS="$@"
- CCMD=EXT_${SRCEXT}_COMP
- [ -n "${!CCMD}" ] || die "Don't know how to compile $SRC"
- CCMD="`eval echo ${!CCMD}`"
- echo "$CCMD"
- $CCMD
-fi
+++ /dev/null
-#!/bin/bash
-# The Evaluator -- Public Status Script
-# (c) 2004 Martin Mares <mj@ucw.cz>
-
-set -e
-[ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
-pushd $MO_ROOT >/dev/null
-. lib/libeval.sh
-. cf/mop
-popd >/dev/null
-
-[ -z "$1" ] || die "Usage: status"
-
-echo -e "Submitted tasks:\n"
-
-if [ -n "$REMOTE_SUBMIT" ] ; then
- exec $MO_ROOT/bin/remote-status
-fi
-
-for PROBLEM in `cd $MO_ROOT/problems/ ; echo *` ; do
- (
- PDIR=$MO_ROOT/problems/$PROBLEM
- SUBDIR=~/.submit/$PROBLEM
- [ -f $PDIR/config ] || exit 0
- echo -n "$PROBLEM: "
- . $PDIR/config
- if [ -d $SUBDIR ] ; then
- if [ $TASK_TYPE == open-data ] ; then
- for X in $TESTS ; do
- [ -f $SUBDIR/$X.out ] && echo -n "$X " || echo -n "- "
- done
- echo
- else
- C=0
- for X in $EXTENSIONS ; do
- if [ -f $SUBDIR/$PROBLEM.$X ] ; then
- echo -n `basename $SUBDIR/$PROBLEM.$X`
- C=$(($C+1))
- fi
- done
- if [ $C == 0 ] ; then
- echo ---
- elif [ $C == 1 ] ; then
- echo
- else
- echo "INCONSISTENT (you probably modified $SUBDIR manually)"
- fi
- fi
- else
- echo ---
- fi
- )
-done
+++ /dev/null
-#!/bin/bash
-# The Evaluator -- Public Submit Script
-# (c) 2001--2007 Martin Mares <mj@ucw.cz>
-
-set -e
-[ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
-pushd $MO_ROOT >/dev/null
-. lib/libeval.sh
-. cf/mop
-popd >/dev/null
-
-function usage
-{
- die "Usage: submit [--force] [-s <source-file>] <problem> [<test-number>]"
-}
-
-FORCE=0
-if [ "$1" = --force ] ; then
- FORCE=1
- shift
-fi
-[ -n "$1" -a "$1" != "--help" ] || usage
-SRCFILE=
-while getopts "s:" opt ; do
- case $opt in
- s) SRCFILE="$OPTARG"
- ;;
- *) usage
- ;;
- esac
-done
-shift $(($OPTIND-1))
-[ -n "$1" ] || usage
-PROBLEM=$1
-PART=
-shift
-if [ -n "$1" ] ; then
- PART="$1"
- shift
-fi
-[ -z "$1" ] || usage
-public-setup
-. $PDIR/config
-
-function test-verdict
-{
- pend "$2"
- [ $1 == 0 ] && exit 1 || exit 0
-}
-
-FAILED=0
-if [ $TASK_TYPE == open-data ] ; then
- [ -n "$PART" ] || die "You need to specify test number for open data problems."
- TEST=$PART
- pstart "Test case $TEST: "
- open-locate "$SRCFILE"
- (
- [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
- try-ln "$SDIR/$SRCN" $TDIR/$TEST.out
- syntax-check
- test-result $POINTS_PER_TEST OK
- ) || FAILED=1
-else
- [ -z "$PART" ] || die "Test number should be given only for open data problems."
- locate-source "$SRCFILE"
- compile
- for TEST in $SAMPLE_TESTS ; do
- (
- pstart "Checking on sample input $TEST: "
- [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
- test-run
- syntax-check
- output-check
- die "How could I get there? It's a buuuuug!"
- ) || FAILED=$(($FAILED+1))
- done
-fi
-
-if [ $FAILED != 0 ] ; then
- if [ $FORCE != 0 ] ; then
- echo "Submit forced."
- pend "TESTS FAILED, but --force given, so submitting anyway."
- else
- pend "TESTS FAILED. Nothing has been submitted!"
- pend "Use submit --force if you really want to submit an obviously WRONG solution."
- exit 1
- fi
-fi
-
-if [ -n "$REMOTE_SUBMIT" ] ; then
- pstart "Submitting to the server... "
- $MO_ROOT/bin/remote-submit $PROBLEM $PART "$SDIR/$SRCN"
- pend "OK"
- exit 0
-fi
-
-pstart "Submitting... "
-mkdir -p ~/.submit
-if [ $TASK_TYPE == open-data ] ; then
- mkdir -p ~/.submit/$PROBLEM
- cp "$SDIR/$SRCN" ~/.submit/$PROBLEM/$PART.out
-else
- rm -rf ~/.submit/$PROBLEM
- mkdir -p ~/.submit/$PROBLEM
- cp "$SDIR/$SRCN" ~/.submit/$PROBLEM/
-fi
-pend "OK"
+++ /dev/null
-# Makefile for MO-P contest environment
-# (c) 2008 Martin Mares <mj@ucw.cz>
-
-DIRS+=mop/score
-PROGS+=$(addprefix $(o)/mop/score/,mo-score-mop)
-
-$(o)/mop/score/mo-score-mop: $(s)/mop/score/mo-score-mop.sh
+++ /dev/null
-#!/usr/bin/perl
-use strict;
-use warnings;
-use List::Util qw(min);
-
-@ARGV or die "Usage: mo-score-mop task1 task2 ...";
-
-print STDERR "Scanning contestants... ";
-open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
-my %users = ();
-while (<CT>) {
- chomp;
- my ($u, $f) = split /\t/;
- $u =~ /^mo/ or next;
- $users{$u}=$f;
-}
-close CT;
-print STDERR 0+keys %users, "\n";
-
-print STDERR "Scanning task results... ";
-my %tasks = ();
-for my $u (keys %users) {
- for my $t (@ARGV) {
- my $tt = "testing/$u/$t/points";
- -f $tt || next;
- print STDERR "$u/$t ";
- open (X, $tt) || die "Unable to open $tt";
- my %groups = ();
- while (<X>) {
- chomp;
- my ($test, $pts) = /^(\S+) (-?\d+)/ or die "Parse error: $_";
- my $group = $test;
- $group =~ s{\D}{}g;
- if (defined $groups{$group}) {
- $groups{$group} = min($groups{$group}, $pts);
- } else {
- $groups{$group} = $pts;
- }
- }
- close X;
-
- for my $g (keys %groups) {
- $tasks{$u}{$t} += $groups{$g};
- }
- }
-}
-print STDERR "OK\n";
-
-print STDERR "Generating output... ";
-for my $u (sort keys %users) {
- print join("\t", $u, $users{$u}, map { $tasks{$u}{$_} // '-' } @ARGV), "\n";
-}
-print STDERR "OK\n";
-