מערכת הגשת תרגילים: הוראות למתרגל

בדיקה אוטומטית

בנוסף לאפשרות של הגשת תרגילים באמצעות האינטרנט, המערכת מאפשרת בדיקה אוטומטית של נכונות תוכניות מחשב הנשלחות כתרגיל. המערכת מקמפלת את התוכנית שהוגשה ומריצה אותה עם קלטים שהוכנו על ידי המתרגל לאחר מכן המערכת משווה את הפלטים שהתקבלו לפלטים המתאימים שהוכנו על ידי המתרגל. הציון נקבע לפי הניקוד שהמתרגל נתן לכל מקרה בדיקה. נכון לעכשיו, המערכת יכולה לבדוק תוכניות שנכתבו בשפות: C, C++, Java, .Python, Assembly, SCIM ,SML, Prologue, Perl, Matlab

כדי שתרגיל יבדק אוטומטית, המתרגל צריך להכין שני קבצים. קובץ אחד auto.cfg מפרט את התכונות של כל התרגילים בקורס. קובץ שני targil_name.io מכיל את הקלטים ואת הפלטים הנכונים של הבדיקה, קובץ זה יש להכין עבור כל תרגיל בקורס. שני הקבצים צריכם להמצא בתיקיה data, קיומו של הקובץ auto.cfg מסמן למערכת שהתרגילים בקורס זה נבדקים אוטומטית.

הקובץ auto.cfg

לקובץ זה מבנה של קובץ של קובץ ini., לכל תרגיל יש פיסקה שמתחילה בשורה [targil_name] ואחריה שורות של  parameter=value שמפרטות את תכונות התרגיל. שם התרגיל צריך להיות זהה לשם שניתן בזמן הוספת התרגיל בפקודה make_targil. את השורות שמפרטות את התכונות אפשר לכתוב בכל סדר.

דוגמא:

[targil1]
required parameter#
 compiler = java
 all other parameters are optional#
 input = myinput
 output = myoutput
 timeout = 60
 timing = 1
 memleak = 1
 feedback = 1
 data_files = targil1_data
 weight = 25
 message = A bonus will be given for efficient programs
 [targil2]
 compiler = cpp
 input = stdin
 output = stdout
 [targil3]
 compiler = make
 alias=<<END_ALIAS
 targil3.1
 targil3.2
 targil3.3
 END_ALIAS

פירוט הפרמטרים והערכים:

compiler = # required parameter

 c — The file "targil_name.c" is compiled with the command
gcc targil_name.c -lm -ansi -pedantic; "a.out" is run

cpp — The file "targil_name.cpp" is compiled with the command
 g++ targil_name.cpp -lm -ansi -pedantic; "a.out" is run

s — The file "targil_name.s" is compiled with the command
 gcc -m32 targil_name.s; "a.out" is run

java — The files are compiled with the command
javac *.java"; "java targil_name" is run

py — No compilation; "python targil_name.py" is run

py3 — No compilation; "python3 targil_name.py" is run

 scm — No compilation; "guile -s targil_name.scm" is run

sml — No compilation; "sml @SMLload=heapimage.x86-linux" is run

pl — No compilation
 swipl -q -g "consult('$exercise.pl'), $input_string" -t "halt" is run

 plx — No compilation; "perl targil_name.plx" is run

make — The files are compiled according to a "makefile" supplied by student
  a.out" is run"

 dm — dummy; submitted files may be checked latter

 m — No compilation; 'matlab -nodisplay -r "check(),quit"' is run
 (check.m is supplied by metargel to check the .m files sent by students)

 sh - bash

 ant – "ant compile" for compilation and "ant" to run. It sets appropriate ANT_HOME environment variable.

 ant_compile – just compile with "ant compile" but do not run it.

 net — Submitted files will be copied to and executed on virtual machines to test
 network connectivity
input = # default = stdin

.stdin — the program should read its input from standard input
.standard input will contain the test input

 Any "file_name" except "stdin" — the program should read its input from
.a file named "file_name". The file "file_name" will contain the test input
output = # default = stdout

 .stdout — the program should write its output to standard output
.standard output will be compared to the correct output

 Any "file_name" except "stdout" — the program should write its output to a file
.named "file_name". The file "file_name" will be compared to the correct output
timeout = # default = 12

.A timeout in seconds that limits the execution of checked programs
timing = # default = 0

‎1 — timing is enabled, execution time in seconds is recorded in "grades.txt" next
to the mark of each test case, in the format "mark/time".‎
.Execution time is reported to student if feedback = 1
 .The command "make_csv_long" will display this information
memleak = # default = 0

‎1 — memleak is enabled, memory leak in bytes is recorded in "grades.txt" next
to the mark of each test case, in the format "mark/time/lost/not-freed".‎
.Memory leak is reported to student if feedback = 1
.The command "make_csv_long" will display this information
feedback = # default = 0

‎1 — email sent as a response to submission of checked programs
.will include feedback
exact = # default = 1

‎1 — In both program output and correct output, whitespace is trimmed
before and after each line and consecutive spaces and/or tabs within
line are replaced by one space. Also, empty lines are trimmed too.
To avoid these behaviors set exact to 1.‎
data_files = # default = none‎

dir_name — a copy of the files within the directory
course_name/data/dir_name" will be available to the program~"
.at execution time for reading and writing
.The files will be copied again for each test case
weight = # default = 0
 This field will be used by make_csv to calculate the average grade
.for the course assignments
alias = # default = none
 alias_name — input/output for checking will be taken from
.the file alias_name.io
 Files within the directory "~course_name/data/alias_name" will be
.compiled together with the submitted files
.The grade will be given for targil alias_name

More than one alias can be denoted using the shell "here document syntax":‎

 alias=<<END_ALIAS
 alias1
 alias2
 END_ALIAS

To set a weight to aliases, each alias needs a section with a "weight" parameter
 .(see example above)
message = # default = none

This field can be used to send a message to students,‎
the message will be attached to the email sent after submission.‎

הקובץ targil_name.io

קובץ זה מכיל את הקלטים והפלטים הנכונים עבור מקרי הבדיקה.סוף כל קלט מסומן על ידי שורה המתחילה END_INPUT וסוף כל פלט על ידי שורה המתחילה END_OUTPUT. בהמשך שורת END_OUTPUT יופיע ציון עבור אותו מקרה. אם הפלט של התוכנית הנבדקת תואם לפלט הנכון, ציון זה נוסף לציון התרגיל.

בדוגמא הבאה, התוכנית הנבדקת מקבלת כקלט שני מספרים וצריכה להדפיס את הממוצע שלהם. הוכנו שני מקרי בדיקה, במקרה הראשון הקלט הוא 3.0 ו- 4.0 והפלט הנכון הוא: “The average is 3.5”, ובמקרה השני הקלט הוא 1.0 ו- 0.5 והפלט הנכון הוא: “The average is 0.75”. עבור המקרה הראשון יתווסף לציון 60 נקודות ועבור המקרה השני 40.

3.0
4.0
END_INPUT
 The average is 3.50
 END_OUTPUT 60
 1.0
 0.5
END_INPUT
 The average is 0.75
 END_OUTPUT 40