?? grade-datalab.pl
字號:
#!/usr/bin/perl
#!/usr/local/bin/perl
use Getopt::Std;
use lib ".";
use config;
#########################################################################
# grade-datalab.pl - Data Lab autograder (iCarnegie Windows Version)
#
# Copyright (c) 2002, R. Bryant and D. O'Hallaron, All rights reserved.
# May not be used, modified, or copied without permission.
#
# This program automatically grades a Data Lab handin bits.c file and
# prints a report on stdout that can be handed back to the students.
#
# Grading policy:
# Solutions that violate the coding rules get zero points. Solutions with
# zero errors gets full points (given by the rating of the problem).
# Solutions with one error half credit. Solutions with more than one
# error get zero points.
#
#########################################################################
$| = 1; # autoflush output on every print statement
# Any files created by this script are readable only by the user
umask(0077);
#
# usage - print help message and terminate
#
sub usage {
printf STDERR "$_[0]\n";
printf STDERR "Usage: $0 [-he] -f <filename> [-s <srcdir>]\n";
printf STDERR "Options:\n";
printf STDERR " -h Print this message.\n";
printf STDERR " -f <file> C file to be graded.\n";
printf STDERR " -s <srcdir> Location of directory with support code\n";
printf STDERR " -e Don't include the original handin file on the grade sheet\n";
die "\n";
}
##############
# Main routine
##############
#
# Parse the command line arguments
#
getopts('hef:s:');
if ($opt_h) {
usage();
}
if ((!$opt_f)) {
usage("Missing required argument (-f)");
}
#
# These optional flags override defaults in config.pm
#
if ($opt_s) { # driver src directory
$SRCDIR = $opt_s;
}
#
# Initialize some file and path names
#
$infile = $opt_f; # input C file
($infile_basename = $infile) =~ s#.*/##s; # basename of input file
# absolute pathname of src directory
$srcdir_abs = `cd $SRCDIR; pwd`;
chomp($srcdir_abs);
$handout_dir = "$srcdir_abs"; # handout directory
$btest_dir = "$srcdir_abs"; # btest directory
$tmpdir = "/tmp/$infile_basename.$$"; # scratch directory
$0 =~ s#.*/##s; # this prog's basename
#
# This is a message we use in several places when the program dies
#
$diemsg = "The files are in $tmpdir.";
#
# Make sure the handout directory exists
#
(-d $handout_dir and -e $handout_dir)
or die "$0: ERROR: Directory $handout_dir does not exist.\n";
#
# Make sure the input file exists and is readable
#
open(INFILE, $infile)
or die "$0: ERROR: could not open file $infile\n";
close(INFILE);
#
# Set up the contents of the scratch directory
#
system("mkdir $tmpdir");
system("cp $infile $tmpdir/bits.c");
system("cp $btest_dir/btest.c $tmpdir");
system("cp $btest_dir/decl.c $tmpdir");
system("cp $btest_dir/tests.c $tmpdir");
system("cp $btest_dir/btest.h $tmpdir");
system("cp $btest_dir/bits.h $tmpdir");
system("cp $btest_dir/getopt.c $tmpdir");
system("cp $btest_dir/getopt.h $tmpdir");
system("cp $btest_dir/tailor.h $tmpdir");
system("cp $handout_dir/Makefile $tmpdir");
# Print header
print "\nCS:APP Data Lab: Grading Sheet for $infile_basename\n\n";
#
# Compile students submission into driver
#
print "Part 0: Compilation Results for Correctness Score\n\n";
system("(cd $tmpdir; make clean > /dev/null 2>&1)");
system("(cd $tmpdir; make btest)") == 0
or die "$0: ERROR: $infile_basename did not compile (c). $diemsg\n";
#
# Generate correctness score
#
print "\f\nPart 1: Correctness Tests (invalid operations must be detected manually)\n\n";
print("Results of running 'btest -g':\n");
system("$tmpdir/btest -g") == 0
or die "$0: ERROR: btest failed. $diemsg\n";
#
# Optionally print the original handin file
#
if (!$opt_e) {
print "\f\nPart 2: Original $infile file\n\n";
system("cat $infile");
}
#
# Everything went OK, so remove the scratch directory
#
system("rm -fr $tmpdir");
exit;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -